-1

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).

codedread
  • 1,312
  • 11
  • 18
  • 1
    Likely due to the difference in the format (mpg vs. mp4). To set default track for mp4, use `-disposition` option. See [this post](https://video.stackexchange.com/questions/29233) – kesh Oct 01 '22 at 04:27
  • Thanks, I had read that post, but is there a way to programmatically figure out what the default audio stream is from an mpg file so that I can remove/add the disposition default in the output mp4? I've got hundreds of these files (cartoons) – codedread Oct 01 '22 at 05:53

1 Answers1

0

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

tony
  • 63
  • 7
  • 1
    What I ended up doing is, for each mpg file, finding the audio stream that is identified as [0x80] and mapping that to the first audio stream... doing this is what makes the correct audio stream be chosen. (https://ffmpeg.org/ffmpeg.html#Automatic-stream-selection explains that normally the audio stream with the highest # of channels is chosen. Sometimes an audio commentary track is stereo while the original audio track is mono.) I don't know why [0x80] is the audio stream that I want, it must be a quirk of how these files were turned into MPG files in the first place. – codedread Oct 07 '22 at 23:02