Android Developers Blog: Media3 1.8.0

Android Developers Blog: Media3 1.8.0

Home » News » Android Developers Blog: Media3 1.8.0
Table of Contents

Posted by Toni Heidenreich – Engineering Supervisor

This launch contains a number of bug fixes, efficiency enhancements, and new options. Learn on to seek out out extra, and as all the time please try the complete launch notes for a complete overview of modifications on this launch.

Scrubbing in ExoPlayer

This launch introduces a scrubbing mode in ExoPlayer, designed to optimize efficiency for frequent, user-driven seeks, like dragging a search bar deal with. You may allow it with ExoPlayer.setScrubbingModeEnabled(true). We have additionally built-in this into PlayerControlView within the UI module the place it may be enabled with both time_bar_scrubbing_enabled=”true” in XML or the setTimeBarScrubbingEnabled(boolean) methodology. Media3 1.8.0 comprises the primary batch of scrubbing enhancements, with extra to return in 1.9.0!

moving image showing repeated seeking while scrubbing with scrubbing mode off in ExoPlayer

Repeated in search of whereas scrubbing with scrubbing mode OFF

moving image showing repeated seeking while scrubbing with scrubbing mode on in ExoPlayer

Repeated in search of whereas scrubbing with scrubbing mode ON

Stay streaming adverts with HLS interstitials

Extending the preliminary help for VOD in Media3 1.6.0, HlsInterstitialsAdsLoader now helps reside streams and asset lists for all of your server-guided advert insertion (SGAI) wants. The Google Adverts Supervisor staff explains how SGAI works. Comply with our documentation for learn how to combine HLS interstitals into your app.

chart of HLS intertitials processing flow from content server to ads server to Exoplayer

HLS interstitials processing move

Period retrieval with out playback

MetadataRetriever has been considerably up to date – it is now utilizing an AutoCloseable sample and allows you to retrieve the length of media objects with out playback. This implies Media3 now presents the complete performance of the Android platform MediaMetadataRetriever however with out having to fret about gadget particular quirks and cross-process communication (some components like body extraction are nonetheless experimental, however we’ll combine them correctly sooner or later).

attempt {
  MetadataRetriever.Builder(context, mediaItem).construct().use {
     val trackInfo = it.retrieveTrackGroups().await()
     val length = it.retrieveDurationUs().await()
  }
} catch (e: IOException) {
  handleFailure(e)
}

Partial downloads, XR audio routing and extra environment friendly playback

There have been a number of different enhancements and bug fixes throughout ExoPlayer and playback associated elements. To call just some:

    • Downloader implementations now help partial downloads, with a brand new PreCacheHelper to prepare handbook caching of single objects. This can be built-in into ExoPlayer’s DefaultPreloadManager in Media3 1.9.0 for an much more seamless caching and preloading expertise.
    • When created with a Context with a digital gadget ID, ExoPlayer now routinely routes the audio to the digital XR gadget for that ID.
    • We enabled extra environment friendly interactions with Android’s MediaCodec, for instance skipping buffers that aren’t wanted earlier within the pipeline.

Playback resumption in demo app and higher notification defaults

The MediaSession module has a number of modifications and enhancements for notification dealing with. It is now retaining notifications for longer by default, for instance when playback is paused, stopped or failed, so {that a} consumer has extra time to renew playback in your app. Notifications for reside streams (particularly with DVR home windows) additionally grew to become extra helpful by eradicating the complicated DVR window length and progress from the notification.

The media session demo app now additionally helps playback resumption to showcase how the characteristic may be built-in into your app! It permits the consumer to renew playback lengthy after your app has been terminated and even after reboot.

Media resumption notification after device reboot

Media resumption notification after gadget reboot

Quicker trim operations with edit checklist help

We’re persevering with so as to add optimizations for quicker trim operations to Transformer APIs. Within the new 1.8.0 launch, we launched help for trimming utilizing MP4 edit lists. Name experimentalSetMp4EditListTrimEnabled(true) to make trim-only edits considerably quicker.

