fix(player): show audio codec and bitrate in the performance overlay on ExoPlayer
The Android performance overlay showed only sample rate and channels for EAC3, FLAC, DTS, TrueHD, and Opus tracks. The overlay reads the codec from media3's Format.codecs, an RFC 6381 string only MP4/HLS provide (hence AAC working), and the bitrate from Format.bitrate, which Matroska carries only when the muxer wrote BPS statistics tags. Fall back to the already-transmitted sample MIME type for the codec name (audio and video), and measure the audio bitrate in the FFmpeg demuxer from packet sizes over their pts span — the same source mpv uses for its audio-bitrate property — when the container declares none. close #2063
This commit is contained in:
@@ -123,11 +123,29 @@ class CodecUtils {
|
||||
|
||||
/// Formats an audio codec name to a user-friendly display format.
|
||||
///
|
||||
/// Accepts both ffmpeg-style names as reported by mpv and the media
|
||||
/// servers ('aac', 'eac3') and RFC 6381 codec IDs as reported by
|
||||
/// ExoPlayer's `Format.codecs` ('mp4a.40.2', 'ec-3', 'dtsc').
|
||||
/// Accepts ffmpeg-style names as reported by mpv and the media
|
||||
/// servers ('aac', 'eac3'), RFC 6381 codec IDs as reported by
|
||||
/// ExoPlayer's `Format.codecs` ('mp4a.40.2', 'ec-3', 'dtsc'), and
|
||||
/// `audio/...` MIME types as reported by ExoPlayer's
|
||||
/// `Format.sampleMimeType` ('audio/eac3', 'audio/vnd.dts').
|
||||
static String formatAudioCodec(String codec) {
|
||||
final lower = codec.toLowerCase();
|
||||
if (lower.startsWith('audio/')) {
|
||||
return switch (lower.substring('audio/'.length)) {
|
||||
'mp4a-latm' => 'AAC',
|
||||
'mpeg' || 'mpeg-l2' => 'MP3',
|
||||
'true-hd' => 'TrueHD',
|
||||
'vnd.dts' => 'DTS',
|
||||
'vnd.dts.hd' || 'vnd.dts.hd;profile=lbr' => 'DTS-HD',
|
||||
'vnd.dts.uhd;audio=p2' => 'DTS:X',
|
||||
'ac3' => 'AC3',
|
||||
'eac3' || 'eac3-joc' => 'E-AC3',
|
||||
'ac4' => 'AC4',
|
||||
'raw' || 'wav' => 'PCM',
|
||||
'alac' => 'ALAC',
|
||||
final rest => formatAudioCodec(rest),
|
||||
};
|
||||
}
|
||||
// MP4 object types 0x69/0x6B under the mp4a prefix are MPEG layer
|
||||
// audio; every other mp4a object type in the wild is an AAC variant.
|
||||
if (lower == 'mp4a.69' || lower == 'mp4a.6b') return 'MP3';
|
||||
|
||||
Reference in New Issue
Block a user