diff --git a/index.html b/index.html index 8d56d6a..940b9ec 100644 --- a/index.html +++ b/index.html @@ -50,7 +50,8 @@ - + + @@ -258,32 +259,6 @@ - - -
ffmpeg -f image2 -framerate 9 -pattern_type glob -i "input_image_*.jpg" -vf scale=250x250 output_file.gif
This will convert a series of image files into a GIF.
-image2
specifies the image file demuxer.-vf
is an alias for -filter:v
E.g. for converting 24fps to 25fps with audio pitch compensation for PAL access copies. (Thanks @kieranjol!)
+ffmpeg -i input_file -filter_complex "[0:v]setpts=input_fps/output_fps*PTS[v]; [0:a]atempo=output_fps/input_fps[a]" -map "[v]" -map "[a]" output_file
setpts
video filter modifies the PTS (presentation time stamp) of the video stream, and the atempo
audio filter modifies the speed of the audio stream while keeping the same sound pitch. Note that the parameter order for the image and for the sound are inverted:
+ setpts
the numerator input_fps
sets the input speed and the denominator output_fps
sets the output speed; both values are given in frames per second.atempo
the numerator output_fps
sets the output speed and the denominator input_fps
sets the input speed; both values are given in frames per second.ffmpeg -f concat -safe 0 -i mylist.txt -c copy output_file
- Generate image files from a video
-
-
-
-
-
-
-
- Create GIF
- Create high quality GIF
- ffmpeg -ss HH:MM:SS -i input_file -filter_complex "fps=10,scale=500:-1:flags=lanczos,palettegen" -t 3 palette.png
- ffmpeg -ss HH:MM:SS -i input_file -i palette.png -filter_complex "[0:v]fps=10, scale=500:-1:flags=lanczos[v], [v][1:v]paletteuse" -t 3 -loop 6 output_file
- The first command will use the palettegen filter to create a custom palette, then the second command will create the GIF with the paletteuse filter. The result is a high quality GIF.
-
- - ffmpeg
- starts the command
- - -ss HH:MM:SS
- starting point of the GIF. If a plain numerical value is used it will be interpreted as seconds
- - -i input_file
- path, name and extension of the input file
- - -filter_complex "fps=framerate, scale=width:height, palettegen"
- a complex filtergraph.
- Firstly, the fps filter sets the frame rate.
- Then the scale filter resizes the image. You can specify both the width and the height, or specify a value for one and use a scale value of -1 for the other to preserve the aspect ratio. (For example, 500:-1
would create a GIF 500 pixels wide and with a height proportional to the original video). In the first script above, :flags=lanczos
specifies that the Lanczos rescaling algorithm will be used to resize the image.
- Lastly, the palettegen filter generates the palette.
- - -t 3
- duration in seconds (here 3; can be specified also with a full timestamp, i.e. here 00:00:03)
- - -loop 6
- sets the number of times to loop the GIF. A value of -1 will disable looping. Omitting -loop will use the default, which will loop infinitely.
- - output_file
- path, name and extension of the output file
-
- The second command has a slightly different filtergraph, which breaks down as follows:
-
- - -filter_complex "[0:v]fps=10, scale=500:-1:flags=lanczos[v], [v][1:v]paletteuse"
[0:v]fps=10,scale=500:-1:flags=lanczos[v]
: applies the fps and scale filters described above to the first input file (the video).
- [v][1:v]paletteuse"
: applies the paletteuse
filter, setting the second input file (the palette) as the reference file.
-
- Simpler GIF creation
- ffmpeg -ss HH:MM:SS -i input_file -vf "fps=10,scale=500:-1" -t 3 -loop 6 output_file
- This is a quick and easy method. Dithering is more apparent than the above method using the palette filters, but the file size will be smaller. Perfect for that “legacy” GIF look.
-
-
-
-
-
-
+ Generate image files from a video
@@ -1245,6 +1212,74 @@ e.g.: ffmpeg -f concat -safe 0 -i mylist.txt -c copy output_file
+
+
+ Create an animated GIF
+
+
+
+
+
+
+
+ Images to GIF
+ ffmpeg -f image2 -framerate 9 -pattern_type glob -i "input_image_*.jpg" -vf scale=250x250 output_file.gif
+ This will convert a series of image files into a GIF.
+
+ - ffmpeg
- starts the command
+ - -f image2
- forces input or output file format.
image2
specifies the image file demuxer.
+ - -framerate 9
- sets framerate to 9 frames per second
+ - -pattern_type glob
- tells ffmpeg that the following mapping should "interpret like a glob" (a "global command" function that relies on the * as a wildcard and finds everything that matches)
+ - -i "input_image_*.jpg"
- maps all files in the directory that start with input_image_, for example input_image_001.jpg, input_image_002.jpg, input_image_003.jpg... etc.
+ (The quotation marks are necessary for the above “glob” pattern!)
+ - -vf scale=250x250
- filter the video to scale it to 250x250;
-vf
is an alias for -filter:v
+ - output_file.gif
- path and name of the output file
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Create GIF
+ Create high quality GIF
+ ffmpeg -ss HH:MM:SS -i input_file -filter_complex "fps=10,scale=500:-1:flags=lanczos,palettegen" -t 3 palette.png
+ ffmpeg -ss HH:MM:SS -i input_file -i palette.png -filter_complex "[0:v]fps=10, scale=500:-1:flags=lanczos[v], [v][1:v]paletteuse" -t 3 -loop 6 output_file
+ The first command will use the palettegen filter to create a custom palette, then the second command will create the GIF with the paletteuse filter. The result is a high quality GIF.
+
+ - ffmpeg
- starts the command
+ - -ss HH:MM:SS
- starting point of the GIF. If a plain numerical value is used it will be interpreted as seconds
+ - -i input_file
- path, name and extension of the input file
+ - -filter_complex "fps=framerate, scale=width:height, palettegen"
- a complex filtergraph.
+ Firstly, the fps filter sets the frame rate.
+ Then the scale filter resizes the image. You can specify both the width and the height, or specify a value for one and use a scale value of -1 for the other to preserve the aspect ratio. (For example, 500:-1
would create a GIF 500 pixels wide and with a height proportional to the original video). In the first script above, :flags=lanczos
specifies that the Lanczos rescaling algorithm will be used to resize the image.
+ Lastly, the palettegen filter generates the palette.
+ - -t 3
- duration in seconds (here 3; can be specified also with a full timestamp, i.e. here 00:00:03)
+ - -loop 6
- sets the number of times to loop the GIF. A value of -1 will disable looping. Omitting -loop will use the default, which will loop infinitely.
+ - output_file
- path, name and extension of the output file
+
+ The second command has a slightly different filtergraph, which breaks down as follows:
+
+ - -filter_complex "[0:v]fps=10, scale=500:-1:flags=lanczos[v], [v][1:v]paletteuse"
[0:v]fps=10,scale=500:-1:flags=lanczos[v]
: applies the fps and scale filters described above to the first input file (the video).
+ [v][1:v]paletteuse"
: applies the paletteuse
filter, setting the second input file (the palette) as the reference file.
+
+ Simpler GIF creation
+ ffmpeg -ss HH:MM:SS -i input_file -vf "fps=10,scale=500:-1" -t 3 -loop 6 output_file
+ This is a quick and easy method. Dithering is more apparent than the above method using the palette filters, but the file size will be smaller. Perfect for that “legacy” GIF look.
+
+
+
+
+
+
+
Create a video from images
@@ -2200,35 +2235,6 @@ foreach ($file in $inputfiles) {
-
-
-
-
-
-
- Modify image and sound speed
- E.g. for converting 24fps to 25fps with audio pitch compensation for PAL access copies. (Thanks @kieranjol!)
- ffmpeg -i input_file -filter_complex "[0:v]setpts=input_fps/output_fps*PTS[v]; [0:a]atempo=output_fps/input_fps[a]" -map "[v]" -map "[a]" output_file
-
- - ffmpeg
- starts the command
- - -i input_file
- path, name and extension of the input file
- - -filter_complex "[0:v]setpts=input_fps/output_fps*PTS[v]; [0:a]atempo=output_fps/input_fps[a]"
- A complex filter is needed here, in order to handle video stream and the audio stream separately. The
setpts
video filter modifies the PTS (presentation time stamp) of the video stream, and the atempo
audio filter modifies the speed of the audio stream while keeping the same sound pitch. Note that the parameter order for the image and for the sound are inverted:
-
- - In the video filter
setpts
the numerator input_fps
sets the input speed and the denominator output_fps
sets the output speed; both values are given in frames per second.
- - In the sound filter
atempo
the numerator output_fps
sets the output speed and the denominator input_fps
sets the input speed; both values are given in frames per second.
-
- The different filters in a complex filter can be divided either by comma or semicolon. The quotation marks allow to insert a space between the filters for readability.
- - -map "[v]"
- maps the video stream and:
- - -map "[a]"
- maps the audio stream together into:
- - output_file
- path, name and extension of the output file
-
-
-
-
-
-
-
-