user3033137
user3033137

Reputation: 15

Manually calculate h264 video bitrate

I have a problem.

I'm currently trying to manually calculate the bitrate of a .mkv video I want to encode to get a specific file size so I can use that in my batch file.

Size I want the clip to be: 1900 MB -- Duration: 2587 seconds -- Audio bitrate: 1509 kbps

My current calculation is:

 1900MB*1024    seconds   1509/8       seconds
(1945600     - (2587    x 188,625) ) / 2587    = 563,44303247004252029377657518361 KBps
563,44303247004252029377657518361 * 8 = 4507,5442597603401623502126014689 kbps

I tried encoding with this bitrate, however the file size won't match 1900 MB, so I used a bitrate calculator and after putting in my settings it says for 1900 MB, the video needs a bitrate of 4647 kbps (encoded with this bitrate, and it was 1899 MB).

My question is, what did I miss in my calculation?

Upvotes: 1

Views: 3137

Answers (1)

Sean Gugler
Sean Gugler

Reputation: 779

"kilo" is 1024 for data size, but 1000 for bitrate.

  1992294400 bytes for whole file  [1900 MB * 1024 * 1024]
  -487972875 bytes for audio  [1509/8 * 1000 * 2587]
= 1504321525 bytes for video  [4652/8 * 1000 * 2587]
                video bitrate: 4652 kbps

This result more closely matches the calculator you used than your result, although I can't explain the remaining discrepancy of about 5kbps. Perhaps the calculator accounts for framing overhead or seek tables or some other metadata.

I would trust the calculator, since using its value gave you results very close to your goal.

Upvotes: 1

Related Questions