ffmpeg视频压缩/特定文件大小 [英] ffmpeg video compression / specific file size

查看:1622
本文介绍了ffmpeg视频压缩/特定文件大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我有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屋!

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