Uhg, How do I post a blinking LED image again?

Every time I have to look this up… I have a longer page of notes to go through, but at least I can post the links.

get ffmpeg

brew install ffmpeg

Use ffmpeg for creating a video from the images in the file sequence img-001.jpeg, img-002.jpeg, …, assuming an input frame rate of 10 frames per second:

ffmpeg -framerate 10 -i 'img-%03d.jpeg' out.mkv

As above, but start by reading from a file with index 100 in the sequence:

ffmpeg -framerate 10 -start_number 100 -i 'img-%03d.jpeg' out.mkv

Read images matching the “*.png” glob pattern , that is all the files terminating with the “.png” suffix:

ffmpeg -framerate 10 -pattern_type glob -i "*.png" out.mkv 
#-video_size 320x240
## destination folder must already exist.
ffmpeg -i $filename.mov -r 1 "$filename_frames/$filename%03d.png"
## edit frames...
ffmpeg -f image2 -i "$filename_frames/$filename%03d.png" -loop 0 $filename.gif
ffmpeg -i IMG_1703.mov -r 12 "all_frames2/switch_press%03d.png"
ffmpeg -i $filename.mov -r 1 "$filename_frames/$filename%03d.png"
ffmpeg -f image2 -i "$filename_frames/$filename%03d.png" -loop 0 $filename.gif
# 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.

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
ffmpeg -f image2 -framerate 12 -start_number 085 -i these/switch_press%003d.png -vf "fps=12,scale=240:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 touch_12fps.gif

num=298; for i in *; do mv "$i" "$(printf 'switch_press%003d' $num).${i#*.}"; ((num++)); done
ffmpeg -f image2 -i "these5/switch_press%003d.png" -loop 0 touchc.gif

ffmpeg -f image2 -framerate 12 -i these/switch_press%003d.png -vf "fps=10,scale=320:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 toucha_12to10fps.gif

ffmpeg -i IMG_1706.mov -vf "palettegen" palette.png
ffmpeg -i IMG_1706.mov -loop 0 -filter_complex "fps=10, scale=-1:240[s]; [s]split[a][b]; [a]palettegen[palette]; [b][palette]paletteuse" final_a.gif