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 和 Two-Pass 编码.
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#twopass
您使用 bitrate = target size/duration
计算目标比特率,然后启动 ffmpeg 两次:一次分析媒体,第二次执行实际编码:
You calculate your target bitrate using bitrate = target 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屋!