Discussion:
[FFmpeg-user] How to map specific audio channels in MPTS stream
Ilir Pruthi
2014-09-13 07:27:28 UTC
Permalink
Hello,

I am receiving an MPTS stream where each Program has multiple audio tracks.
Only one of the audio tracks works, the others are 0-channels, thus dead
audio tracks. FFmpeg is giving me trouble because of those dead audio
tracks.

This is the partial MPTS stream output, showing just 2 of the programs:

Program 11
Metadata:
service_name : 20.1
service_provider: Tandberg
Stream #0:9[0x65]: Video: h264 (Main) ([27][0][0][0] / 0x001B),
yuv420p(tv, bt470bg), 704x576 [SAR 12:11 DAR 4:3], 25 fps, 50 tbr, 90k tbn,
50 tbc
Stream #0:28[0x101](mkd): Audio: mp2 ([4][0][0][0] / 0x0004), 48000 Hz,
stereo, s16p, 379 kb/s
Stream #0:13[0x111](spa): Audio: mp3 ([6][0][0][0] / 0x0006), 0
channels, s16p
Stream #0:10[0x115]: Audio: mp3 ([6][0][0][0] / 0x0006), 0 channels,
s16p
Program 12
Metadata:
service_name : 20.2
service_provider: Tandberg
Stream #0:6[0x1fcc]: Video: h264 (Main) ([27][0][0][0] / 0x001B),
yuv420p(tv, bt470bg), 704x576 [SAR 12:11 DAR 4:3], 25 fps, 50 tbr, 90k tbn,
50 tbc
Stream #0:7[0x100](mkd): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz,
stereo, s16p, 189 kb/s
Stream #0:8[0x1fcd]: Audio: mp3 ([6][0][0][0] / 0x0006), 0 channels,
s16p


The FFmpeg commands I tried are:
$ ffmpeg -i "udp://@MY_IP_ADDRESS:XXXX?overrun_nonfatal=1&reuse=1" -map
0:p:11 -map 0:28 -vcodec libx264 -acodec copy -t 30 -f mpegts -y
program11.ts

But I get this error:
[mpegts @ 0x33a94e0] sample rate not set
Could not write header for output file #0 (incorrect codec parameters ?):
Invalid argument

I receive same error when I leave only the first -map parameter.

Can someone please show me how to use -map to pick only the working audio
tracks (in this case: mp2)?

Thank you in advance.

-Ilir
Carl Eugen Hoyos
2014-09-13 19:28:38 UTC
Permalink
$ ffmpeg -i "udp:// <at> MY_IP_ADDRESS:XXXX?overrun_nonfatal=1&reuse=1"
-map 0:p:11 -map 0:28 -vcodec libx264 -acodec copy
-t 30 -f mpegts -y program11.ts
Please provide your command line together with the
complete, uncut console output (sensible information
cut if necessary).

Allow me to add what I often write here:
I believe FFmpeg may not be the right tool for this
task. If all you want to do is save a transport stream
use mplayer -dumpstream or even better just pipe the
stream into a file. FFmpeg may fail on a reception
error and damage your recording.
Once you made the recording, you can use FFmpeg to
change resolution etc. if needed.

Carl Eugen
Ilir Pruthi
2014-09-13 22:12:08 UTC
Permalink
Post by Carl Eugen Hoyos
$ ffmpeg -i "udp:// <at> MY_IP_ADDRESS:XXXX?overrun_nonfatal=1&reuse=1"
-map 0:p:11 -map 0:28 -vcodec libx264 -acodec copy
-t 30 -f mpegts -y program11.ts
Please provide your command line together with the
complete, uncut console output (sensible information
cut if necessary).
I believe FFmpeg may not be the right tool for this
task. If all you want to do is save a transport stream
use mplayer -dumpstream or even better just pipe the
stream into a file. FFmpeg may fail on a reception
error and damage your recording.
Once you made the recording, you can use FFmpeg to
change resolution etc. if needed.
Hello Carl and thank you for replying.

The MPTS stream was "fixed" after I requested from sending party to modify
the MPTS so it does not contain dead tracks. Unfortunately, I have not
saved the full output and cannot reproduce it now. But the last message was
that FFmpeg could not continue decoding because of the multiple broken
audio tracks in each program. That's why I thought it's possible to select
tracks via FFmpeg's -map parameter.

Theoretically, however, do you know if/how to achieve the following in
FFmpeg:
* For each program, select specific video and audio track and copy them to
a UDP port

Would you happen to know the correct -map notation to achieve this?

Thank you for your time and help.

-Ilir
Post by Carl Eugen Hoyos
Carl Eugen
_______________________________________________
ffmpeg-user mailing list
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Qianliang Zhang
2014-09-16 01:37:56 UTC
Permalink
Maybe you can try -map index, like:

Stream #0:6[0x1fcc]: Video: h264 (Main) ([27][0][0][0] / 0x001B),
yuv420p(tv, bt470bg), 704x576 [SAR 12:11 DAR 4:3], 25 fps, 50 tbr, 90k tbn,
50 tbc
Stream #0:7[0x100](mkd): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz,
stereo, s16p, 189 kb/s
Stream #0:8[0x1fcd]: Audio: mp3 ([6][0][0][0] / 0x0006), 0 channels,
s16p

-map 0:6 -vcodec copy -map 0:7 -acodec libfaac
Post by Ilir Pruthi
Post by Carl Eugen Hoyos
$ ffmpeg -i "udp:// <at> MY_IP_ADDRESS:XXXX?overrun_nonfatal=1&reuse=1"
-map 0:p:11 -map 0:28 -vcodec libx264 -acodec copy
-t 30 -f mpegts -y program11.ts
Please provide your command line together with the
complete, uncut console output (sensible information
cut if necessary).
I believe FFmpeg may not be the right tool for this
task. If all you want to do is save a transport stream
use mplayer -dumpstream or even better just pipe the
stream into a file. FFmpeg may fail on a reception
error and damage your recording.
Once you made the recording, you can use FFmpeg to
change resolution etc. if needed.
Hello Carl and thank you for replying.
The MPTS stream was "fixed" after I requested from sending party to modify
the MPTS so it does not contain dead tracks. Unfortunately, I have not
saved the full output and cannot reproduce it now. But the last message was
that FFmpeg could not continue decoding because of the multiple broken
audio tracks in each program. That's why I thought it's possible to select
tracks via FFmpeg's -map parameter.
Theoretically, however, do you know if/how to achieve the following in
* For each program, select specific video and audio track and copy them to
a UDP port
Would you happen to know the correct -map notation to achieve this?
Thank you for your time and help.
-Ilir
Post by Carl Eugen Hoyos
Carl Eugen
_______________________________________________
ffmpeg-user mailing list
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
_______________________________________________
ffmpeg-user mailing list
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Loading...