2

as the title suggests I need command for ffmpeg or ffprobe to list only english sub and audio tracks in a media file;I suspect this may involve using sed, awk, or exiftool--if anyone can explain I would appreciate it. TIA

2

The command will show entries for those English tracks which have been assigned a language tag of eng:

ffprobe -show_entries stream=index,codec_type:stream_tags=language -of compact video.mp4 -v 0 | grep eng

Output e.g.

stream|index=1|codec_type=audio|tag:language=eng

(On Windows, use findstr eng in place of grep eng)

1
  • finally! thanks--I've been asking all over and you're the first one to answer with something I could actually use..:) – armight29 Oct 22 '16 at 17:45
0

I know this is a bit old, but I was looking for the same thing and I found a better way.

So first the code for ffprobe

ffprobe -v error -show_entries stream=index,codec_name,codec_type:stream_tags=language -of default=noprint_wrappers=1 "location\input.avi"

The results will show only what you're looking for and nothing more, were as with Mulvya results will include more than what you need, so now all you have to do is split the results.

This is how I would do this in batch

For /F "tokens=1* delims=^=" %%a in ('ffprobe -v error -show_entries stream^="index,codec_name,codec_type:stream_tags^=language" -of default^=noprint_wrappers^=1 "location\input.avi"') do (
        Echo. %%a %%b
)
Results:
index 0
codec_type video
codec_name h264
TAG:language und
index 1
codec_type audio
codec_name aac
TAG:language eng

This is how I'd do it in bash, although I'm still learning, so there could be a better way to script this.

for i in $(echo $(ffprobe -v error -show_entries stream=index,codec_name,codec_type:stream_tags=language -of default=noprint_wrappers=1 "location/input.avi") | tr " " "\n") ; do
   echo $(echo $i | cut -d \= -sf 1)  $(echo $i | cut -d \= -sf 2) 
done
Results:
index 0
codec_type video
codec_name h264
TAG:language und
index 1
codec_type audio
codec_name aac
TAG:language eng

One major difference with the results using ffprobe on windows and Linux, is that with Linux the results show up on a single line, with windows each result appears on a new line, so, with windows we can get away with simply splitting the results, using the delimiter "=", but with bash we need to first split the space, then split by "=".

Now that we've got our results, with either version, you can simply do an if statement to determine the language, although I would suggest doing an if statement to first find "TAG:language" then a nested statement to check what language, I consider this more of a fail-safe, although I doubt there's a codec type/name called eng.

3
  • were as with Mulvya results will include more than what you need --> my command shows fewer fields than yours, as shown in the Output sample. – Gyan Jan 5 '17 at 17:08
  • What you're referring to are the filtered results from the loop, which for mines includes codec_name and shows both streams, if OP doesn't want that, then it can be changed quite easily. But regardless, that's not what I meant regarding the unnecessary data, if I was to run both ffprobe commands, yours would output more data, whereas mines only displays the data I specified in my command, here's an image of the results, in fact, we can output only your results the same way by using "-v error -show_entries stream=index,codec_type:stream_tags=language -of compact f.mp4". – Rycore Jan 12 '17 at 2:02
  • Looks like you missed the -v 0 and grep in my command. – Gyan Jan 12 '17 at 5:19
0

With ffmpeg, you'll get a list of streams, showing any tracks that have been tagged with a language type like so:

ffmpeg.exe -i %a% 2>&1 | find "Stream"

Output (showing list of audio, video & subtitle tracks with any language tags):

Stream #0:0[0x83e]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(top first), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0:1[0x83f]: Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, 5.1(side), fltp, 384 kb/s
Stream #0:2[0x841]: Audio: aac (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 384 kb/s (default)
Stream #0:3[0x840]: Audio: mp3 ([4][0][0][0] / 0x0004), 0 channels
Stream #0:4[0x842]: Audio: mp3 ([4][0][0][0] / 0x0004), 0 channels
Stream #0:5[0x853](tai): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
Stream #0:6[0x854](may): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
Stream #0:7[0x855](vie): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
Stream #0:8[0x856](tha): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
Stream #0:9[0x857](ind): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
Stream #0:10[0x858](bur): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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