From wikipost
Revision as of 14:46, 28 July 2020 by Admin (talk | contribs)
Jump to navigationJump to search

Bunch of ffmpeg examples on one page

ffmpeg -y -i INFILE.mp4 -vcodec mpeg4 -vb 200k -acodec libvo_aacenc -ac 1 -ab 94000 -ar 16000 OUTFILE.mp4

ffmpeg -y -i INFILE.mp4 -c:v libx264 -crf 23 -vb 200k -c:a copy OUTFILE.mp4

convert jpg images to video: ffmpeg -r 1/0.1 -f concat -i filelist.txt -r 25 -c:v libx264 -pix_fmt yuv420p -y OUTFILE.mp4 (where filelist.txt contains the list of image file names, e.g. img001.jpg, img002.jpg)

Video bitrate:

  rule of thumb: divide your target size (in bits) by the video length (in seconds)
  example: for a 6 second video to be 10MBytes, use (10,000,000 / 6) = 1.6M
    -vb 1000k
  Note: lower CRF (Constant Rate Factor) equals higher quality (and larger files)
  (max bitrate over wifi around 1Mbps)

Audio codecs and options:

-acodec libvo_aacenc -ac 1 -ab 94000 -ar 16000 
-acodec aac -ac 2 -ab 128k
-acodec copy

Time selection:

   -ss = start-time offset (0 = begin, 5:00 = after 5 minutes)
   -t  = duration (1:00 = one minute, 1:45:00 = 1 hour and 45 minutes)
   -ss 2:23
   -ss 1:49 -t 1:58:02
   -t 2:15:06

Screen resolution:

    -s 1280x720

Resize and Crop options:

  Resize: -vf scale=iw*2:ih
     -vf "setsar=1/0.75" // Set the pixel sample aspect ratio.
     -vf "setdar=64:27"  // Set the frame display aspect ratio.

  Scale by percentage:
     -vf scale=iw/2:-1

  Crop: -vf crop=<width>:<height>:<from t/b>:<from l/r>
     -vf crop=680:440:300:50


     -force_key_frames 1