[FFmpeg-user] How to Transcode ALL Audio streams from input to output using ffmpeg?
Mahesh Velankar
mvelanka at gmail.com
Thu Nov 24 15:29:08 EET 2022
I have an input MPEG TS file 'unit_test.ts'. This file has following
content (shown by ffprobe):
Input #0, mpegts, from 'unit_test.ts':
Duration: 00:00:57.23, start: 73674.049844, bitrate: 2401 kb/s
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #0:0[0x31]: Video: h264 (Main) ([27][0][0][0] / 0x001B),
yuv420p(progressive), 852x480 [SAR 640:639 DAR 16:9], Closed Captions,
59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
Stream #0:1[0x34](eng): Audio: ac3 ([129][0][0][0] / 0x0081),
48000 Hz, 5.1(side), fltp, 448 kb/s
Stream #0:2[0x35](spa): Audio: ac3 ([129][0][0][0] / 0x0081),
48000 Hz, stereo, fltp, 192 kb/s
I want to convert it into another MPEG TS file. Requirement is that the
Video stream of the input should be directly copied to the output whereas
*ALL* the audio streams should be transcoded "aac" format.
I tried this command:
ffmpeg -i unit_test.ts -map 0 -c copy -c:a aac maud_test.ts
It converted it into 'maud_test.ts' with following contents (shown by
ffprobe)
Input #0, mpegts, from 'maud_test.ts':
Duration: 00:00:57.25, start: 1.400000, bitrate: 2211 kb/s
Program 1
Metadata:
service_name : Service01
service_provider: FFmpeg
Stream #0:0[0x100]: Video: h264 (Main) ([27][0][0][0] / 0x001B),
yuv420p(progressive), 852x480 [SAR 640:639 DAR 16:9], Closed Captions,
59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
Stream #0:1[0x101](eng): Audio: aac (LC) ([15][0][0][0] / 0x000F),
48000 Hz, 6 channels, fltp, 391 kb/s
Stream #0:2[0x102](spa): Audio: aac (LC) ([15][0][0][0] / 0x000F),
48000 Hz, stereo, fltp, 133 kb/s
So it appeared as if the command worked....However when I play the
maud_test.ts file in vlc player I can see both audio streams listed in the
menu; but Stream 1 (eng) remains silent............whereas Stream 2 (spa)
has proper audio. (Original TS file has both audio streams properly audible)
I have tried this with different input files and have seen that same
problem occurs in each case.
What that I am doing is not right?
How should I get this done? (*I can write explicit stream by stream map and
channel arguments to get that done; however I want the command line to be
generic, in that the input file could be having any configuration with one
Video and several Audios with different formats. The configuration will not
be known beforehand.*)
More information about the ffmpeg-user
mailing list