How to calculate average variable video bitrate? Create MKV without re-encoding?

HandBrake for Windows support
Forum rules
An Activity Log is required for support requests. Please read How-to get an activity log? for details on how and why this should be provided.
Post Reply
pstein
Posts: 13
Joined: Wed Apr 29, 2009 11:09 am

How to calculate average variable video bitrate? Create MKV without re-encoding?

Post by pstein »

Assume I have already a *.MKV video with a variable video bitrate.

Now I want to find out the average video bitrate.

Since it is a variable bitrate popular codec/media information tools like MedieInfo do not show it.

So I could imagine that specialized MKV tools like Handbrake are able to calculate them.

Is this possible? how?

Mkvtoolnix offer a command to add statistic tags with

mkvpropedit --add-track-statistics-tags <file>

However this seems to be only possible at creation time and not afterwards :-(

My Idea is now to open an existing *.mkv video file in Handbrake then set video+audio to NO re-encoding/just copy and let Handbrake
create a new, second MKV video file WITH average variable video bitrate statistic tag.

Is this possible?

Peter
rollin_eng
Veteran User
Posts: 4840
Joined: Wed May 04, 2011 11:06 pm

Re: How to calculate average variable video bitrate? Create MKV without re-encoding?

Post by rollin_eng »

No it’s not possible with HB, you have to reencode the video with HB.
Spaarpott
Posts: 3
Joined: Fri Nov 11, 2022 3:03 pm

Re: How to calculate average variable video bitrate? Create MKV without re-encoding?

Post by Spaarpott »

I was reading this thread, because my output files with 2-Pass Avg Bitrate encoding, did not show any bitrates in MediaInfo, which I find annoying.
I got it working in Handbrake. The adding of the statistics happens in mere seconds, depending on the size of the file. After each encode completes, a command window opens briefly in which mkvpropedit updates the statistics of the just finished file. In MediaInfo the output file shows the audio and video bitrate.

It currently works in Handbrake (tested in v1.5.1) by enabling post encoding in mkvpropedit, which is part of mkvtoolnix.
Set it in Preferences in the tab "When Done" under "Encode Completed"
Link the "send file to:" to your mkvpropedit location, and fill in the arguments line: {destination} --add-track-statistics-tags

Here is a screenshot of how it's working.
https://user-images.githubusercontent.c ... 96fef6.png
Last edited by HandBrake on Fri Nov 11, 2022 8:39 pm, edited 1 time in total.
Reason: Removed img tags. Remote images are not supported.
pstein
Posts: 13
Joined: Wed Apr 29, 2009 11:09 am

Re: How to calculate average variable video bitrate? Create MKV without re-encoding?

Post by pstein »

Interesting.
Can I calculate and add this statistic to a given MKV video file WITHOUT re-encoding it?
Spaarpott
Posts: 3
Joined: Fri Nov 11, 2022 3:03 pm

Re: How to calculate average variable video bitrate? Create MKV without re-encoding?

Post by Spaarpott »

Yep. Mkvpropedit just adds the statistics without re-encoding.
You can use mkvpropedit on any .mkv file.
Open a command window or .bat script in the same folder as mkvpropedit.
Example: Use the command:

Code: Select all

mkvpropedit "Q:\Folder\Folder\File1.mkv" --add-track-statistics-tags
In the .bat script you can use multiple lines and do a whole folder.

Code: Select all

mkvpropedit "Q:\Folder\Folder\File1.mkv" --add-track-statistics-tags
mkvpropedit "Q:\Folder\Folder\File2.mkv" --add-track-statistics-tags
mkvpropedit "Q:\Folder\Folder\File#.mkv" --add-track-statistics-tags
Excel File
I personally have made a Excel File in which I can past the file names from Explorer.
Select the files in Explorer and push the "Copy Path" button.
Paste the names in Cel A6 and below.
Put a " in cel D1.
Use in Cel B6 the formula ="mkvpropedit "&$D$1&A6&$D$1&" --add-track-statistics-tags"
You can then copy the formula to below.
If you copy the output in column B to a .bat file, it does them all in one window.
pstein
Posts: 13
Joined: Wed Apr 29, 2009 11:09 am

Re: How to calculate average variable video bitrate? Create MKV without re-encoding?

Post by pstein »

@Spaarpott:

works
thank you.

One should mention, that the original video file will be replaced without creating a backup
Deleted User 11865

Re: How to calculate average variable video bitrate? Create MKV without re-encoding?

Post by Deleted User 11865 »

You could argue it appends to the file rather than replacing it altogether, although I suppose there's indeed always the risk of breaking the index :-)
Spaarpott
Posts: 3
Joined: Fri Nov 11, 2022 3:03 pm

Re: How to calculate average variable video bitrate? Create MKV without re-encoding?

Post by Spaarpott »

Rodeo wrote: Sat Nov 12, 2022 10:38 am You could argue it appends to the file rather than replacing it altogether, although I suppose there's indeed always the risk of breaking the index :-)
Never had it happen and I am using this for a while.
Post Reply