I'm following http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html
Made the script but got $ /tmp/palette.png: No such file or directory
How do I generate this file?
I generated it, now I'm stuck on...
It is unlikely that you will encode a complete movie, so you might be tempted to use -ss and -t (or similar) options to select a segment. If you do that, be very sure to have both as input options (before the -i). For example:
script
If you don't, it will cause problem at least for the first pass where the output will never have more than one frame (the palette), so that won't do what you want.
That's what's happening. I changed the script -ss to a time within my video and -t to 6 seconds (also valid), it doesn't work, the gif doesn't get created, the file does but it "contains errors". I open the video by itself and get one frame (the palette).
Output for $ ./gifenc.sh video.mp4 is:
Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)
/tmp/palette.png: No such file or directory
The script:
#!/bin/sh
start_time=2:20
duration=6
palette="/tmp/palette.png"
filters="fps=15,scale=320:-1:flags=lanczos"
ffmpeg -v warning -ss $start_time -t $duration -i $1 -vf "$filters,palettegen" -y $palette
ffmpeg -v warning -ss $start_time -t $duration -i $1 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $1
>>82116
You gave it a video but not a output file
Try
>$ ./gifenc.sh video.mp4 output.gif
and turn
>
ffmpeg -v warning -ss $start_time -t $duration -i $1 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $1
into
>
ffmpeg -v warning -ss $start_time -t $duration -i $1 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $2
>>82124
Thanks, I changed it to $2 and added output.gif and got:
Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)
/tmp/palette.png: No such file or directory
So I opened the video again by itself with mpv and the palette came up for one frame.