Opened 13 years ago
Closed 13 years ago
#1056 closed defect (invalid)
FFMPEG unable to select or copy multiple audio tracks in a TS file
Reported by: | ramitb | Owned by: | |
---|---|---|---|
Priority: | important | Component: | undetermined |
Version: | git-master | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | yes | |
Analyzed by developer: | no |
Description
I have a TS file with multiple Audio tracks in it (which FFMPEG can recognize). Howeven when I try to copy the audio track (either by specifying which audio track or requesting a copy all FFMPEG ALWAYS uses the first audio track only AND also converts it to mp2?? instead of copying it).
This sample TS file was created by FFMPEG and it was able to copy all audio tracks into the TS container perfectly but is unable to extract more than 1.
FIRST TEST: Copy 2nd audio track into a TS file
COMMAND:
D:\Test Videos>ffmpeg -threads 0 -async 1 -y -i "video.ts" -vcodec copy -c:a:1 copy output.ts
OUTPUT:
ffmpeg version N-37915-g6cb2085 Copyright (c) 2000-2012 the FFmpeg developers
built on Feb 15 2012 20:47:20 with gcc 4.6.2
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-runtime-cpudetect --enable-avisynth --enab
le-bzlib --enable-frei0r --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --en
able-libmp3lame --enable-libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --en
able-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-
libxvid --enable-zlib
libavutil 51. 39.100 / 51. 39.100
libavcodec 54. 3.100 / 54. 3.100
libavformat 54. 1.100 / 54. 1.100
libavdevice 53. 4.100 / 53. 4.100
libavfilter 2. 62.100 / 2. 62.100
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 6.100 / 0. 6.100
libpostproc 52. 0.100 / 52. 0.100
Input #0, mpegts, from 'video.ts':
Duration: 00:00:01.76, start: 1.400000, bitrate: 9903 kb/s
Program 1
Metadata:
service_name : Canal+ Accion HD
service_provider: Canal+ Accion HD
Stream #0:0[0x100](spa): Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, stereo, s16, 192 kb/s
Stream #0:1[0x101](qaa): Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, stereo, s16, 192 kb/s
Stream #0:2[0x102]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 104857
kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
[mpegts @ 01C9F940] muxrate VBR, pcr every 2 pkts, sdt every 200, pat/pmt every 40 pkts
Output #0, mpegts, to 'output.ts':
Metadata:
encoder : Lavf54.1.100
Stream #0:0: Video: mpeg2video ([2][0][0][0] / 0x0002), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 104857 kb/s,
25 fps, 90k tbn, 25 tbc
Stream #0:1(spa): Audio: mp2, 48000 Hz, stereo, s16, 128 kb/s
Stream mapping:
Press [q] to stop, ? for help
frame= 45 fps= 0 q=-1.0 Lsize= 2065kB time=00:00:01.76 bitrate=9609.4kbits/s
video:1880kB audio:29kB global headers:0kB muxing overhead 8.196496%
SECOND TEST: Copy ALL Audio tracks into a TS file
COMMAND:
D:\Test Videos>ffmpeg -threads 0 -async 1 -y -i "video.ts" -vcodec copy -c:a copy output.ts
OUTPUT:
ffmpeg version N-37915-g6cb2085 Copyright (c) 2000-2012 the FFmpeg developers
built on Feb 15 2012 20:47:20 with gcc 4.6.2
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-runtime-cpudetect --enable-avisynth --enab
le-bzlib --enable-frei0r --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --en
able-libmp3lame --enable-libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --en
able-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-
libxvid --enable-zlib
libavutil 51. 39.100 / 51. 39.100
libavcodec 54. 3.100 / 54. 3.100
libavformat 54. 1.100 / 54. 1.100
libavdevice 53. 4.100 / 53. 4.100
libavfilter 2. 62.100 / 2. 62.100
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 6.100 / 0. 6.100
libpostproc 52. 0.100 / 52. 0.100
Input #0, mpegts, from 'video.ts':
Duration: 00:00:01.76, start: 1.400000, bitrate: 9903 kb/s
Program 1
Metadata:
service_name : Canal+ Accion HD
service_provider: Canal+ Accion HD
Stream #0:0[0x100](spa): Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, stereo, s16, 192 kb/s
Stream #0:1[0x101](qaa): Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, stereo, s16, 192 kb/s
Stream #0:2[0x102]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 104857
kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
[mpegts @ 035DC020] muxrate VBR, pcr every 2 pkts, sdt every 200, pat/pmt every 40 pkts
Output #0, mpegts, to 'output.ts':
Metadata:
encoder : Lavf54.1.100
Stream #0:0: Video: mpeg2video ([2][0][0][0] / 0x0002), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 104857 kb/s,
25 fps, 90k tbn, 25 tbc
Stream #0:1(spa): Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, stereo, 192 kb/s
Stream mapping:
Press [q] to stop, ? for help
frame= 45 fps= 0 q=-1.0 Lsize= 2080kB time=00:00:01.76 bitrate=9681.1kbits/s
video:1880kB audio:42kB global headers:0kB muxing overhead 8.238927%
THIRD TEST: Copy all audio tracks into a AVI file
COMMAND:
D:\Test Videos>ffmpeg -threads 0 -async 1 -y -i "video.ts" -vcodec copy -c:a copy output.avi
OUTPUT:
ffmpeg version N-37915-g6cb2085 Copyright (c) 2000-2012 the FFmpeg developers
built on Feb 15 2012 20:47:20 with gcc 4.6.2
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-runtime-cpudetect --enable-avisynth --enab
le-bzlib --enable-frei0r --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --en
able-libmp3lame --enable-libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --en
able-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-
libxvid --enable-zlib
libavutil 51. 39.100 / 51. 39.100
libavcodec 54. 3.100 / 54. 3.100
libavformat 54. 1.100 / 54. 1.100
libavdevice 53. 4.100 / 53. 4.100
libavfilter 2. 62.100 / 2. 62.100
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 6.100 / 0. 6.100
libpostproc 52. 0.100 / 52. 0.100
Input #0, mpegts, from 'video.ts':
Duration: 00:00:01.76, start: 1.400000, bitrate: 9903 kb/s
Program 1
Metadata:
service_name : Canal+ Accion HD
service_provider: Canal+ Accion HD
Stream #0:0[0x100](spa): Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, stereo, s16, 192 kb/s
Stream #0:1[0x101](qaa): Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, stereo, s16, 192 kb/s
Stream #0:2[0x102]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 104857
kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
Output #0, avi, to 'output.avi':
Metadata:
ISFT : Lavf54.1.100
Stream #0:0: Video: mpeg2video (mpg2 / 0x3267706D), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 104857 kb/s, 25 f
ps, 50 tbn, 50 tbc
Stream #0:1(spa): Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, stereo, 192 kb/s
Stream mapping:
Press [q] to stop, ? for help
frame= 45 fps= 0 q=-1.0 Lsize= 1935kB time=00:00:01.74 bitrate=9109.0kbits/s
video:1880kB audio:42kB global headers:0kB muxing overhead 0.685256%
Attachments (1)
Change History (14)
by , 13 years ago
comment:1 by , 13 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 by , 13 years ago
It works thanks - according to the documentation this should work but it does not:
ffmpeg -y -i video.ts -c:v:0 copy -c:a:1 copy output.ts
What's wrong with this? isn't the -c:a:1 supposed to select the 2nd audio channel and then apply the codec to it?
comment:4 by , 13 years ago
Sure: The FFMPEG Documentation page: (quoting)
Section 4.1
A stream specifier is a string generally appended to the option name and separated from it by a colon. E.g. -codec:a:1 ac3 option contains a:1 stream specifer, which matches the second audio stream. Therefore it would select the ac3 codec for the second audio stream.
Section 4.4
ffmpeg -i INPUT -map 0 -c copy -c:v:1 libx264 -c:a:137 libvorbis OUTPUT
will copy all the streams except the second video, which will be encoded with libx264, and the 138th audio, which will be encoded with libvorbis.
What i understang from the above is once I select the stream identifier it will apply the following codec to it. Did I get it wrong?
comment:5 by , 13 years ago
Priority: | normal → important |
---|---|
Reproduced by developer: | set |
Resolution: | invalid |
Status: | closed → reopened |
Version: | unspecified → git-master |
Thank you for the explanation, I consider this a serious issue.
comment:6 by , 13 years ago
Okay you're welcome. Does that mean my understand is incorrect or is the documentation incorrect?
Need to know for future reference also if you can help explain how to use/what's the use of c:a:1
comment:7 by , 13 years ago
I suspect nothing is wrong, just badly written for anyone who is not very pedantic.
As I understand it -c:a:1 will set the codec for the second audio stream, but if there is no second audio stream it doesn't matter which codec it has set.
So whether an audio stream is created is independent of whether one exists/is created. Which admittedly leads to the nonsensical case of allowing the user to set a codec for something that doesn't exist.
comment:8 by , 13 years ago
Well in that case I had used it correctlly and this is a bug right. Because the sample I uploaded does have a 2nd audio stream but it is not copying it when I used this command.
I noticed you reopened the ticket. Thanks.
comment:9 by , 13 years ago
No, I meant your output file does not have a second audio stream because you never told ffmpeg to create one. If it doesn't exist it doesn't matter which codec it has set.
I'd certainly be in favour of making the behaviour more user-friendly though.
comment:10 by , 13 years ago
I'm a little confused here. The input file had 2 audio streams. I asked ffmpeg to select the 2nd stream (c:a:1) and apply the copy codec to it.
Isn't that what I did?
comment:11 by , 13 years ago
I asked ffmpeg to select the 2nd stream (c:a:1) and apply the copy codec to it.
The "apply the copy codec" (to the second audio stream) part yes, but "select the 2nd stream" isn't part of what -c does (the :a:1 does only restrict to which streams -c is applied, it does not do anything _more_ than the -c without any further specifiers; In particular it does not create/select/map/... a stream).
comment:12 by , 13 years ago
got it thanks,
So the c:a:x limits the codec actions to that stream but does nothing to map it, to extract the stream one needs to map it with the map command.
comment:13 by , 13 years ago
Resolution: | → invalid |
---|---|
Status: | reopened → closed |
The correct syntax is
Please reopen if this does not work for you.