Extract text subtitles using ffmpeg libraries

I am writing a C program that uses libb * libs ffmpeg, and using the Dranger tutorial , I can correctly decode both audio and video. I'm currently trying to extract subtitles. I really don’t want to decode them in time and display them on video, but actually extract the subtitle text from the container.

For example, on cli

ffmpeg -i video.mkv -map 0:4 -scodec copy out.ass 

will give me an ass. (For some reason, srts returns text only.)

I tried to communicate with AVSubtitle, avcodec_decode_subtitle2, etc., but they return subtitles line by line. I need time codes in srts, header information in ass, etc. All I want is an entire text subtitle file that has been multiplexed into a container.

+4
source share
1 answer

In the case of .mkv files, you can use mkvextract . You may need to use mkvinfo to determine which track you want to extract.

Since you want to do this from your own C program, you probably want to use the Matroska libraries instead of command line tools.

-1
source

All Articles