我常用的ffmpeg命令集锦
时间: 2019-09-25来源:OSCHINA
前景提要
「深度学习福利」大神带你进阶工程师,立即查看>>>
保存我常用的ffmpeg命令.
都是从各处收集来的.除了常规操作,还有一些特殊的优化.
教程
官方文档
一个教程
一个转码的教程
基本操作
考虑到基于h264的mp4兼容性最好,例子中都用h264编码器吧. # 用h264编码器,参数默认 ffmpeg -i 输入视频 -vcodec h264 输出视频 # 用不同的预设参数(从快到慢有ultrafast、superfast、veryfast、faster、fast、medium、slow、slower、veryslow、placebo),指定码率 ffmpeg -i 输入视频 -vcodec h264 -preset ultrafast -b:v 2000k 输出视频
Gif转mp4
来源 ffmpeg -i animated.gif -movflags faststart -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" video.mp4
解释: movflags – This option optimizes the structure of the MP4 file so the browser can load it as quickly as possible. pix_fmt – MP4 videos store pixels in different formats. We include this option to specify a specific format which has maximum compatibility across all browsers. vf – MP4 videos using H.264 need to have a dimensions that are divisible by 2. This option ensures that’s the case.
flv转mp4
来源 # 重新编码式 ffmpeg -i input.flv -c:v libx264 -crf 19 -strict experimental output.mp4 # 直接输出式 ffmpeg -i input.flv -codec copy output.mp4
解释: You must specify the video codec used. In your command you don't specify -vcodec or -c:v so ffmpeg uses the default codec for MP4 (mpeg4) which doesn't have very good compression efficiency. Try using libx264 instead and setting the CRF, which is the quality level (lower is better, default is 23, and sane values are between 18 and 28). Encoding with libx264 is kind of complex, so you should look up the H.264 encoding guide. You also need to specify -strict experimental otherwise you might get : " The encoder 'aac' is experimental but experimental codecs are not enabled, add '-strict -2' if you want to use it."
提取音频 ffmpeg -i input.flv -acodec libmp3lame output.mp3

科技资讯:

科技学院:

科技百科:

科技书籍:

网站大全:

软件大全:

热门排行