Created
February 28, 2021 03:10
-
-
Save devadvance/f2ad3cfe38afe3eeef64c72c46692158 to your computer and use it in GitHub Desktop.
Create animated GIF and WebP from videos using ffmpeg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ffmpeg -ss $INPUT_START_TIME -t $LENGTH -i $INPUT_FILENAME \ | |
-vf "fps=$OUTPUT_FPS,scale=$OUTPUT_WIDTH:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" \ | |
-loop $NUMBER_OF_LOOPS $OUTPUT_FILENAME | |
# Change these placeholders: | |
# * $INPUT_START_TIME - number of seconds in the input video to start from. | |
# * $LENGTH - number of seconds to convert from the input video. | |
# * $INPUT_FILENAME - path to the input video. | |
# * $OUTPUT_FPS - ouput frames per second. Start with `10`. | |
# * $OUTPUT_WIDTH - output width in pixels. Aspect ratio is maintained. | |
# * $NUMBER_OF_LOOPS - use `0` to loop forever, or a specific number of loops. | |
# * $OUTPUT_FILENAME - the name of the output animated GIF. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ffmpeg -ss 32.5 -t 7 -i "sample_recording.mp4" \ | |
-vf "fps=10,scale=720:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" \ | |
-loop 0 sample_recording.gif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ffmpeg -ss $INPUT_START_TIME -t $LENGTH -i $INPUT_FILENAME \ | |
-vf "fps=$OUTPUT_FPS,scale=$OUTPUT_WIDTH:-1:flags=lanczos" \ | |
-vcodec libwebp -lossless 0 -compression_level 6 \ | |
-q:v $OUTPUT_QUALITY -loop $NUMER_OF_LOOPS \ | |
-preset picture -an -vsync 0 $OUTPUT_FILENAME | |
# Change these placeholders: | |
# * $INPUT_START_TIME - number of seconds in the input video to start from. | |
# * $LENGTH - number of seconds to convert from the input video. | |
# * $INPUT_FILENAME - path to the input video. | |
# * $OUTPUT_FPS - ouput frames per second. Start with `10`. | |
# * $OUTPUT_WIDTH - output width in pixels. Aspect ratio is maintained. | |
# * $OUTPUT_QUALITY - quality of the WebP output. Start with `50`. | |
# * $NUMBER_OF_LOOPS - use `0` to loop forever, or a specific number of loops. | |
# * $OUTPUT_FILENAME - the name of the output animated WebP. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ffmpeg -ss 32.5 -t 7 -i "sample_recording.mp4" \ | |
-vf "fps=10,scale=720:-1:flags=lanczos" \ | |
-vcodec libwebp -lossless 0 -compression_level 6 \ | |
-q:v 50 -loop 0 \ | |
-preset picture -an -vsync 0 sample_recording.webp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ffmpeg -i $INPUT_FILENAME \ | |
-vf "fps=$OUTPUT_FPS,scale=$OUTPUT_WIDTH:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" \ | |
-loop $NUMBER_OF_LOOPS $OUTPUT_FILENAME | |
# Change these placeholders: | |
# * $INPUT_FILENAME - path to the input video. | |
# * $OUTPUT_FPS - ouput frames per second. Start with `10`. | |
# * $OUTPUT_WIDTH - output width in pixels. Aspect ratio is maintained. | |
# * $NUMBER_OF_LOOPS - use `0` to loop forever, or a specific number of loops. | |
# * $OUTPUT_FILENAME - the name of the output animated GIF. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ffmpeg -i "sample_recording.mp4" \ | |
-vf "fps=10,scale=720:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" \ | |
-loop 0 sample_recording.gif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ffmpeg -i $INPUT_FILENAME \ | |
-vf "fps=$OUTPUT_FPS,scale=$OUTPUT_WIDTH:-1:flags=lanczos" \ | |
-vcodec libwebp -lossless 0 -compression_level 6 \ | |
-q:v $OUTPUT_QUALITY -loop $NUMER_OF_LOOPS \ | |
-preset picture -an -vsync 0 $OUTPUT_FILENAME | |
# Change these placeholders: | |
# * $INPUT_FILENAME - path to the input video. | |
# * $OUTPUT_FPS - ouput frames per second. Start with `10`. | |
# * $OUTPUT_WIDTH - output width in pixels. Aspect ratio is maintained. | |
# * $OUTPUT_QUALITY - quality of the WebP output. Start with `50`. | |
# * $NUMBER_OF_LOOPS - use `0` to loop forever, or a specific number of loops. | |
# * $OUTPUT_FILENAME - the name of the output animated WebP. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ffmpeg -i "sample_recording.mp4" \ | |
-vf "fps=10,scale=720:-1:flags=lanczos" \ | |
-vcodec libwebp -lossless 0 -compression_level 6 \ | |
-q:v 50 -loop 0 \ | |
-preset picture -an -vsync 0 sample_recording.webp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment