如何正确估计mp4 H.264视频大小? [英] How to correctly estimate mp4 H.264 video size?

查看:258
本文介绍了如何正确估计mp4 H.264视频大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,视频大小是通过计算得出的:

Basically, video size is calculated:

Video Size per Second (bps)
=
Frame Rate (fps)
* Horizontal Pixels
* Vertical Pixels
* Bit Depth (bit)
/ Compression Ratio by Codec

当我在某处阅读时,mp4视频的拇指压缩比是50.因此,对于720p 24fps 24位彩色视频(暂时忽略音频大小),文件大小计算为:

As I read somewhere, the rule of thumb compression ratio of mp4 video is 50. So for a 720p 24fps 24bit color video (neglecting the audio size for now), the file size is calculated to:

24(fps) * 1280 * 720 * 24(bit) / 50
= 10616832 (bps) = 10.125 (Mbps)

如果使用上述比特率计算1小时的视频大小,则会得到:

If you calculate the video size of a 1 hour with the above bit rate, you'd get:

10.125(Mbps) * 3600(s) / 8(bit per Byte) / 1024(MB per GB)  = 4.449GB

...这似乎根本不正确.根据日常经验,我们知道,一个1小时长的720p H.264 mp4可能约为1 GB或更少.差异几乎是5倍.

... which doesn't seems right at all. From daily experience, we know that a 1 hour long 720p H.264 mp4 is probably around 1 GB or less. The difference is almost a factor of 5.

我知道此公式不包括关键帧间隔进行计算,据我了解,这很重要.我也知道这里的压缩率只是一个经验法则.可能还有一些我没有考虑的因素.问题是我不知道如何适应这些缺失的因素.

I know this formula doesn't include key-frame interval to calculation, which from I read matters a lot. I also know the compression ratio here is just a rule of thumb. There might also be factors that I didn't take into consideration. The problem is I have no idea how to fit in these missing factors.

那么,还有其他方法可以更准确地估算视频大小吗?

So, is there other way we can more accurately estimate a video size?

推荐答案

它远比您的公式复杂得多,并且更容易弄清楚.

It's far, far more complicated than your formula, and much simpler for you to figure out.

编解码器具有数百个参数和内部分支.没有说"50"的静态因素.即使您想要达到特定的质量,所需的比特率也会根据压缩的内容而有很大差异.例如,与从移动的车辆拍摄的详细动态场景相比,不移动且亮度变化很小的东西占用的带宽更少.压缩率变化很大.

The codecs have hundreds of parameters and internal branches. There isn't some static factor of say "50". Even if you wanted to target a particular quality, the required bitrate varies quite a bit based on the content that's being compressed. For example, something not moving and with little variation in brightness takes way less bandwidth than a detailed dynamic scene being shot from a moving vehicle. The compression ratio is highly variable.

您可以将编解码器配置为目标比特率.这样,您的视频流将接近该比特率.就这么简单.

You can configure your codec for a target bitrate. Your video stream will then be close to that bitrate. It's that simple.

我可以告诉H.264将1920x1080视频中的恒定比特率10 Mbps视频流作为目标,并且将尽力将其全部塞入其中.

I can tell H.264 to target a constant bitrate 10 Mbps video stream from a 1920x1080 video, and it will do its best to cram it all in there.

您提到关键帧间隔...是的,关键帧占用了视频流中的大部分带宽.因此,您希望它们尽可能合理地分开.您在此处的设置更多是关于选择权衡.您是要让流更定期地重新同步(例如在广播中支持快速的频道更改,还是在网上减少延迟),还是要节省带宽以从可靠的地方获取更高质量的视频(例如-记录的文件).您的视频仍将适合所需的比特率,但是过于频繁地插入关键帧会减少流剩余部分的可用带宽,从而降低质量.如果不确定,只需让编解码器决定在哪里插入关键帧.通用的默认设置是可以的,通常比猜测您不熟悉的设置要好.

You mentioned keyframe interval... yes, the keyframe takes up most of the bandwidth in a video stream. Therefore, you want them reasonably further apart when possible. Your setting here is more about choosing a tradeoff. Do you want your stream to re-sync more regularly (such as in broadcast to support fast channel changes, or online to reduce latency), or do you want to save the bandwidth for higher quality video from a reliable place (such as a pre-recorded file). Your video will still fit within the desired bitrate, but inserting keyframes too frequently will reduce the bandwidth available for the rest of the stream, causing lower quality. If you're unsure, just let the codec decide where to insert keyframes. The defaults are okay for general purpose, and are usually better than guessing at settings you're not familiar with.

这篇关于如何正确估计mp4 H.264视频大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