Ffmpeg

From Colettapedia
Jump to navigation Jump to search

Crop video

  • ffmpeg -i input.mp4 -filter:v "crop=w:h:x:y" output.mp4

Fast Rotate Video

  • ffmpeg -i input.mp4 -c copy -metadata:s:v:0 rotate=270 output.mp4

Mosaic Videos

  • ffmpeg -i input01.mp4 -i input02.mp4 -i input03.mp4 -filter_complex vstack=3 out.mp4
  • ffmpeg -f concat -i mylist.txt -c copy output.mp4 - create file list to do simple linear concat

My Home Video Conversion Pipeline example

  1. ffmpeg -ss 1:23:40 -to 1:26:05 -i Coletta-Tape03.avi -vf yadif -crf 12 temp1.mp4
  2. python3 -m vidstab -i temp1.mp4 -o temp1_stab.mp4 - also set num frames for stability using -s 10 and drop edges using -z 10
  3. ffmpeg -i temp1_stab.mp4 -vf "setpts=N/29.97/TB,fps=29.97" -r 29.97 -crf 12 temp1_stab_30fps.mp4
  4. ffmpeg -i temp1_stab_30fps.mp4 -i 1992_Gaeta_Christmas_Eve.mp4 -shortest -c:v copy -map 0:v:0 -map 1:a:0 FINAL.mp4

Pull in images as frames Example

  • ffmpeg -i ./%04d.png -c:v libx264 -vf "format=yuv420p" -crf 12 output.mp4

H.264 encoding

  • ffmpeg -i VID_20160918_113318088.mp4 -vprofile high -codec:v libx264 -preset slow -b:v 2500k -maxrate 2500k -bufsize 5000k -vf scale=-2:720 -threads 0 -codec:a aac -b:a 128k ../HD_size/VID_20160918_113318088_720.mp4
    • Set resolution and bitrate all at the same time
  • ffmpeg -r 1 -i img%01d.png -vcodec mpeg4 -y movie.mp4
    • fps is defined with the "-r" bit - so "-r 1" would be 1 fps, "-r 30" would be 30, etc.