I want to use ffmpeg to convert .avi to .gif with good quality and subtitles.
Now, I use this script to convert from .avi to .gif with good quality:
ffmpeg -v warning -ss 10:00 -t 5 -i input.avi -vf "fps=15,scale=420:-1:flags=lanczos,palettegen" -y palette.png
ffmpeg -v warning -ss 10:00 -t 5 -i input.avi -i palette.png -lavfi "fps=15,scale=420:-1:flags=lanczos [x]; [x][1:v] paletteuse" -y output.gif
I generate a palette and then using it to output the gif.
Then I am using this script to add subtitles to gif:
ffmpeg -v warning -i output.gif -vf "ass=subtitles.ass" -y outputWithSubs.gif
All that works just fine. The problem is that the first script gives me good quality without subtitles and the second gives me subtitles without good quality.
When I am trying to combine them with this script:
ffmpeg -v warning -ss 10:00 -t 5 -i input.avi -vf "fps=15,scale=420:-1:flags=lanczos,palettegen" -y palette.png
ffmpeg -v warning -ss 10:00 -t 5 -i input.avi -i palette.png -vf "ass=subtitles.ass" -lavfi "fps=15,scale=420:-1:flags=lanczos [x]; [x][1:v] paletteuse" -y output.gif
I am getting this error:
Filtergraph 'ass=subtitles.ass' was specified through the -vf/-af/-filter option for output stream 0:0, which is fed from a complex filtergraph.
-vf/-af/-filter and -filter_complex cannot be used together for the same stream.
Is there any way that I could combine good quality and subtitles at the same time?