Log in

View Full Version : MKVtoolNix Bitrate change


d3crypti0n
10th January 2021, 12:15
Hello everybody,

Yesterday evening I extracted a Movie using MakeMKV and also kept the bonuses on that disc. After the extraction I usually use a tool called MKV Optimizer which uses MKVToolNix to remove all subtitles and audio tracks which are not the ones set in the condition (meaning only German and English Audio- und Subtitle tracks will be kept).

There I noticed that after the re-Mux the video bitrate was smaller. It is no way near of a big deal (it went from 4 994 kb/s to 4 993 Kb/s). I googled and found out that it was due to the Subtitles being compressed with zlib and if I understood correct they were somehow part of the video which decreased the bitrate.
Is this right so far?

But since the MKV Optimizer tool runs through every file it also changes the Bitrate of videos were no muxing needs to be done. There is one short clip which had only one Audio track and no subtitle tracks so in conclusion nothing had to be removed and nothing should have been changed. But the video bitrate changed from 4 993 Kb/s to 4 895 Kb/s. Again, this is no big deal but I still wonder why this happened. Since MKVToolNix does not re-encode I wonder why my bitrate decreased ? Can someone explain why and also if there has been a (even little) drop in quality?

Edit: Both videos used AVC and there has been no change of video length.

hello_hello
10th January 2021, 15:32
How are you determining the bitrate?

d3crypti0n
10th January 2021, 16:42
I use mediainfo GUI

poisondeathray
10th January 2021, 20:57
You can use mkvextract and compare the video stream filesize , or check the quality with metrics such as PSNR

PSNR is better to confirm , because padding and junk can get removed, headers stripped, changing the filesize slightly.

d3crypti0n
10th January 2021, 22:26
How do I check the PSNR?

poisondeathray
10th January 2021, 22:30
How do I check the PSNR?

you can use ffmpeg

https://ffmpeg.org/ffmpeg-filters.html#psnr

eg


ffmpeg -i muxed.mkv -i original.mkv -lavfi "[0:v]settb=AVTB,setpts=PTS-STARTPTS[main];[1:v]settb=AVTB,setpts=PTS-STARTPTS[ref];[main][ref]psnr" -f null -



If it's "infinity" then streams are the same. Anything else means different

The timecodes have to be the same, otherwise ffmpeg might be comparing different frames.

d3crypti0n
10th January 2021, 22:35
Sorry to ask again, what am I supposed to see or see not ?

Edit: Extracting both streams with mkvmerge to a .h264 resulted in the exact same file size according to the Windows File Explorer

d3crypti0n
10th January 2021, 22:37
Edit 2: you mean this with infinity?:

[Parsed_psnr_4 @ 0x7f93e750e700] PSNR y:inf u:inf v:inf average:inf min:inf max:inf

poisondeathray
10th January 2021, 22:38
Sorry to ask again, what am I supposed to see or see not ?

It measures the quality of a video vs. original . If result is "inf" (infinity), then it's identical. It decodes the actual video, so it's more accurate than something like filesize


Edit: Extracting both streams with mkvmerge to a .h264 resulted in the exact same file size according to the Windows File Explorer
That's probably good enough for most people, because mkvmerge does not re-encode

If you want to be 100% accurate, check with PSNR


Edit 2: you mean this with infinity?:

[Parsed_psnr_4 @ 0x7f93e750e700] PSNR y:inf u:inf v:inf average:inf min:inf max:inf

Yes. Perfect.

d3crypti0n
10th January 2021, 22:41
That's good.
Thank you for that. But still, any idea why the Bitrate changed even if there are no additional things like audio or subtitle tracks?

Also, you mentioned junk and padding, what's up with that?

poisondeathray
10th January 2021, 22:55
Mediainfo's reported bitrate isn't the actual bitrate (think about it, you demuxed it and have the exact same filesize. That means exact same bitrate if the running time is the same)

Yes mkvmerge removes things like junk stuffing bytes, empty NALU's . Look at the changelog to see what it removes from different streamtypes for different versions of mkvmerge

If you had started with a different container instead of mkv, the actual video stream can be a different filesize too, because it removes some sequence headers. But the actual decoded video data, and there fore the PSNR , will be the same

d3crypti0n
10th January 2021, 23:06
Ah Okay understood. Thank you my friend for your explanation.