Share this
Decoding the decoders: THEOplayer Android SDK decoder selection extension
by Daniel Dallos on July 20, 2023
Today, most streaming services are supporting more than 10 platforms with close to the same number of apps in different stores. Supporting all these platforms is a hygiene factor. It just has to work. Large streaming providers such as Netflix, Youtube, Peacock and Twitch are setting the requirements, making viewers used to access content on all platforms.
However, supporting all these platforms can be hard, definitely for streaming services facing Android device fragmentation, a common challenge amongst media companies streaming into different countries/regions.
In this article we’ll cover:
- Challenges with Android device fragmentation.
- Detection of a faulty media decoder.
- The THEOplayer Android SDK decoder selection extension, which makes it easy to select the right decoders, without having to republish your app.
Android (media codec) fragmentation
When you enjoy watching videos, listening to music, or streaming content on your Android device, have you ever wondered how all these multimedia files are decoded and played? That’s where media decoders come into play.
Media decoders are essential components responsible for decoding compressed media files, such as videos and audio (e.g., encoded in formats like H.264, AAC, or MP3), into formats that can be displayed or played by your Android device. There are different types of media decoders, including hardware-based, software-based, and hybrid decoders, each with their own advantages and characteristics, depending on the capabilities of the device.
Due to the open-source nature of Android, manufacturers are free to choose their hardware and software components when they build their Android devices. This causes fragmentation in the Android ecosystem which means it is really hard to develop a one size fits all solution (unlike in the Apple ecosystem).
As the media playback components (hardware and software) can vary from device to device a playback pipeline has to take into account the possible differences and limitations.
THEOplayer Android SDK
The new THEOplayer Android SDK (5.x) was built from the ground up using fully native, low-level Android APIs to provide fine-grained control over the media playback experience.
This means the player will encounter the above-mentioned media decoder and playback differences firsthand.
THEOplayer has a built-in continuously improving decoder selection logic which handles most of the use cases, but sometimes the player cannot be aware of the exact capabilities or defects of a certain decoder.
This issue is not specific to THEOplayer. Any video player that does media playback via low-level APIs runs into similar issues.
How can you detect a faulty decoder?
- The application is crashing with some weird decoder-related error logs.
- Users are reporting strange playback behavior on their devices, for example:
- Audio is playing, but they don’t see any video
- The video playback is stuttering
- There are some weird artifacts on the video (green pixels, blurred image)
The Decoder Selection extension
It’s very difficult to compile a definitive list of the ever-growing Android device/decoder combinations worldwide.
That’s why with THEOplayer Android SDK 5.x introduced a decoder selection helper API on THEOplayerGlobal.getSharedInstance(this).getPlaybackSettings().setDecoderSelectionHelper(...)
This API lets you define your DecoderSelectionHelper class to help the player’s decoder selection algorithm.
class MyDecoderSelectionHelper extends DecoderSelectionHelper {
@Override
public boolean shouldUseDecoder(DecoderType decoderType, String decoderName, MediaCodecInfo codecInfo) {
return super.shouldUseDecoder(decoderType, decoderName, codecInfo);
}
@Override
public boolean shouldApplySecureExtensionWorkaround(DecoderType decoderType, String decoderName, MediaCodecInfo codecInfo) {
return super.shouldApplySecureExtensionWorkaround(decoderType, decoderName, codecInfo);
}
@Override
public boolean shouldOverrideBuiltInDecoderSelectionLogic() {
return super.shouldOverrideBuiltInDecoderSelectionLogic();
}
}
When the player picks the decoder for the current source, it will iterate over the decoders available on the device and selects the first one that satisfies the needs. If a DecoderSelectorHelper is defined, it will call into the relevant methods before selecting the final media decoder.
Let’s look at the provided API in detail.
1. shouldUseDecoder
This is the one that you will use in most of the cases.
If you notice that there are playback issues with the selected decoder (see “How can we detect a faulty decoder?” section) , here you can “blacklist” it and return false inside the method.
NOTE: Be aware this code will run on all of your customer’s devices. Be as specific as possible when blacklisting a decoder! The same decoder can be available on another device (from another manufacturer) too and there it could work without any problem.
For example:
@Override
public boolean shouldUseDecoder(DecoderType decoderType, String decoderName, MediaCodecInfo codecInfo) {
// TCL Smart TV (32S5201X2)
if ("OMX.MS.AVC.Decoder".equals(decoderName) && "C06".equals(Build.DEVICE) && "TCL".equals(Build.MANUFACTURER)) {
return false;
}
return super.shouldUseDecoder(decoderType, decoderName, codecInfo);
}
This snippet will blacklist the OMX.MS.AVC.Decoder decoder only on a TCL Smart TV that has the C06 identifier.
Don’t forget to call the super method to keep the support as is for the other devices.
2. shouldApplySecureExtensionWorkaround
The secure decoder is primarily focused on decoding content that is encrypted or protected by digital rights management (DRM) technologies. It ensures that the content remains secure during the decoding process and prevents unauthorized access or tampering.
In most cases, this works fine, but sometimes the player could apply a workaround on the decoder to avoid playback issues (e.g. rendering glitches).
The idea is the same as with the shouldUseDecoder
method, only use it when it is really needed.
Don’t forget to call the super
method to keep the support as is for the other devices.
3. shouldOverrideBuiltInDecoderSelectionLogic
THEOplayer has a built-in decoder selection logic, and that is used by default. If a decoder falls through those internal checks, the DecoderSelectionHelper
will be used.
If you return true
in this method, the default decoder selection logic will be skipped and only the DecoderSelectionHelper
will be used.
NOTE: You should not use this method! We just show it for completeness. This is a preparation for a later iteration of the feature. You should use this method only if you have an extensive blacklist of decoders (covering THEOplayer’s internal list too), otherwise, you can break playback on some devices.
How do you know which decoder to blacklist?
After you gathered device logs from a customer or crash reports from an analytics backend, you should look for a log line like this with a tag THEO_VideoDecoder:
THEO_VideoDecoder, Decoder created successfully with name: OMX.MS.AVC.Decoder security: true, Mime: video/mp4
This means THEOplayer selected OMX.MS.AVC.Decoder
decoder for the playback of the selected stream. (And probably it is buggy, that’s why you see the issues).
The device details are logged with the tag THEO_DeviceInfo
:
THEO_DeviceInfo, Device Information
os.version: 4.14.302-g1c5bb331fccc-ab9989803
VERSION.SDK_INT (API level): 33
DEVICE: sunfish
MODEL: Pixel 4a
PRODUCT: sunfish
VERSION.RELEASE : 13
VERSION.INCREMENTAL : 10161073
BOARD : sunfish
BOOTLOADER : s5-0.5-9825683
BRAND : google
SUPPORTED_ABIS : [arm64-v8a, armeabi-v7a, armeabi]
DISPLAY : TQ3A.230605.011
FINGERPRINT : google/sunfish/sunfish:13/TQ3A.230605.011/10161073:user/release-keys
HARDWARE : sunfish
HOST : abfarm-release-2004-0126
ID : TQ3A.230605.011
MANUFACTURER : Google
TAGS : release-keys
TIME : 1684427704000
TYPE : user
UNKNOWN : unknown
USER : android-build
With the two information above you should be able to fabricate a device-specific exclusion list in your DecoderSelectionHelper class.
Community-based decoder selection extension
You can always build your own DecoderSelectionHelper
, but wouldn’t be better if someone does it for you?
The THEOplayer Android SDK includes an always-evolving algorithm for decoder selection. However, it can only cover devices that the developers have access to and can test.
We started an open-source initiative where we curate a blacklist of device and decoder combinations based on your feedback and contribution.
The idea behind this crowdsourced list is to help everyone to achieve smooth playback on as many devices as possible without suffering from the same problems over and over again.
To know more about this project, please visit the GitHub page: https://github.com/THEOplayer/android-decoder-selector
Dynamic decoder selection
One of the hidden advantages of opening up an internal SDK logic through a public API is on-the-fly adaptability.
Mobile applications nowadays talk to a backend system every time. Getting the data to show to the user, sending analytics to calculate better metrics and drive business decisions, detecting crashes, and so on…
If there is a playback crash reported by the application, or video rendering glitches reported by the users, it is important to address these issues in a timely manner. Failure to do so can result in a negative user experience and potentially lead to loss of customers.
By maintaining an always up-to-date decoder selection blacklist on your backend or using Firebase Remote Config that you sync with every device at application start you can ensure your users that the same crash is not happening again.
“In this case, you don’t have to wait for a new release of a decoder selection helper module, a new release of THEOpalyer and a new release of your application. The decoder selection fixes can be applied as soon as the app is restarted and the new list is fetched from the backend.”
Daniel Dallos
Mobile Chapter Lead
With Firebase Remote Config you can even target the user who only encountered a crash and send them a new decoder selection configuration. (Stay tuned for a comprehensive guide on this topic !)
Do you need any help?
Visit our developer hub, and in particular our FAQ, or contact us to learn more about Android device fragmentation, and the decoder selection extension.
Share this
- THEOplayer (45)
- online streaming (40)
- live streaming (35)
- low latency (32)
- video streaming (32)
- HESP (24)
- HLS (21)
- new features (21)
- THEO Technologies (20)
- SDK (19)
- THEOlive (17)
- best video player (17)
- html5 player (16)
- LL-HLS (15)
- cross-platform (15)
- online video (15)
- SmartTV (12)
- delivering content (12)
- MPEG-DASH (11)
- Tizen (11)
- latency (11)
- partnership (11)
- Samsung (10)
- awards (10)
- content monetisation (10)
- innovation (10)
- Big Screen (9)
- CDN (9)
- High Efficiency Streaming Protocol (9)
- fast zapping (9)
- video codec (9)
- SSAI (8)
- Ultra Low Latency (8)
- WebOS (8)
- advertising (8)
- viewers expercience (8)
- "content delivery" (7)
- Adobe flash (7)
- LG (7)
- Online Advertising (7)
- Streaming Media Readers' Choice Awards (7)
- html5 (7)
- low bandwidth (7)
- Apple (6)
- CMAF (6)
- Efficiency (6)
- Events (6)
- drm (6)
- interactive video (6)
- sports streaming (6)
- video content (6)
- viewer experience (6)
- ABR (5)
- Bandwidth Usage (5)
- Deloitte (5)
- HTTP (5)
- ad revenue (5)
- adaptive bitrate (5)
- nomination (5)
- reduce buffering (5)
- release (5)
- roku (5)
- sports betting (5)
- video monetization (5)
- AV1 (4)
- DVR (4)
- Encoding (4)
- THEO Technologies Partner Success Team (4)
- Update (4)
- case study (4)
- client-side ad insertion (4)
- content encryption (4)
- content protection (4)
- fast 50 (4)
- google (4)
- monetization (4)
- nab show (4)
- streaming media west (4)
- support matrix (4)
- AES-128 (3)
- Chrome (3)
- Cost Efficient (3)
- H.265 (3)
- HESP Alliance (3)
- HEVC (3)
- IBC (3)
- IBC trade show (3)
- THEOplayer Partner Success Team (3)
- VMAP (3)
- VOD (3)
- Year Award (3)
- content integration (3)
- customer case (3)
- customise feature (3)
- dynamic ad insertion (3)
- scalable (3)
- server-side ad insertion (3)
- video (3)
- video trends (3)
- webRTC (3)
- "network api" (2)
- Amino Technologies (2)
- Android TV (2)
- CSI Awards (2)
- Encryption (2)
- FireTV (2)
- H.264 (2)
- LHLS (2)
- LL-DASH (2)
- MPEG (2)
- Microsoft Silverlight (2)
- NAB (2)
- OMID (2)
- Press Release (2)
- React Native SDK (2)
- Start-Up Times (2)
- UI (2)
- VAST (2)
- VP9 (2)
- VPAID (2)
- VPAID2.0 (2)
- ad block detection (2)
- ad blocking (2)
- adobe (2)
- ads in HTML5 (2)
- analytics (2)
- android (2)
- captions (2)
- chromecast (2)
- chromecast support (2)
- clipping (2)
- closed captions (2)
- deloitte rising star (2)
- fast500 (2)
- frame accurate clipping (2)
- frame accurate seeking (2)
- metadata (2)
- multiple audio (2)
- playback speed (2)
- plugin-free (2)
- pricing (2)
- seamless transition (2)
- server-side ad replacement (2)
- subtitles (2)
- video publishers (2)
- viewer engagement (2)
- wowza (2)
- "smooth playback" (1)
- 360 Video (1)
- AOM (1)
- API (1)
- BVE (1)
- Best of Show (1)
- CEA-608 (1)
- CEA-708 (1)
- CORS (1)
- DIY (1)
- Edge (1)
- FCC (1)
- HLS stream (1)
- Hudl (1)
- LCEVC (1)
- Microsoft Azure Media Services (1)
- Monoscopic (1)
- NAB Show 2016 (1)
- NPM (1)
- NetOn.Live (1)
- OTT (1)
- Periscope (1)
- React Native (1)
- Real-time (1)
- SGAI (1)
- SIMID (1)
- Scale Up of the Year award (1)
- Seeking (1)
- Stereoscopic (1)
- Swisscom (1)
- TVB Europe (1)
- Tech Startup Day (1)
- Telenet (1)
- Uncategorized (1)
- University of Manitoba (1)
- User Interface (1)
- VR (1)
- VR180 (1)
- Vivaldi support (1)
- Vualto (1)
- adblock detection (1)
- apple tv (1)
- audio (1)
- autoplay (1)
- cloud (1)
- company news (1)
- facebook html5 (1)
- faster ABR (1)
- fmp4 (1)
- hiring (1)
- iGameMedia (1)
- iOS (1)
- iOS SDK (1)
- iPadOS (1)
- id3 (1)
- language localisation (1)
- micro moments (1)
- mobile ad (1)
- nagasoft (1)
- new web browser (1)
- offline playback (1)
- preloading (1)
- program-date-time (1)
- server-guided ad insertion (1)
- stream problems (1)
- streaming media east (1)
- support organization (1)
- thumbnails (1)
- use case (1)
- video clipping (1)
- video recording (1)
- video trends in 2016 (1)
- visibility (1)
- vulnerabilities (1)
- zero-day exploit (1)
- August 2024 (1)
- July 2024 (1)
- January 2024 (1)
- December 2023 (2)
- September 2023 (1)
- July 2023 (2)
- June 2023 (1)
- April 2023 (4)
- March 2023 (2)
- December 2022 (1)
- September 2022 (4)
- July 2022 (2)
- June 2022 (3)
- April 2022 (3)
- March 2022 (1)
- February 2022 (1)
- January 2022 (1)
- November 2021 (1)
- October 2021 (3)
- September 2021 (3)
- August 2021 (1)
- July 2021 (1)
- June 2021 (1)
- May 2021 (8)
- April 2021 (4)
- March 2021 (6)
- February 2021 (10)
- January 2021 (4)
- December 2020 (1)
- November 2020 (1)
- October 2020 (1)
- September 2020 (3)
- August 2020 (1)
- July 2020 (3)
- June 2020 (3)
- May 2020 (1)
- April 2020 (3)
- March 2020 (4)
- February 2020 (1)
- January 2020 (3)
- December 2019 (4)
- November 2019 (4)
- October 2019 (1)
- September 2019 (4)
- August 2019 (2)
- June 2019 (1)
- December 2018 (1)
- November 2018 (3)
- October 2018 (1)
- August 2018 (4)
- July 2018 (2)
- June 2018 (2)
- April 2018 (1)
- March 2018 (3)
- February 2018 (2)
- January 2018 (2)
- December 2017 (1)
- November 2017 (1)
- October 2017 (1)
- September 2017 (2)
- August 2017 (3)
- May 2017 (3)
- April 2017 (1)
- March 2017 (1)
- February 2017 (1)
- December 2016 (1)
- November 2016 (3)
- October 2016 (2)
- September 2016 (4)
- August 2016 (3)
- July 2016 (1)
- May 2016 (2)
- April 2016 (4)
- March 2016 (2)
- February 2016 (4)
- January 2016 (2)
- December 2015 (1)
- November 2015 (2)
- October 2015 (5)
- August 2015 (3)
- July 2015 (1)
- May 2015 (1)
- March 2015 (2)
- January 2015 (2)
- September 2014 (1)
- August 2014 (1)