Categories: Development

How to calculate video bitrate from video size and length

Manually calculate the bitrate of a video from its file size and length. This can be done for both Megabits per second and Kilobits per second.

Bitrate is the number of bits processed per specified unit of time. The more per time means more data is being sent. For video, this means the higher the bitrate the more detail being processed during the time frame.

Bytes to Bits

Filesize is stated in Bytes whilst video is Bits. There are 8 Megabits to a Megabyte so to convert the video size into Bits you will have to multiply the size in Megabytes by 8.

You now have Megabits, to get the Megabits per second divide by the length of the video in seconds.

(size * 8) / length

This will give the bitrate reading as Megabits per second (Mbps).

As Kilobits per second

If you want the bitrate to be in Kilobits per second (Kbps) multiple this value by 1000:

((size * 8) / length) * 1000

An example

A short clip that is 12.5 Megabytes in size and 18 seconds long:

(12.5 * 8) / 18

This equals 5.55, meaning 5.55 megabits per second. To get this as kilobits per second multiple it by 1000.

Therefore the clip is 5,555.55kbps.

Share

Recent Posts

Kennington reservoir drained drone images

A drained and empty Kennington reservoir images from a drone in early July 2024. The…

2 years ago

Merrimu Reservoir drone images

Merrimu Reservoir from drone. Click images to view larger.

2 years ago

Early September spring shots

Some early September spring shots from a bushwalk, It is still too early for wildflowers.

3 years ago

Cloning an NVMe to SK Hynix Platinum P41 NVMe

I recently needed to clone over a smaller NVMe to a 2TB SK Hynix Platinum…

3 years ago

Using Laravel’s deleteDirectory to delete folders and their contents

If you ever needed a simple solution in Laravel to delete an entire directory and…

3 years ago

How to allow only 1 user to register in a Laravel application

How to enforce only one user to register or be registered in a Laravel web…

3 years ago