Ffmpeg

From IridiaWiki
Jump to navigationJump to search

These are the steps to convert a set of frames (in the format frame_xxxxx.bmp) to a video.

Some options

  • -f image2 : to start from a set of frames (not a video)
  • -i input : the input value
  • -r xx.xxxx : frames per second (that is, fps given by the camera when recording)
  • -b xxxxk : specify the bitrate (higher = better quality, larger file size)
  • -threads 0 : optimal thread usage
  • -an : no audio
  • -vcodec libx264 : uses the best and newest codec (on ubuntu it's in the libx264-106 packet)
  • -vpre xxxx : codec quality (see here )
  • -vf : video filtes for adding filters (to have a list of available filters type 'ffmpeg -filters'). here below useful filters:
    • "transpose=1" : rotates the video (1 rotates by 90 degrees clockwise; 2 rotates by 90 degrees counterclockwise)
  • output.ext : output is the name of the file, ext is the extension. Note that selecting mp4 or avi produces different files (is not just a name!)

Examples

  • Low quality video, fast result:
ffmpeg -f image2 -r 12.0205 -i frame_%05d.bmp -vcodec libx264 -threads 0 -an -vpre fast video_fast.avi
  • High quality (slow, high quality)::
ffmpeg -f image2 -r 12.0205 -i frame_%05d.bmp -vcodec libx264 -threads 0 -an -vpre hq -b 2000k video2000k.avi
  • High quality, 2 pass (very slow, even higher quality):
    • note that there are actually two commands (hence the &&), the first generates the first pass to get the info necessary for the second pass. The command generates 4 files: video_2pass1.avi (the first pass, useless, can be deleted), video_2pass2.avi (the video itself, to keep) and 2 log files (delete them if you need to create another 2pass video)
ffmpeg -f image2 -r 12.0205 -i frame_%05d.bmp -an -vcodec libx264 -threads 0 -vpre fastfirstpass -b 2000k -pass 1 video_2pass1.avi &&
ffmpeg -f image2 -r 12.0205 -i frame_%05d.bmp -an -vcodec libx264 -threads 0 -vpre hq -b 2000k -pass 2 video_2pass2.avi

A note about doing videos from ARGoS2. The size of the images depends on the size of the window, so make sure that the size of the window is the one you like and also that both sizes are divisible by 2, otherwise x264 might complain.

  • Convert Avi (or any video) to Ogg or Webm (useful to embed in the HTML5 video tag)
ffmpeg -i video.avi video.ogv
ffmpeg -i video.avi video.webm
  • Rotate a video, remove audio and convert to avi
ffmpeg -vf "transpose=2" -an -sameq -i 00000.MTS video.avi

Useful links

--Manubrambi 09:05, 10 October 2011 (UTC)