ffmpeg

resize images in a video

Reduce image width+height to half of original size:

ffmpeg -i video.flv -vf scale=iw*0.5:ih*0.5 -sameq video_small.flv

video conversion with setting of output video bitrate

ffmpeg -i input.avi -b 2000k output.mp4

images => video

ffmpeg -f image2 -i image%d.jpg -b 800 video.mpg

lossless coding + specification of frame rate:

ffmpeg -f image2 -r 3 -sameq -i frame%04d.png video.avi

video => images

ffmpeg -i video.avi frame%04d.png

Start to extract images from a certain position (here: hh:mm::ss.[xxx]=00:06:40) in the video:

ffmpeg -i video.avi -ss 00:06:40 frame%04d.png

video => video (change of codec)

ffmpeg -i test.MOV -sameq -vcodec msmpeg4v2 -acodec pcm_u8 output.avi

example: images => video (.flv = flash video)

Use

ffmpeg -f image2 -r 1 -i frame%04d.jpg -s 320×240 -y -an -r 24 out.flv

or

ffmpeg -f image2 -r 30 -i frame%04d.jpg -sameq -y -an -r 30 out.flv

Note:

  • -r 1 tells that input stream is one frame per second (one image per second), choose the one you like
  • -s 320×240 scales all frames
  • -y -an to overwrite output file and to disable audio recording
  • -r 24 to have 24 fps in the output stream

You can also consider putting -sameq in the middle to preserve quality as much as possible.

Read more

get video infos

ffmpeg -i video.avi

image => video (specifcation of codec)

There is the vcodec switch:

vcodec=
              Employ the specified codec (default: mpeg4).
                 mjpeg
                      Motion JPEG
                 ljpeg
                      Lossless JPEG
                 h263 
                      H.263
                 h263p
                      H.263+
                 mpeg4
                      MPEG-4 (DivX 4/5)
                 msmpeg4
                      DivX 3
                 msmpeg4v2
                      MS MPEG4v2
                 wmv1 
                      Windows Media Video, version 1 (AKA WMV7)
                 wmv2 
                      Windows Media Video, version 2 (AKA WMV8)
                 rv10 
                      an old RealVideo codec
                 mpeg1video
                      MPEG-1 video
                 mpeg2video
                      MPEG-2 video
                 huffyuv
                      HuffYUV
                 asv1 
                      ASUS Video v1
                 asv2 
                      ASUS Video v2
                 ffv1 
                      FFmpeg's lossless video codec

video => video (set xvid codec)

ffmpeg -i source_video.avi -b 300 -s 320×240 -vcodec xvid -ab 32 -ar 24000 -acodec aac final_video.mp4

Explanations :

  • Source : source_video.avi
  • Audio codec : aac
  • Audio bitrate : 32kb/s
  • Video codec : xvid
  • Video size : 320px par 180px
  • Generated video : final_video.mp4

video => get audio channel

Extracting sound from a video, and save it as Mp3:

ffmpeg -i source_video.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 sound.mp3

Explanations :

  • Source video : source_video.avi
  • Audio bitrate : 192kb/s
  • output format : mp3
  • Generated sound : sound.mp3

more samples?

list of cmd line options?

batch conversion with ImageMagick?

Example: mogrify -format eps *.png

 
public/ffmpeg.txt · Last modified: 2014/01/21 11:20 (external edit) · []
Recent changes RSS feed Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki