How does MPG determine its default audio track?

201 Views Asked by At

I have some mpg files that I transcoded from DVDs I bought a long time ago (maybe 20 years ago). ffprobe:

Input #0, mpeg, from 'da-orig.mpg':
  Duration: 00:06:59.44, start: 0.044100, bitrate: 6354 kb/s
  Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, progressive), 720x480 [SAR 8:9 DAR 4:3], Closed Captions, 31 fps, 59.94 tbr, 90k tbn
    Side data:
      cpb: bitrate max/min/avg: 7500000/0/0 buffer size: 1835008 vbv_delay: N/A
  Stream #0:1[0x85]: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
  Stream #0:2[0x83]: Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
  Stream #0:3[0x81]: Audio: ac3, 48000 Hz, mono, fltp, 192 kb/s
  Stream #0:4[0x80]: Audio: ac3, 48000 Hz, mono, fltp, 192 kb/s

This shows there are 4 audio streams. When I play this file in VLC / QuickTime it seems that Audio Track 4 is the default. I'd like to understand how this is chosen. Is it something within the mpg container format or are players choosing the stream that has the lowest id (0x80) ?

More background, when I try to turn this into a mp4 file with the following command:

ffmpeg -i da-orig.mpg -c copy -map 0 da-copy.mp4

I get roughly the same size file, but the default audio track is stream #0:1[0x85].

What I want is an equivalent mp4 file (so the same audio track chosen).

1

There are 1 best solutions below

1
tony On

as written in this guide

"The -map option is used to choose which streams from the input(s) should be included in the output(s)."

in your case you have only one input so it would be -map 0
if you have 2 inputs and want video from one and audio from the other it would be -map 0:v -map 1:a

since your input is a container selecting the video would be -map 0:v
and the second audio stream would be -map 0:a:2

ffmpeg -i da-orig.mpg -map 0:v -c:v h264 -crf 17 -preset 'veryslow' -map 0:a:2 -c:a copy output.mp4

to answer to your comment the sequence can help you after you rename your collection with sequential numbers 'collection-name_0000' then
ffmpeg -i collection_name_#04d.mpg -map 0:v -c:v h264 -crf 17 -preset 'veryslow' -map 0:a:2 -c:a copy output-#04d.mp4
this iterate through the videos if they have the same number of streams