Official: www.ffmpeg.org
ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow
ffmpeg -i video.mov -preset veryslow video.mp4ffmpeg -i video.mov -q:v 1 %05d.jpg # (1)
ffmpeg -i video.mov -q:v 1 -vframes 1 -ss 00:10:00 image.jpg # (2)-
convert video to a sequence of jpeg files.
-
extracts a single image at time 10s.
| option example | comment |
|---|---|
|
Set the quality of the video encoder. Values range from 1 to 31, where lower means better. |
|
save to jpeg files, numbered in order |
|
Set the number of frames to output. |
|
starting at 10 min from the beginning. |
|
As an input option, set FPS. ie. regenerate timestamp with given FPS. |
|
As an output option, duplicate or drop input frames to achieve constant output frame rate fps. |
ffmpeg -framerate 1/5 -i img%03d.png -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4
ffmpeg -pattern_type glob -i "image-*.png" out.mp4 # Not numbered or no regular pattern|
Note
|
Use -loop 1 as an input option for an infinite loop, and then use -t 00:30:00 as an output option to cut off the video at thirty minutes.
|
If file names does not comply the %d nomenclature (not starting 0), print the list into a file like:
# this is a comment
file '/path/to/file1.jpg'
file '/path/to/file2.jpg'
file '/path/to/file3.jpg'ls /volumes/data/sample/images/left/* | xargs -L 1 -I {} echo "file '{}'" >> mylist.txt
ffmpeg -f concat -i mylist.txt -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4You can use the -ss option to specify a start timestamp, and the -t option to specify the encoding duration. The timestamps need to be in HH:MM:SS.xxx format or in seconds.
ffmpeg -i input.mp4 -ss 00:00:30.0 -c copy -t 00:00:10.0 output.mp4
ffmpeg -i input.mp4 -ss 30 -c copy -t 10 output.mp4option |
placement |
description |
|
input |
retimes input frames at that rate. |
output |
will duplicate or drop frames to achieve the given rate. |
ffmpeg -i input.mp4 -r 2 output.gif # (1)
ffmpeg -i input.mp4 -filter:v "fps=2" output.gif # (1)
ffmpeg -r 2 -i input.mp4 output.gif # (2)-
retime: drop frames to meet 2 fps.
-
reinterpret: slow down framerate to meet 2 fps.
ffmpeg -i input.mp4 -filter:v "crop=100:100:12:34" output.mp4
ffmpeg -i input.mp4 -filter:v "crop=200:ih:12:34" output.mp4ffmpeg -i input.mp4 -filter:v "scale=640:-1" output.mp4 # (1)
ffmpeg -i input.mp4 -filter:v "scale=iw/2:-1" output.mp4 # (2)-
rescale the video 640 pixel width, and height keeps aspect ratio.
-
downscale the video by 4 (2 in each dimension).
# first pass
ffmpeg -i movie.mp4 -vf vidstabdetect=stepsize=6:shakiness=10:accuracy=15:result=motions.trf -f null -
# second pass
ffmpeg -i movie.mp4 -vf vidstabtransform=input=motions.trf:smoothing=60:relative=1,unsharp=5:5:0.8:3:3:0.4 \
-vcodec libx264 -preset veryslow -tune film -acodec copy -y smooth.mp4|
Note
|
to use filter stereo3d, you may have a recent version of ffmpeg.
|
side by side half width left first to Red cyan gray/monochrome
ffmpeg -i SbS.mp4 -vf stereo3d=sbs2l:arbg -y anaglyph.mp4with :
|
side by side |
|
half width |
|
left first |
|
anaglyph |
|
red blue grey |
If the output video is still squeezed, use :
ffmpeg -i SbS.mp4 -vf "stereo3d=sbsl:arcg,scale=iw*2:ih" -y anaglyph.mp4with :
|
side by side left first |
|
anaglyph red/cyan gray |
|
squeeze horizontally |
ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 input.mp4
1280x720# query the video stream
ffprobe -v error -count_frames -select_streams v:0 -show_entries stream=nb_read_frames -of default=nokey=1:noprint_wrappers=1 input.mp4
# query the container
ffprobe -v error -select_streams v:0 -show_entries stream=nb_frames -of default=nokey=1:noprint_wrappers=1 input.mp4