video – Extracting text from hard-coded subtitles using ffmpeg OCR

What is the best way to extract OCR from hard-coded (burned) subtitles into a text file? At least in my hands OCR in ffmpeg/ffprobe makes too many mistakes to be useful, particularly with accent characters from other languages. For example,

ffprobe -show_entries frame_tags=lavfi.ocr.text -f lavfi -i "movie=m.mp4,ocr" -o sub.txt

I have a method to convert hard-coded subtitles very accurately (including in other languages) but it also requires tools besides ffmpeg. I’d rather stick with ffmpeg so it could be made into a batch process.

My method involves:

burning timestamps into video using ffmpeg and
cropping the video to show just part of the timestamp (hh:mm:ss.s)
removing duplicate frames using ffmpeg and
trimming the result to remove black frames at end
producing images from each frame using ffmpeg and
running a Keyboard Maestro macro to OCR text from those images
converting that text to .srt using Excel vba

Read more here: Source link