[media3-1.1.0] Codec, Bitrate and version info @ Playing audio/mpeg
Hello,
By analyzing the Track.Group format output of our media3 implementation, I recognized that not every media content contains the information about used codec and its values.
Especially the output for audio/mped files does not contain codec info and bitrate and the used codec version.
I also compared the format information to the output of the official media3 demo app while using different formats and noticed that in general there are always some format fields missing depending on played format.
Output in Player.Listener onTracksChanged (mp3 file):
Output for same file in further processing CodecConfig/CCodec:
1.) Is this known behavior, since in some cases the audio playback of "MediaCodec" is operating asynchronously? 2.) Is there any general rule/info for which media formats the bitrate can be fetched within the Tracks.Group getTrackFormat? 3.) I also saw that the debug log of media3 internal "CCodec" has at least more information about bitrate, which is not available in the getFormat/getTrackFormat containing information. Is there any way to obtain the missing information manually within the media3 framework without customization of the framework itself?
Kind regards
ExoPlayer generally only populates fields like codec and bitrate etc on Format if they're likely to be useful for track selection decisions. In the case of progressive containers, there's usually only a single track of each type (especially in an MP3 file), so there's need for ExoPlayer to populate these fields. To add some more detail to your specific questions:
1.) Is this known behavior, since in some cases the audio playback of "MediaCodec" is operating asynchronously?
This is not related to MediaCodec's operating mode. ExoPlayer populates the Format object from information it can parse from the container file (and/or playlist/manifest for adaptive content) - this happens before samples are passed to MediaCodec.
2.) Is there any general rule/info for which media formats the bitrate can be fetched within the Tracks.Group getTrackFormat?
As above, these fields are generally only populated where they might be neede for track selection decisions - so usually this is only for adaptive content (DASH and HLS)
3.) I also saw that the debug log of media3 internal "CCodec" has at least more information about bitrate, which is not available in the getFormat/getTrackFormat containing information. Is there any way to obtain the missing information manually within the media3 framework without customization of the framework itself?
ExoPlayer doesn't inspect the actual encoded media sample bytes - it unwraps the container and passes the encoded samples to a decoder (usually via MediaCodec). In the case of MP3, especially for variable bitrate files (VBR), I'm not sure there's an explicit bitrate field in the container metadata - I think each MP3 frame just has a different bitrate (so there's not really a convenient value for ExoPlayer to read).
It might help if you could outline why you need this info and what you want to do with it?
It might help if you could outline why you need this info and what you want to do with it?
It's for displaying purposes. So we want to show these values in our media app.
Hey @MrBoe. We need more information to resolve this issue but there hasn't been an update in 14 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
Sorry for the robot's comment, something meant it didn't see your reply - we're not waiting for additional info.
Hey @MrBoe. We need more information to resolve this issue but there hasn't been an update in 14 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
I have a change in review which will plumb MP3 bitrate into the Format.averageBitrate field. I'm not sure what you're referring to by 'codec' and 'version info' in the issue title.
@icbaker this was discussed also on ExoPlayer back then but there's more than just mp3 missing data.
0656b3688a78a1374cb05bb6e500fd8b7bd2419d.patch
Now using ffmpeg to get the data, but flac bitrate and bit per sample, alac bitrate would be nice too. Was using the rough patch attached before.
I have a change in review which will plumb MP3 bitrate into the
Format.averageBitratefield. I'm not sure what you're referring to by 'codec' and 'version info' in the issue title.
Thank you for caring! For the Mp3Extractor it's for sure a good thing to have this info available . But our request is more kind of having general information of the used codec, container format and the bitrate, as much as it is possible regardless of the used extractor.
At the current state of the project we also aren't using the external decoders like ffmpeg. So it would be appreciated to have the Format fields available for the internal decoder.
Thx in advance
Each piece of data needs to be parsed from each container, so there isn't really a 'high-level' way to automatically provide the information you're asking for from every container.
So it would be appreciated to have the Format fields available for the internal decoder.
To clarify something here: Format is created during extraction, before any samples have been decoded, so nothing in it can be determined by the decoder implementation. The decoder used for a particular playback can be determined by listening to:
I'm going to close this issue, because the title and original comment are specifically about MP3 and that case is now handled by the commits linked above. If you have specific other similar combinations of data + container then I'd encourage you to file new issue(s), so each can be reasonably scoped. You may also want to consider sending PRs for the data you're interested in.