MediaArea / MediaInfo

Convenient unified display of the most relevant technical and tag data for video and audio files.
https://MediaArea.net/MediaInfo
BSD 2-Clause "Simplified" License
1.33k stars 161 forks source link

Incorrect stream info reported for Opus audio #540

Open Sohex opened 3 years ago

Sohex commented 3 years ago

Mediainfo is reporting the stream size and bit rate as that of the PCM source, not the encoded Opus audio. Audio was encoded with the ffmpeg flags -c:a libopus -b:a 128000. For example:

$ mediainfo source.mkv 
General
Unique ID                                : 139462965663304931617278727151797026870 (0x68EB9715684A705C5B3F802080024036)
Complete name                            : source.mkv
Format                                   : Matroska
Format version                           : Version 4
File size                                : 1.24 GiB
Duration                                 : 24 min 36 s
Overall bit rate mode                    : Variable
Overall bit rate                         : 7 189 kb/s
Encoded date                             : UTC 2021-04-30 22:08:06
Writing application                      : mkvmerge v49.0.0 ('Sick Of Losing Soulmates') 64-bit
Writing library                          : libebml v1.4.0 + libmatroska v1.6.2

...

Audio
ID                                       : 2
ID in the original source medium         : 189 (0xBD)160 (0xA0)
Format                                   : PCM
Format settings                          : Little / Signed
Codec ID                                 : A_PCM/INT/LIT
Duration                                 : 24 min 36 s
Bit rate mode                            : Constant
Bit rate                                 : 1 536 kb/s
Channel(s)                               : 2 channels
Sampling rate                            : 48.0 kHz
Frame rate                               : 30.000 FPS (1600 SPF)
Bit depth                                : 16 bits
Stream size                              : 270 MiB (21%)
Title                                    : Stereo
Language                                 : Japanese
Default                                  : Yes
Forced                                   : No
Original source medium                   : DVD-Video
$mediainfo encoded.mkv 
General
Unique ID                                : 200637366892329362186608958064629495742 (0x96F159EDE2AF8E71CB8C0F5C5B41B7BE)
Complete name                            : encoded.mkv
Format                                   : Matroska
Format version                           : Version 4
File size                                : 92.0 MiB
Duration                                 : 24 min 36 s
Overall bit rate                         : 523 kb/s
Writing application                      : Lavf58.78.100
Writing library                          : Lavf58.78.100
ErrorDetectionType                       : Per level 1

...

Audio
ID                                       : 2
ID in the original source medium         : 189 (0xBD)160 (0xA0)
Format                                   : Opus
Codec ID                                 : A_OPUS
Duration                                 : 24 min 36 s
Bit rate                                 : 1 536 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 30.000 FPS (1600 SPF)
Bit depth                                : 16 bits
Compression mode                         : Lossy
Delay relative to video                  : -7 ms
Stream size                              : 270 MiB
Title                                    : Stereo
Writing library                          : Lavc58.136.101 libopus
Language                                 : Japanese
Default                                  : Yes
Forced                                   : No
Original source medium                   : DVD-Video
mediainfo audio.ogg
General
Complete name                            : audio.ogg
Format                                   : Ogg
File size                                : 22.3 MiB
Duration                                 : 24 min 36 s
Overall bit rate                         : 127 kb/s
Track name                               : Stereo
Writing application                      : Lavc58.136.101 libopus
BPS-eng                                  : 1536000
DURATION-eng                             : 00:24:36.000000000
NUMBER_OF_FRAMES-eng                     : 44280
NUMBER_OF_BYTES-eng                      : 283392000
SOURCE_ID-eng                            : 01A0BD
_STATISTICS_WRITING_APP-eng              : mkvmerge v49.0.0 ('Sick Of Losing Soulmates') 64-bit
_STATISTICS_WRITING_DATE_UTC-eng         : 2021-04-30 22:08:06
_STATISTICS_TAGS-eng                     : BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES SOURCE_ID
DURATION                                 : 00:24:36.007000000

Audio
ID                                       : 2998495890 (0xB2B96A92)
Format                                   : Opus
Duration                                 : 24 min 36 s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Compression mode                         : Lossy
Writing library                          : Lavf58.78.100
Language                                 : Japanese
jessielw commented 2 years ago

I noticed this today. Having the exact same issues. It seems to adopt the source bitrate Metadata even though it's encoded to a different bitrate. I plan to do more tonight to see if this is the fault of mediainfo, mkvmerge, or ffmpeg for sure.

jessielw commented 2 years ago

Nvm solution was -map_metadata:s:a -1

cjee21 commented 5 days ago

This is a known behaviour of FFmpeg. It does not calculate and write statistics tags for MKV family of files but will copy the tags as is if they are present in the original file even after re-encoding. User has to manually remove the tags when re-encoding from a file that has them.