0

Using avprobe to examine one ts file i have this:

Input #0, mpegts, from '/tmp/file.ts':
  Duration: 00:00:17.06, start: 82902.417489, bitrate: 3533kb/s
  Program 30601
  Program 30602
  Program 30603
  Program 30604
  Program 30605
  Program 30606
  Program 30607
  Program 30608
  Program 30609
  Program 30610
  Program 30611
    Stream #0.0[0xa0]: Video: mpeg2video (Main), yuv420p, 720x576 [PAR 64:45 DAR 16:9], 7647 kb/s, 25 fps, 90k tbn, 50 tbc
    Stream #0.1[0x50](spa): Audio: mp2, 48000 Hz, 2 channels, s16p, 128 kb/s (clean effects)
    Stream #0.2[0x51](dos): Audio: mp2, 48000 Hz, 2 channels, s16p, 128 kb/s (clean effects)
    Stream #0.3[0xd0]: Data: [192][0][0][0] / 0x00C0
    Stream #0.4[0xde]: Data: [192][0][0][0] / 0x00C0
    Stream #0.5[0xd5]: Data: [193][0][0][0] / 0x00C1
    Stream #0.6[0xfd]: Data: [193][0][0][0] / 0x00C1
    Stream #0.7[0x133]: Data: [193][0][0][0] / 0x00C1
    Stream #0.8[0x164]: Data: [193][0][0][0] / 0x00C1
    Stream #0.9[0x188]: Data: [193][0][0][0] / 0x00C1
    Stream #0.10[0x135]: Data: [192][0][0][0] / 0x00C0
    Stream #0.11[0x276]: Data: [193][0][0][0] / 0x00C1
    Stream #0.12[0x378]: Data: [193][0][0][0] / 0x00C1
  Program 30612

I am testing this command to transcode to mp4 over the network one test ts file and it works fine but using default video and audio stream of program 30611:

gst-launch-1.0 filesrc location=/tmp/file.ts ! \
tsdemux program-number=30611 name=demux demux. ! \
queue ! \
mpegvideoparse ! \
omxmpeg2videodec ! \
queue ! \
omxh264enc ! \
video/x-h264,stream-format=byte-stream,profile=high,framerate=25/1 ! \
h264parse config-interval=1 ! \
mpegtsmux name=mux ! \
tcpserversink host=ipaddress port=port demux. ! \
queue ! \
mpegaudioparse ! \
mpg123audiodec ! \
audioconvert dithering=0 ! \
audio/x-raw,channels=1 ! \
avenc_mp2 bitrate=32768 ! \
mux.

But i would like to select first or second audio stream. I can't find on documentation or internet how to do it. Could you help me please?

Jorge Palanques
  • 63
  • 1
  • 10
  • Did you take a look at https://gstreamer.freedesktop.org/documentation/additional/design/stream-selection.html?gi-language=c ? – Florian Zwoch Jun 18 '20 at 20:21
  • Yes i found and read it. But i am not programming with gstreamer, i am only playing with gst-launch to understand a little how it works. If i find how to select audio stream i will post it here. Thanks! – Jorge Palanques Jun 19 '20 at 18:38
  • gst-launch is a small helper for testing. There are tons on features unavailble to you then. You should start an application, it can be python too. – Florian Zwoch Jun 20 '20 at 10:10
  • Hi Florian! After testing i found the way to select audio and video stream on gst-launch-1.0. Do i have to post it in comments, on my first question or in option Answer your question? Thanks! – Jorge Palanques Jun 21 '20 at 14:55
  • I think its perfectly fine to answer your own question and accept it as answer. (I would like to know the answer too) – Florian Zwoch Jun 21 '20 at 18:10

1 Answers1

0

This worked on my raspberry pi 2 with mpeg2 hardware decoder license enabled, you have to buy code license:

nohup gst-launch-1.0 filesrc location=/tmp/file.ts ! \
tsdemux name=demux demux.${VIDEOSELTXT} ! \
queue ! \
mpegvideoparse ! \
omxmpeg2videodec ! 
queue ! 
omxh264enc ! 
video/x-h264,stream-format=byte-stream,profile=high,width=360,height=288,framerate=25/1 ! 
h264parse config-interval=1 ! 
mpegtsmux name=mux ! 
tcpserversink host=${IP2LISTEN} port=${PORT2LISTEN} demux.${AUDIOSELTXT} ! 
queue ! 
mpegaudioparse ! 
mpg123audiodec ! 
audioconvert dithering=0 ! \
audio/x-raw,channels=1 ! \
avenc_mp2 bitrate=32768 ! \
mux. > /tmp/sal.log &

On our previous example change video variable:

VIDEOSELTXT for video_00a0

and audio variable:

AUDIOSELTXT for audio_0050 to spa audio stream
            for audio_0051 to dos audio stream

On my tests it is only working using four numbers for audio and video stream, following examples are not working fine:

audio_00050
audio_50
Jorge Palanques
  • 63
  • 1
  • 10