Log in

View Full Version : How to force bitrate information to Matroska?


Anakunda
26th October 2012, 15:27
Hi, it seems that some tracks (especially those not encoded in bitrae mode) doesnot show their bitrate and size. However I think I have seen that I seen some videos having these kinds of tracks showing their bitrate and size. Where's the difference and how can I force MKVmerge to scan and store bitrate and size of all multiplexed tracks?

nhakobian
29th October 2012, 03:51
I just checked some mkv files I encoded with x264 in CRF mode and they all displayed a "bitrate" field in mediainfo.

I'm not familiar with the internal workings of the MKV format, but are you sure that this information is stored in the container? Its possible that it reads the track size and divides it by the track length to display an average bitrate.

Are you sure there isn't a problem with your files? If my above guess is true, maybe its missing timecode or duration information.

Again, these are guesses. Perhaps someone with more technical knowledge can pitch in.

Anakunda
29th October 2012, 12:37
If I add video track in non-bitrate mode (mostly CRF) or AAC track in VBR mode in M4A format, I see this file still carries the information about average and maximum bitrate but as soon as I add it to MKV the resulting file already doesnot carry these parameters, guessingly only MP4(M4A) container can contain these values but in MKV the audio track is as bare AAC, that's why I think the information is missing. Anyway I still can see some matroskas with video track in CRF format showing it's avg. bitrate thus also video track size and overall size share. The bitrate information is not shown even if I fill in FPS value on video which is no more mandatory.

fryk
29th October 2012, 13:53
According to the specs, there is no bitrate parameter in Matroska.

matroska (http://matroska.org/technical/specs/index.html)

Anakunda
29th October 2012, 14:03
The there must be other fields from which the track bitrate (and size) is calculated by MediaInfo, excerpt from mediainfo of such a bitrate capable container:

Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L3.1
Format settings, CABAC : Yes
Format settings, ReFrames : 4 frames
Codec ID : V_MPEG4/ISO/AVC
Duration : 1h 18mn
Bit rate : 3 584 Kbps
Width : 1 280 pixels
Height : 720 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 25.000 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.156
Stream size : 1.97 GiB (83%)
Writing library : x264 core 118 r2085 8a62835
Encoding settings : cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x3:0x133 / me=hex / subme=5 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=6 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=16 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=0 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=crf / mbtree=1 / crf=18.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00

fryk
29th October 2012, 14:26
This are not Matroska fields. May be in the x264 bitstream.

Try this:
mkvextract tracks Infile.mkv 0:infile.264
mkvmerge -o outfile.mkv infile.264
And the mediainfo finds the bitrate field again:

Complete name : outfile.mkv
Format : Matroska
Format version : Version 2
File size : 53.8 MiB
Duration : 1mn 2s
Overall bit rate : 7 168 Kbps[/B]
Encoded date : UTC 2012-10-29 14:12:44
Writing application : mkvmerge v5.8.0 ('No Sleep / Pillow') built on Sep 2 2012 15:37:04
Writing library : libebml v1.2.3 + libmatroska v1.3.0

Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L4.1
Format settings, CABAC : Yes
Format settings, ReFrames : 4 frames
Muxing mode : Header stripping
Codec ID : V_MPEG4/ISO/AVC
Duration : 1mn 2s
Bit rate : 7 025 Kbps
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 23.976 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.141
Stream size : 52.7 MiB (98%)
Default : Yes
Forced : No



So this can't be a matroska information.

nhakobian
29th October 2012, 18:20
Its also a possibility that it is a bug in mediainfo (or its underlying libraries). Perhaps the original file has an error in it (whether its visible or not during playback) that causes mediainfo to be unable to display this.

Just a thought. In the end, is this information really important to have?

sneaker_ger
31st October 2012, 17:57
I think MediaInfo tries to be smart. As fryk pointed out, Matroska does not provide bitrate information, so MediaInfo tries to estimate the bitrates through other means:
1.) If it is a x264 encode using --bitrate instead of --crf, x264 will write the bitrate into the custom SEI, just like the other encoding infos.
2.) If it is a video track only mkv, bitrate will probably be overall bitrate minus some overhead
3.) If it is a CRF encode or the custom SEI is missing, it tries to figure out the bitrate of the other tracks. This should work if the other tracks have a constant bitrate (typically AC3 or DTS), but does not work if it is VBR (typically AAC). It can then substract those bitrates from the overall file bitrate to get the video bitrate.

Maybe it can also easily measure the bitrate if the file at hand is small and can be analyzed fully in a short amount of time.
I don't really know the MediaInfo internals, so probably only Zenitram can tell.

fryk
23rd November 2012, 15:36
mosu told, mediainfo can only estimate the bitrate value by dividing the file or track size by length. https://www.bunkus.org/answers/?qa=716/makemkv-harddrive-after-mkvmerge-considerably-less-file-size

Anakunda
23rd November 2012, 15:43
I have managed this. MI only reports video track size and bitate if the other track is AC3 or CBR MP3 with information about bitrate. I think the "mystery" ;) is solved now. Thanks for all replies.

Zenitram
25th July 2014, 16:41
FYI, Matroska bitrates will arrive soon in MediaInfo for files having latest version of libmatroska (Mosu added bitrate metadata per stream ).