How do you determine bitsPerSecond for media recording?

Viewed 1046

Is there some formula like frames per second X resolution to determine the bitsPerSecond? I can't understand what values I'm supposed to be using. I want to specify the bitsPerSecond for 720p, 1080p and 4k video. I'm not sure if file type matters but this will most likely befor webm or mp4. I'm afraid some of my files are unnecessarily large while others I'm not using enough bits causing video glitches.

I did find values listed here.... https://restream.io/blog/what-is-a-good-upload-speed-for-streaming/ But even that im not sure how to convert over.

I am using RecordRTC https://github.com/muaz-khan/RecordRTC which is a wrapper for the MediaRecorder.

recorder = RecordRTC(camera, {
       recorderType: MediaStreamRecorder,
       mimeType: encoding_options,
       bitsPerSecond: bits_per_second,
       timeSlice: 15000,
       getNativeBlob: true
   });

I thought about doing something like this? But am I using too large of values or too small?

var bits_per_second = 5000000;

if (current_camera_height > 2100){
  bits_per_second = 16777216
}

if (current_camera_height > 1000){
  bits_per_second = 7500000
}
2 Answers

You can read this article about video bitrate to understand how it works. https://restream.io/blog/what-is-video-bitrate/

According to YouTube Recommended video bitrates ( https://support.google.com/youtube/answer/1722171?hl=en#zippy=%2Cbitrate), you can use

bits_per_second = 40000000 for 4K video,
bits_per_second = 16000000 for 2K video,
bits_per_second = 8000000 for 1080p video,
bits_per_second = 5000000 for 720p video,
bits_per_second = 2500000 for 480p video,
bits_per_second = 1000000 for 360p video

You may have a this on mind for un-compressed video.

BITRATE = SCREEN_SIZE_VERTICAL x SCREEN_SIZE_HORIZONTAL X FPS X PIXEL_COLOR_DEPTH
  • BITRATE: The bitrate expressed @bps (bits per second)
  • SCREEN_SIZE_VERTICAL: The vertical size of the screen (pixels)
  • SCREEN_SIZE_HORIZONTAL: The horizontal size of the screen (pixels)
  • FPS: frames per second
  • PIXEL_COLOR_DEPTH: The color depth of a single pixel.

Display resolutions of 720p, 1080p and 4K translates to:

  • 720p: (1280 x 720)
  • 1080p: (1920 x 1080)
  • 4K: (3840 × 2160)

The following information is for an example of 1080p, 24FPS, 3x8bit COLOR DEPTH video.

Uncompressed bitrate

Megapixels: 2.1 MP (2,073,600 pixels)
Aspect ratio: 1.78:1 (HD 16:9)
1 frame of RGB 3x8bit: 6.22MB (2.1 MP x 24 bits)
Interlaced: 24 fps x 6.22MB x 50% (interlacing) = 597.2Mbps = 74.65MB/s
Progressive: 24 fps x 6.22MB = 1.19Gbps = 149.3MB/s
Longer durations: 8.96GB/min = 537.48GB/hr
Estimated compressed bitrates

HDCAM SR HQ (1080p25 @ 10bit = 880 Mbps) (compression: 1.3:1 or 76.9%):
918.76Mbps = 114.85MB/s = 6.89GB/min = 413.44GB/hr
HDCAM SR SQ (1080p25 @ 10bit = 440 Mbps) (compression: 2.7:1 or 37%):
442.37Mbps = 55.3MB/s = 3.32GB/min = 199.07GB/hr
Pure YCbCr 4:2:2 (compression: 3:1 or 33.3%):
398.13Mbps = 49.77MB/s = 2.99GB/min = 179.16GB/hr
Prores444 (1080p25 = 275 Mbps) (compression: 4.5:1 or 22.2%):
265.42Mbps = 33.18MB/s = 1.99GB/min = 119.44GB/hr
Prores422 (1080p25 = 184 Mbps) (compression: 6.7:1 or 14.9%):
178.27Mbps = 22.28MB/s = 1.34GB/min = 80.22GB/hr
REDCODE 42 Codec (compression: 7.5:1 or 13.3%):
159.25Mbps = 19.91MB/s = 1.19GB/min = 71.66GB/hr
JPEG2000 250Mbps for 2Kp24 (compression: 7.6:1 or 13.2%):
157.16Mbps = 19.64MB/s = 1.18GB/min = 70.72GB/hr
DVCPRO HD 4:2:2 Y′CbCr (1080i50 = 115 Mbps) (compression: 8.6:1 or 11.6%):
138.88Mbps = 17.36MB/s = 1.04GB/min = 62.5GB/hr
REDCODE 36 Codec (compression: 9:1 or 11.1%):
132.71Mbps = 16.59MB/s = 995.33MB/min = 59.72GB/hr
REDCODE 28 Codec (compression: 10:1 or 10%):
119.44Mbps = 14.93MB/s = 895.8MB/min = 53.75GB/hr
JPEG2000 250Mbps for 2Kp48 (compression: 15.3:1 or 6.5%):
78.06Mbps = 9.76MB/s = 585.49MB/min = 35.13GB/hr
MPEG2 High (1080p25 = 80 Mbps) (compression: 15.5:1 or 6.5%):
77.06Mbps = 9.63MB/s = 577.93MB/min = 34.68GB/hr
DVD MPEG2 (480p25 = 9.8 Mbps) (compression: 21.1:1 or 4.7%):
56.61Mbps = 7.08MB/s = 424.55MB/min = 25.47GB/hr
DVCPRO50 (1080p25 = 50 Mbps) (compression: 24.8:1 or 4%):
48.16Mbps = 6.02MB/s = 361.21MB/min = 21.67GB/hr
BluRay H.264 (1080p25 = 38 Mbps) (compression: 32.6:1 or 3.1%):
36.64Mbps = 4.58MB/s = 274.78MB/min = 16.49GB/hr

Last but not least there is this lovely online tool that exists, to do your calculations and see the bandwidth needed for a list of video compression standards.

Since H.265 (or High Efficiency Video Coding - HEVC) is not mentioned at the above results, you could use the following table as a point of reference.

Video
coding       Average bit rate reduction
standard     compared with H.264/MPEG-4 AVC HP      
----------------------------------------------  
HEVC          480p  720p    1080p   2160p
----------------------------------------------
              52%    56%     62%     64%
Related