This is an old revision of the document!


/opt/ffmpeg/bin/ffmpeg -i 1.mov -i 2.mov -f lavfi -i color=black -filter_complex \
"[0:v]format=pix_fmts=yuva420p,fade=t=out:st=4:d=1:alpha=1,setpts=PTS-STARTPTS[va0];\
[1:v]format=pix_fmts=yuva420p,fade=t=in:st=0:d=1:alpha=1,setpts=PTS-STARTPTS+4/TB[va1];\
[2:v]scale=1920x1080,trim=duration=7[over];\
[0:a]afade=t=out:st=4:d=1[a0];\
[1:a]afade=t=in:st=0:d=1[a1];\
aevalsrc=0:d=4[s1];\
[s1][a1]concat=n=2:v=0:a=1[ac1];\
[a0][ac1]amix[outa];\
[over][va0]overlay[over1];\
[over1][va1]overlay=format=yuv420[outv]" \
-vcodec libx264 -aspect 1.778 -map [outv] -map [outa] -codec:a libmp3lame -qscale:a 2 -ss 00:00:02 -t 5 out.mp4
  • highest quality:
/opt/ffmpeg/bin/ffmpeg -i 1.mov -i 1.mov -f lavfi -i color=black -filter_complex \
"[0:v]format=pix_fmts=yuva420p,fade=t=out:st=4:d=1:alpha=1,setpts=PTS-STARTPTS[va0];\
[1:v]format=pix_fmts=yuva420p,fade=t=in:st=0:d=1:alpha=1,setpts=PTS-STARTPTS+4/TB[va1];\
[2:v]scale=1920x1080,trim=duration=7[over];\
[0:a]afade=t=out:st=4:d=1[a0];\
[1:a]afade=t=in:st=0:d=1[a1];\
aevalsrc=0:d=4[s1];\
[s1][a1]concat=n=2:v=0:a=1[ac1];\
[a0][ac1]amix[outa];\
[over][va0]overlay[over1];\
[over1][va1]overlay=format=yuv420[outv]" \
-vcodec libx264 -preset ultrafast -qp 0 -aspect 1.778 -map [outv] -map [outa] -acodec libvorbis -qscale:a 10 -ss 00:00:02 -t 5 out.mp4
  • compress video with ffmpeg:
ffmpeg -i input.mp4 -vcodec libx265 -crf 28 output.mp4

crf is typically 24 through 30. Higher numbers are smaller files and lower quality. From https://unix.stackexchange.com/questions/28803/how-can-i-reduce-a-videos-size-with-ffmpeg

  • convert video to a sequence of pngs: ffmpeg -i <FILENAME1> <FILENAME2>_%03d.png
  • slow down video but keep smoothness by using optical flow (sometimes called motion interpolation): ffmpeg -i input.mkv -filter:v "minterpolate='mi_mode=mci:mc_mode=aobmc:vsbmc=1:fps=120'" output.mkv where fps is the output fps (independent of input fps)
  • change speed video is played (fps) without changing anything else. No frames are harmed with this cmd: ffmpeg -itsscale 2 -i input.mp4 -c copy -an output.mp4 # slow to 2x slower
  • lwc/multimedia_and_graphics.1668689203.txt.gz
  • Last modified: 2022/11/17 06:46
  • by John Harrison