We have a text-based subtitle stream, and we need to convert each distinct subtitle in that subtitle stream to an individual .bmp file, with 24 Bits per pixel.
How can we do that with ffmpeg?
A little hacky, but this is the best I came up with, also given the rather ambiguous task, where it isn't clear what the output frame size should be, or how the timing should be guaranteed.
ffmpeg -f lavfi -i "color=color=black:d=10:s=1280x720:r=24" \
-filter:v "subtitles=sample.srt,mpdecimate,setpts=N/FRAME_RATE/TB" \
images/out-%04d.bmp
Here's what this does:
subtitles filter (see its options for defining the subtitle style).mpdecimate, and reset the time base. This can be left out if you do not want only distinct images to be output.Now, in case there are parts without subtitles, this will output an empty black frame—these will have to be removed later on, e.g. based on a file checksum.