Reputation: 1546
I already have this working by converting the source video to GIF with:
ffmpeg -y -t 5 source.mp4 -vf fps=10,scale=480:-1,smartblur=ls=-0.5,crop=iw:ih-2:0:0 -hide_banner -loglevel panic output.gif
And then converting the GIF to MP4, like so:
ffmpeg -y animated.gif -hide_banner -pix_fmt yuvj420p -loglevel panic -an -loglevel panic final.mp4
What I want is to convert source.mp4
directly to final.mp4
, and have the same 256 color palette as a normal GIF.
I tried merging both commands together, and although it generates a MP4, the result is a 16 bit video, surprisingly smaller than a 8 bit video.
Do I need to generate a palette first with palettegen
and then re-encode the video with this palette?
Upvotes: 2
Views: 2560
Reputation: 93018
You can use the palettegen and paletteuse filters, like is normally done for GIF creation.
ffmpeg -i source.mp4 -vf palettegen palette.png
and then,
ffmpeg -i source.mp4 -i palette.png -filter_complex "paletteuse" -c:a copy out.mp4
Upvotes: 6