如何计算ffmpeg输出文件大小?
我正在使用 ffmpeg 将家庭视频转换为 DVD 格式,并希望在转换之前计算输出文件的大小。
我的输入文件的比特率为 7700 kbps,长度为 114 秒。音频比特率为 256 kbit(每秒?) 输入文件为 77MB。为了获取此信息,我运行了:
mplayer -vo null -ao null -frames 0 -identify input.MOD
因此,理论上,输入文件的文件大小(大致)应为:
((7700 / 8) * 114) / 1024
即(7700 / 8) 为千字节/秒,乘以114秒,然后换算为兆字节。这给了我 107MB,这远远超出了我的 77MB。因此我对他的公式持怀疑态度。
也就是说,在转换视频后:
ffmpeg -i input.MOD -y -target ntsc-dvd -sameq -aspect 4:3 output.mpg
这些数字似乎更有意义。比特率是 9000 kbps,应用上面的公式,我得到 125MB,我的实际输出文件大小是 126MB。
那么,有两个问题:
如何将音频比特率纳入此计算?它是累加的(视频文件大小 + 音频文件大小)吗?
DVD 的速率总是 9000 千比特/秒吗?这就是DVD的定义吗?或者这可能会根据我输入视频的视频质量而改变? “-target ntsc-dvd”对我的视频有何保证?
为什么我的输入文件与计算不“匹配”,但输出文件却“匹配”?是否还有其他我没有考虑到的变量?
计算文件大小的正确方法是什么?
I am using ffmpeg to convert home videos to DVD format and want to calculate the output file size before doing the conversion.
My input file has a bit rate of 7700 kbps and is 114 seconds long. The audio bitrate is 256 kbit (per second?) The input file is 77MB. To get this information I ran:
mplayer -vo null -ao null -frames 0 -identify input.MOD
So in theory, the input file should have (roughly) a file size of:
((7700 / 8) * 114) / 1024
That is, (7700 / 8) is kilobytes/second, multiplied by 114 seconds, and then converted to megabytes. This gives me 107MB, which is way beyond my 77. Thus I am skeptical of his formula.
That said, after converting the video:
ffmpeg -i input.MOD -y -target ntsc-dvd -sameq -aspect 4:3 output.mpg
The numbers seem to make more sense. Bitrate is 9000 kbps, and applying the above formula, I get 125MB, and my actual output file size is 126MB.
So, two questions:
How do I factor the audio bitrate into this calculation? Is it additive (video file size + audio file size)?
Do DVDs always have a 9000 kilobit/second rate? Is that the definition of a DVD? Or might that change depending on video quality of my input video? What does "-target ntsc-dvd" guarantee about my video?
Why does my input file not "match" the calculation, but the output file does? Is there some other variable I'm not accounting for?
What is the correct way to calculate filesize?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须记住的是,需要考虑几种不同的比特率测量:
平均(目标)比特率 - 使用公式精确计算的比特率< /p>
速率控制(编码器对视频复杂性变化的反应速度)
有损视频编码有效通过消除人眼难以看到的特征。这意味着慢动作、说话的头像可以比旋转的全屏缩放/全景进一步压缩。
为什么这很重要?标准确实指定了“最大”比特率是有原因的 - 这是播放器读取和解码符合标准的视频所需的速度。 DVD 的速度约为 9000kbps。
最后,由于它是一种有损压缩,因此可以指定平均比特率。如果您需要将内容容纳在有限的空间或带宽中(可能允许缓冲更密集的片段),则可以使用此方法。
例如,您可以拥有最大比特率为 7000kbps、平均比特率为 5500kbps 的视频。最后,速率控制是用于决定编码器应分配给不同片段多少“空间”的算法。如果您进行多通道编码,您将重用之前通道中的信息 - 提高质量和比特率分布。
What you have to keep in mind, is that there are few different bitrate measurements to consider:
average (target) bitrate - the bitrate calculated precisely using your formula
rate control (how quickly encoder reacts to changes in complexity of the video)
Lossy video encoding works by eliminating features that are hard for human eye to see. This means, that a slow motion, a talking head, can be compressed further than a spinning full-screen zoom/panorama.
Why does it matter? Standards do specify a 'maximum' bitrate for a reason - this is how fast player needs to be in order to read and decode a standards-compliant video. DVD has it around 9000kbps.
Finally, since it's a lossy compression, one can specify the average bitrate. This is used if you need to fit the content in limited space or bandwidth (possibly permitting buffering for the more intense fragments).
For instance, you can have a video with maximum bitrate of 7000kbps and the average bitrate of 5500kbps. Finally, rate control, is the algorithm used to decide how much 'space' encoder should assign to different fragments. If you do multi-pass encoding, you are reusing this information from previous passes - improving the quality and bitrate distribution.