ffmpeg视频压缩/特定文件大小 [英] ffmpeg video compression / specific file size
问题描述
目前,我有80mb的电影,我想使用ffmpeg转换为10mb或15mb.我知道会有质量损失,但他们需要声音.有没有一种方法可以指定文件大小或比我以前做的更高的压缩率
Currently I have 80mb movies that I want to use ffmpeg to convert down to say about 10mb or 15mb. I know there will be a quality loss but they will need to have sound. Is there a way to either specify a file size or higher compression than what I have done previously
ffmpeg -i movie.mp4 -b 2255k -s 1280x720 movie.hd.ogv
它们目前大约每片25mb
They are currently about 25mb a piece
推荐答案
如果要确定输出文件的大小,最好的方法是使用 H.264 和两次通过编码.
if you are targeting a certain output file size the best way is to use H.264 and Two-Pass encoding.
这里有一个很好的例子,但是它太大了,无法复制粘贴: https://trac.ffmpeg.org/wiki/Encode/H.264
There is a great example here but it's too large to copy-paste: https://trac.ffmpeg.org/wiki/Encode/H.264
您使用bitrate = file size / duration
计算目标比特率,然后启动 ffmpeg 两次:一次分析媒体,第二次进行实际编码:
You calculate your target bitrate using bitrate = file size / duration
and you launch ffmpeg two times: one pass analyzes the media and the second does the actual encoding:
ffmpeg -y -i input -c:v libx264 -preset medium -b:v 555k -pass 1 -c:a libfdk_aac -b:a 128k -f mp4 /dev/null && \
ffmpeg -i input -c:v libx264 -preset medium -b:v 555k -pass 2 -c:a libfdk_aac -b:a 128k output.mp4
H.265(HEVC)在压缩方面甚至更好(在某些情况下为H.264大小的50%),但支持尚未广泛,因此暂时坚持使用H.264.
H.265 (HEVC) is even better at compression (50% of H.264 size in some cases) but support is not yet widespread so stick with H.264 for now.
这篇关于ffmpeg视频压缩/特定文件大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!