如何计算ffmpeg输出文件的大小? [英] How to calculate ffmpeg output file size?

查看:818
本文介绍了如何计算ffmpeg输出文件的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ffmpeg将家庭视频转换为DVD格式,并希望在进行转换之前计算输出文件的大小.

I am using ffmpeg to convert home videos to DVD format and want to calculate the output file size before doing the conversion.

我的输入文件的比特率为7700 kbps,长度为114秒.音频比特率为256 kbit(每秒?).输入文件为77MB.要获取此信息,我运行了:

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

((7700 / 8) * 114) / 1024

也就是说,(7700/8)是千字节/秒,乘以114秒,然后转换为兆字节.这给了我107 MB的内存,远远超过了我的77 MB.因此,我对他的公式表示怀疑.

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

数字似乎更有意义.比特率是9000 kbps,使用上面的公式,我得到125MB,而我的实际输出文件大小是126MB.

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.

因此,有两个问题:

  1. 如何在计算中考虑音频比特率?它是加性的(视频文件大小+音频文件大小)吗?

  1. How do I factor the audio bitrate into this calculation? Is it additive (video file size + audio file size)?

DVD是否始终具有9000 kb/s的速率?那是DVD的定义吗?还是可能会根据我输入视频的视频质量而改变? "-target ntsc-dvd"对我的视频有什么保证?

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?

推荐答案

您要记住的是,要考虑的几种比特率测量方法很少:

What you have to keep in mind, is that there are few different bitrate measurements to consider:

  • 最大比特率-视频中最需要操作的片段的比特率
  • 平均(目标)比特率-使用您的公式精确计算出的比特率

  • maximum bitrate - the bitrate of the most action intensive fragment of the video
  • 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.

为什么重要?标准确实会指定最大"比特率,这是有原因的-这是播放器读取和解码符合标准的视频所需的速度. DVD大约有9000kbps.

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).

例如,您可以拥有最大比特率7000kbps和平均比特率5500kbps的视频.最后,速率控制是用于确定应将多少空间"编码器分配给不同片段的算法.如果您进行多遍编码,那么您将重复使用先前遍中的信息,从而改善质量和比特率分布.

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.

这篇关于如何计算ffmpeg输出文件的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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