ExoPlayer icon indicating copy to clipboard operation
ExoPlayer copied to clipboard

Refine codec selection based on MediaFormat

Open ybai001 opened this issue 3 years ago • 1 comments

Submit this pull request for Dolby Vision team.

Since Android L, framework adds one new API to evaluate decoder with given MediaFormat. After that, android adds below format keys when evaluating decoder since Android N. MediaFormat#KEY_PROFILE MediaFormat#KEY_LEVEL

Currently, MediaCodecSelector uses MIME type to select decoder for Dolby Vision content. And this will return all decoders which are capable for both HEVC and AVC based Dolby Vision content. After that, trying to choose among these decoders that supports specific profile/level. We just wonder if we can simplify this procedure via new API, which can set a good example of codec selection(both for decoder and encoder) for other applications.

Please help to check whether this update is suitable for contribution. Feel free to let us know if you have any question. Thanks for your time in advance.

ybai001 avatar Aug 18 '22 05:08 ybai001

Hi, @christosts, Could you help to check whether this update is suitable for contribution? Feel free to let us know if you have any question. Thanks for your time in advance.

ybai001 avatar Sep 22 '22 01:09 ybai001

Thank you for sending the pull request and I apologize for the delayed response. I'll repeat a comment that I also left on the code. I think the suggested change does not fit well in the MediaCodecVideoRenderer API as it negates the existence of the MediaCodecSelector. I'm also not sure that changing the default codec selection to using MediaCodecList.findDecoderForFormat() does not risk any regressions so we try to be cautious when making such changes that apply to all apps and devices.

To support this use-case, we could change MediaCodecSelector to receive a Format argument instead of String. This way apps can inject a custom MediaCodecSelector that calls MediaCodecList.findDecoderForFormat(). That is a change that requires wider changes in ExoPlayer, and it might be more efficient if the ExoPlayer does this directly.

May I ask, what are the benefits of using MediaCodecList.findDecoderForFormat() compared to the existing implementation in ExoPlayer? To my knowledge, ExoPlayer's default logic is almost identical to what the platform does in MediaCodecList.findDecoderForFormat(). Is there something that ExoPlayer has missed?

christosts avatar Oct 13 '22 12:10 christosts

Hi, Christosts, Really appreciate your kindly feedback. I remember that you have already showed this proposal before in your email to my colleagues. It looks good to leave a chance for apps to inject a customer MediaCodecSelector. My colleagues will also keep in contact with your site about your proposal. Really thanks for your great effort.

yzhon avatar Oct 14 '22 08:10 yzhon

Dolby will discuss with Google team about this topic based on Google's suggestion directly. Close this pull request.

ybai001 avatar Oct 25 '22 08:10 ybai001