Recently I have been having a lot of fun with ffmpeg
. I do photography and wanted a FOSS way to make timelapses, slideshows, etc. I thought I would share three sets of commands that currently see frequent use with me.
Make a time-lapse from a set of JPEGs
ffmpeg -framerate 30 -pattern_type glob -i "*.JPG" -s:v 1440x1080 -c:v libx264 -crf 17 -pix_fmt yuv420p my-timelapse.mp4
Flag | Action |
---|---|
-framerate |
Fromrate of the movie |
-pattern_type glob |
Grab all of the images in a wildcard fashion |
-i |
Input file(s) |
-s:v |
Output resolution |
-c:v |
Encoder Type (H264) |
-crf |
A parameter specific to the H264 codec that determines the quality/compression |
-pix_fmt yuv420p |
This needs to be set to yuv420p to allow many players, such as Quicktime to play the video ("the FFmpeg docs say dumb players, I'll be more forgiving") |
Add Audio To A Video
ffmpeg -i my-timelapse.mp4 -i santa_short.opus -c copy -map 0:v:0 -map 1:a:0 output.mp4
Source: https://superuser.com/questions/590201/add-audio-to-video-using-ffmpeg
Create A GIF From A Video File
ffmpeg -ss 20 -t 9 -i input.mp4 -vf "fps=20,scale=540:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 output.gif
Flag | Action |
---|---|
-ss |
Skip the first Y seconds |
-t |
Create an X second clip |
-i |
Input file |
-vf |
Scale to these specifications with this algorithm |
-loop |
Loop the result (0 = true) |
Source: superuser.com