加字幕
ffmpeg -i input.mp4 -vf ass=input.ass -c:s mov_text output.mp4
查看硬件加速器
ffmpeg -hwaccels
查看编解码器
ffmpeg -codecs
查看编码器参数
ffmpeg -h encoder=libx264
硬件编码
N卡
ffmpeg -hwaccel cuvid -c:v h264_cuvid -i input.mp4 -c:v h264_nvenc output.mp4
树莓派
ffmpeg -c:v h264_mmal -i input.mp4 -c:v h264_omx output.mp4
光流法
ffmpeg -i input.mp4 -vf "minterpolate='fps=60:mi_mode=mci:mc_mode=aobmc:me_mode=bidir:me=epzs:vsbmc=1:scd=fdiff'" output.mp4
指定输出色彩空间
ffmpeg -i input.mp4 -colorspace bt709 -color_primaries bt709 -color_trc bt709 output.mp4
指定输出像素格式
ffmpeg -i input.mp4 -pix_fmt yuv420p10le output.mp4
动画压制
x264 1080p动画压制
ffmpeg -i input.mp4 -c copy -c:v libx264 -mbtree true -preset veryslow -crf 16.5 -pix_fmt yuv420p10le -deblock -1:-1 -rc-lookahead 70 -aq-strength 0.8 -me_method tesa -psy-rd 0.6:0.15 -aq-mode autovariance-biased -x264-params keyint=600:min-keyint=1:bframes=8:ref=13:qcomp=0.75:no-fast-pskip=1 output.mp4
x264 720p动画压制
ffmpeg -i input.mp4 -c copy -c:v libx264 -preset veryslow -tune film -crf 19 -deblock 0:0 -rc-lookahead 70 -aq-mode variance -aq-strength 0.9 -me_method tesa -psy-rd 0:0.2 -x264-params keyint=480:min-keyint=1:ref=9:qcomp=0.7:merange=16:no-fast-pskip=1 output.mp4
x265 1080p动画压制
ffmpeg -i input.mkv -c copy -c:v libx265 -preset slower -crf 15 -pix_fmt yuv420p10le -x265-params "deblock='-1:-1':ctu=32:qg-size=8:pbratio=1.2:cbqpoffs=-2:crqpoffs=-2:no-sao=1:me=3:subme=5:merange=38:b-intra=1:limit-tu=4:no-amp=1:ref=4:weightb=1:keyint=360:min-keyint=1:bframes=6:aq-mode=1:aq-strength=0.8:rd=5:psy-rd=2.0:psy-rdoq=1.0:rdoq-level=2:no-open-gop=1:rc-lookahead=180:scenecut=40:qcomp=0.65:no-strong-intra-smoothing=1" output.mkv
aom 1080p动画压制(aom自带denoise…)
ffmpeg -i input.mkv -c copy -c:v libaom-av1 -b:v 0 -crf 16 -threads 2 -pix_fmt yuv420p10le -cpu-used 3 -lag-in-frames 48 -arnr-strength 0 -aq-mode variance -denoise-noise-level 0 -tune psnr -g 600 -keyint_min 1 -aom-params sb-size=64:deltaq-mode=0:sharpness=1:enable-dnl-denoising=0:enable-qm=1:quant-b-adapt=0:enable-chroma-deltaq=0:max-partition-size=32:enable-keyframe-filtering=2 output.mkv
aom 1080p动画压制(通过denoise-noise-level生成噪点)
ffmpeg -i input.mkv -c copy -c:v libaom-av1 -b:v 0 -crf 16 -threads 2 -pix_fmt yuv420p10le -cpu-used 3 -lag-in-frames 48 -arnr-strength 0 -aq-mode variance -denoise-noise-level 10 -tune psnr -g 600 -keyint_min 1 -aom-params sb-size=64:deltaq-mode=0:sharpness=1:enable-dnl-denoising=0:enable-qm=1:quant-b-adapt=0:enable-chroma-deltaq=0:max-partition-size=32:enable-keyframe-filtering=2 output.mkv
aom 1080p动画压制(通过film-grain-table生成噪点)
生成表
photon_noise_table --width=1920 --height=1080 --iso=1200 --transfer-function=srgb --output=1920x1080-SRGB-ISO1200.tbl
压制
ffmpeg -i input.mkv -c copy -c:v libaom-av1 -b:v 0 -crf 16 -threads 2 -pix_fmt yuv420p10le -cpu-used 3 -lag-in-frames 48 -arnr-strength 0 -aq-mode variance -tune psnr -g 600 -keyint_min 1 -aom-params sb-size=64:deltaq-mode=0:sharpness=1:enable-dnl-denoising=0:enable-qm=1:quant-b-adapt=0:enable-chroma-deltaq=0:max-partition-size=32:enable-keyframe-filtering=2:film-grain-table=1920x1080-SRGB-ISO1200.tbl output.mkv
x264无损输出
ffmpeg -i input.mp4 -c copy -c:v libx264 -preset ultrafast -qp 0 output.mp4