6

I have had media files (video + audio) which have more than one audio track. Sharing an example below -

 $ mediainfo somefile.mkv General Unique ID : xxxxxxxxxxxxxxxxxxxxxxxx Complete name : somefile.mkv Format : Matroska Format version : Version 4 / Version 2 File size : 1.35 GiB Duration : 2h 26mn Overall bit rate : 1 314 Kbps Movie name : somefile Encoded date : UTC 2016-09-04 00:00:15 Writing application : mkvmerge v8.8.0 ('Wind at my back') 64bit Writing library : libebml v1.3.3 + libmatroska v1.4.4 Cover : Yes Attachments : Cover.jpg Video ID : 1 Format : AVC Format/Info : Advanced Video Codec Format profile : [email protected] Format settings, CABAC : Yes Format settings, ReFrames : 4 frames Codec ID : V_MPEG4/ISO/AVC Duration : 2h 26mn Bit rate : 1 024 Kbps Width : 1 280 pixels Height : 544 pixels Display aspect ratio : 2.35:1 Frame rate mode : Constant Frame rate : 24.000 fps Color space : YUV Chroma subsampling : 4:2:0 Bit depth : 8 bits Scan type : Progressive Bits/(Pixel*Frame) : 0.061 Stream size : 1.05 GiB (78%) Title : somefile Writing library : x264 core 142 r2479 dd79a61 Encoding settings : cabac=1 / ref=3 / deblock=1:-1:-1 / analyse=0x3:0x113 / me=umh / subme=10 / psy=1 / psy_rd=0.00:0.00 / mixed_ref=1 / me_range=32 / chroma_me=1 / trellis=2 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=0 / chroma_qp_offset=0 / threads=12 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=8 / b_pyramid=2 / b_adapt=2 / b_bias=0 / direct=3 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=60 / rc=2pass / mbtree=1 / bitrate=1024 / ratetol=1.0 / qcomp=0.60 / qpmin=10 / qpmax=51 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / ip_ratio=1.40 / aq=1:1.00 Language : Tamil Default : Yes Forced : No Audio #1 ID : 2 Format : AC-3 Format/Info : Audio Coding 3 Format profile : Dolby Digital Mode extension : CM (complete main) Format settings, Endianness : Big Codec ID : A_AC3 Duration : 2h 26mn Bit rate mode : Constant Bit rate : 224 Kbps Channel(s) : 2 channels Channel positions : Front: L R Sampling rate : 48.0 KHz Frame rate : 31.250 fps (1536 spf) Compression mode : Lossy Stream size : 235 MiB (17%) Title : somefile Language : Hindi Default : Yes Forced : No Audio #2 ID : 3 Format : AAC Format/Info : Advanced Audio Codec Format profile : HE-AAC / LC Codec ID : A_AAC Duration : 2h 26mn Bit rate : 64.0 Kbps Channel(s) : 2 channels Channel positions : Front: L R Sampling rate : 48.0 KHz / 24.0 KHz Frame rate : 23.438 fps (1024 spf) Compression mode : Lossy Stream size : 67.1 MiB (5%) Title : somefile Language : Tamil Default : No Forced : No 

I have taken out the uniqueid and the name of the media file for privacy as well as not needed reasons. As can be seen by the mediainfo there are two audio tracks, one Hindi and the other Tamil. By default, it will take the hindi track as that is the default, but what if I want the Tamil track. How can I play this ?

3
  • 3
    Does # switch between the audio tracks? (i.e. while playing with mpv) Commented Sep 6, 2016 at 15:12
  • it does, but that doesn't solve my query as I want to do it via CLI and not by a switch, although good tip in itself. Commented Sep 6, 2016 at 19:06
  • It's clearly a question about CLI, but the GUI (balloon-shaped) button is worth mentioning too. Commented Nov 12, 2017 at 23:06

1 Answer 1

6

MPV provides --aid, from the manual:

--aid=<ID|auto|no> Select audio track. auto selects the default, no disables audio. See also --alang. mpv normally prints available audio tracks on the terminal when starting playback of a file. 

So yeah --aid=1 will be Hindi and --aid=2 will be Tamil.

The is also --alang which should be capable to recognize language codes:

  • --alang=hin should play Hindi if such a track is available
  • --alang=tam should play Tamil if Tamil is available
  • And --alange=tam,hin should play Tamil is available, and if not available shall try to find a Hindi track.

Notes:

  • ffprobe will print the language codes (just like mediainfo prints the full langauge).
  • There are also --sid and --slang for subtitles.
2
  • Both of the above work with a slight difference, the --alange=tam , if alange=ta then it doesn't work. Using mpv 0.20.0 Commented Sep 6, 2016 at 22:18
  • @shirish - interesting. I used hu and pl for Hungarian and Polish because that was the only video I had with different tracks. I guess it only matches if there is no ambiguity. ta can be Tahitian as well. But yeah we should all be using ISO 639-2 codes not 639-1 codes. I updated the answer. Commented Sep 6, 2016 at 22:41

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.