14

I would like to get some list of all available subtitles tracks like:

#1 - id, name
#2 - id, name
#3 - id, name
...

So list would tell how much subtitles tracks I have, show id and name of each track

Is there any FFmpeg option to show such list?

2 Answers 2

28

Example

ffprobe command to list the stream ID and language:

ffprobe -loglevel error -select_streams s -show_entries stream=index:stream_tags=language -of csv=p=0 input.mkv

Result

5,eng
6,fao
7,ain

This shows the stream id #5 is English, #6 is Faroese, and #7 is Ainu. See List of ISO 639 codes (refer to 639-2/T or 639-2/B) for the language abbreviations.

-map option

You can use this information to create your command. If you want the English and Ainu languages use:

-map 0:5 -map 0:7

or

-map 0:s:0 -map 0:s:2

or

-map 0:s:m:language:eng -map 0:s:m:language:ain

See the -map option documentation for more info.

5
  • Yes, I need language (or how author of container named subtitles, doesn't matter). I wanted to work only with FFmpeg cause I use it for Android (github.com/WritingMinds/ffmpeg-android-java) and there is no FFprobe.
    – user25
    Commented Jan 9, 2018 at 18:19
  • @user25 ffmpeg starts counting from 0. I'm guessing the other tools start from 1.
    – llogan
    Commented Jan 9, 2018 at 23:06
  • ffprobe uses ISO 639-2T/639-3 (3-character) and not ISO 639-1 (2-character). mediainfo uses ISO 639-1 language abbreviations Commented Sep 21, 2020 at 16:11
  • @MrPotatoHead Clarified in answer. I previously simply copied and pasted the link title.
    – llogan
    Commented Sep 21, 2020 at 18:10
  • Thanks. I have a similar issue where I'm trying to extract only English language subtitles specifically in SRT format. I tried ffprobe -v error -select_streams s -show_entries stream=index:stream_tags=language -of csv=p=0 <input file>. However, this seems to list both PGS formats as well. I did check the ffprobe documentation, and there seems to be an option via txt_format being one of bitmap, text or ass, but neither do I know how to use it, nor did I find examples. Would anyone know how to accomplish this?
    – Jay
    Commented Mar 15 at 3:13
1

FFmpeg seems doesn't have such option

so we can only parse all printed data by ffmpeg -i VIDE_FILE_NAME (filtering out not stream text track lines)

also FFmpeg doesn't really prints that ID (it's just stream position made by FFmpeg) like MediaInfo would print

1
  • 1
    For the lazy reader: ffprobe input.mkv 2>&1 >/dev/null | grep Stream Commented May 21, 2022 at 12:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.