您如何确定媒体录制的 bitsPerSecond?

How do you determine bitsPerSecond for media recording?

是否有一些公式,例如每秒帧数 X 分辨率来确定每秒位数?我不明白我应该使用什么价值观。我想为 720p、1080p 和 4k 视频指定 bitsPerSecond。我不确定文件类型是否重要,但这很可能是 webm 或 mp4。恐怕我的某些文件过大,而另一些文件我没有使用足够的位导致视频故障。

我确实找到了这里列出的值....https://restream.io/blog/what-is-a-good-upload-speed-for-streaming/但即便如此我也不确定如何转换。

我正在使用 RecordRTC https://github.com/muaz-khan/RecordRTC,它是 MediaRecorder 的包装器。

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

我想过做这样的事情吗?但是我使用的值是太大还是太小?

var bits_per_second = 5000000;

if (current_camera_height > 2100){
  bits_per_second = 16777216
}

if (current_camera_height > 1000){
  bits_per_second = 7500000
}

您可以阅读这篇关于视频比特率的文章以了解其工作原理。 https://restream.io/blog/what-is-video-bitrate/

根据 YouTube 推荐的视频比特率 (https://support.google.com/youtube/answer/1722171?hl=en#zippy=%2Cbitrate),您可以使用

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

对于未压缩的视频,您可能会想到这一点。

BITRATE = SCREEN_SIZE_VERTICAL x SCREEN_SIZE_HORIZONTAL X FPS X PIXEL_COLOR_DEPTH
  • BITRATE:比特率表示为@bps(比特每秒)
  • SCREEN_SIZE_VERTICAL: 屏幕垂直尺寸(像素)
  • SCREEN_SIZE_HORIZONTAL: 屏幕水平尺寸(像素)
  • FPS: frames per second
  • PIXEL_COLOR_DEPTH:单个像素的color depth
720p1080p4K

Display resolutions 转换为:

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

以下信息以1080p24FPS3x8bit COLOR DEPTH为例视频。

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

最后但同样重要的是 this lovely online tool 存在,可以进行计算并查看视频压缩标准列表所需的带宽。

由于在上述结果中未提及 H.265(或 高效视频编码 - HEVC),您可以使用以下 table 作为参考点。

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