val transformer = Transformer.Builder(requireContext())
        .addListener(transformerListener)
        .experimentalSetMp4EditListTrimEnabled(true)
        .construct()

An ordinary trimming operation typically requires a full re-transcoding of the video, even for a easy trim. This meant decoding, re-encoding all the file, which is a time-consuming and resource-intensive course of. With MP4 edit checklist help, Transformer can now carry out “trim-only” edits far more effectively. As a substitute of re-encoding, it leverages the prevailing encoded samples and defines a “pre-roll” inside the edit checklist. This pre-roll primarily tells the participant the place to begin playback inside an present encoded pattern, successfully skipping the undesirable starting portion.

The next diagram illustrates how this works:

processing overview for faster trim optimizations

Processing overview for quicker trim optimizations

As illustrated above, every file comprises encoded samples and every pattern begins with a keyframe. The crimson line signifies the supposed clip level within the authentic file, permitting us to soundly discard two first samples. The most important distinction on this method lies in how we deal with the third encoded pattern. As a substitute of working a transcoding operation, we transmux this pattern and outline a pre-roll for a video begin place. This considerably accelerates the export operation; nevertheless this optimization is just relevant if no different results are utilized. Participant implementations may ignore the pre-roll part of the ultimate video and play from the beginning of the encoded pattern.

Chipset particular optimizations with CodecDbLite

CodecDBLite optimizes two components of encoder configuration on a chipset-by-chipset foundation: codec choice and B-frames. Relying on the chipset, these parameters can have both a constructive or opposed impression on video high quality. CodecDB Lite leverages benchmark information collected on manufacturing gadgets to advocate a configuration that achieves the utmost user-perceived high quality for the developer’s goal bitrate. By enabling CodecDB Lite, builders can leverage superior video codecs and options with out worrying about whether or not or not they work on a given gadget.

To make use of CodecDbLite, merely name setEnableCodecDbLite(true) when constructing the encoder manufacturing facility:

val transformer =
    Transformer.Builder()
        .setEncoderFactory(
            DefaultEncoderFactory.Builder()
                .setEnableCodecDbLite(true)
                .construct()
        )
        .construct()

New Composition demo

The Composition Demo app has been refreshed, and is now constructed totally with Kotlin and Compose to showcase superior multi-asset modifying capabilities in Media3. Our staff is actively extending the APIs, and future releases will introduce extra superior modifying options, corresponding to transitions between media objects and different extra superior video compositing settings.

Adaptive-first: Enhancing flows can get difficult, so it helps to reap the benefits of as a lot display screen actual property as potential. With the adaptive layouts supplied by Jetpack Compose, such because the supporting pane format, we are able to dynamically adapt the UI primarily based on the gadget’s display screen dimension.

new Composition demo app

Processing overview for quicker trim optimizations

Multi-asset video compositor: We’ve added a customized video compositor that demonstrates learn how to prepare enter media objects into totally different layouts, corresponding to a 2×2 grid or a picture-in-picture overlay. These compositor settings are utilized to the Composition, and can be utilized each with CompositionPlayer for preview and Transformer for export.

picture-in-picture video overlay in the Composition demo app

Image-in-picture video overlay within the Composition demo app

Get began with Media3 1.8.0

Please get in contact by way of the Media3 problem Tracker for those who run into any bugs, or you probably have questions or characteristic requests. We look ahead to listening to from you!

Supply hyperlink

author avatar
roosho Senior Engineer (Technical Services)
I am Rakib Raihan RooSho, Jack of all IT Trades. You got it right. Good for nothing. I try a lot of things and fail more than that. That's how I learn. Whenever I succeed, I note that in my cookbook. Eventually, that became my blog. 

share this article.

Enjoying my articles?

Sign up to get new content delivered straight to your inbox.

Please enable JavaScript in your browser to complete this form.
Name