Merge two MPEG-TS streams with higher bitrate

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Merge two MPEG-TS streams with higher bitrate

hrbaty
Hi.

I'm quite new to GStreamer. I have an input MPEG-TS stream with a low bitrate. I need to stuff it with NULL packets to make it higher (of course all the data like PCR must be adjusted).

1. I was thinking about merging my original stream with the one, filled with null packets, but with target bitrate. Is there as some straightforward solution for that? I was thinking about something like: 
      filesrc location=in.ts  ! ...some magic here... !  mpegtsmux bitrate=51253960 ! filesink location=out.ts
I have tried some variations but couldn't setup a working pipeline so far.

2. Maybe there is a simpler and obvious solution I'm missing here.

BR,
Rafal

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Merge two MPEG-TS streams with higher bitrate

Mathieu Duponchelle
mpegtsmux now has support for CBR as you've noticed (the bitrate property), so
it should simply be a matter of remuxing the input file indeed.

If you want to do this from the command line, the command line will need to
match the streams contained in your input file, so it's not possible for us to
give you a working pipeline :)

It should more or less look like:

mpegtsmux bitrate=<bitrate> name=mux ! filesink location=<path> filesrc location=<path> ! tsdemux name=demux \
  demux.sink_%d ! <parser> ! queue ! mux.
  <repeat above for every stream in the input file>

--
Mathieu Duponchelle · https://www.centricular.com

On 9/18/19 5:58 PM, Rafal Garbat wrote:
Hi.

I'm quite new to GStreamer. I have an input MPEG-TS stream with a low bitrate. I need to stuff it with NULL packets to make it higher (of course all the data like PCR must be adjusted).

1. I was thinking about merging my original stream with the one, filled with null packets, but with target bitrate. Is there as some straightforward solution for that? I was thinking about something like: 
      filesrc location=in.ts  ! ...some magic here... !  mpegtsmux bitrate=51253960 ! filesink location=out.ts
I have tried some variations but couldn't setup a working pipeline so far.

2. Maybe there is a simpler and obvious solution I'm missing here.

BR,
Rafal

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Merge two MPEG-TS streams with higher bitrate

hrbaty
Hi Mathieu.

Thank you for the quick anwer.
The content of the ts file is as follows:
  container: MPEG-2 Transport Stream
    audio: MPEG-1 Layer 2 (MP2)
    subtitles: DVB subtitles
    audio: MPEG-1 Layer 2 (MP2)
    video: MPEG-2 Video (Main Profile)

I have tried the example you gave, but I'm getting errors like:
```
WARNING: from element /GstPipeline:pipeline0/GstTSDemux:demux: Delayed linking failed.
Additional debug info:
./grammar.y(510): gst_parse_no_more_pads (): /GstPipeline:pipeline0/GstTSDemux:demux:
failed delayed linking pad  sink_0 of GstTSDemux named demux to some pad of GstQueue named queue0
```

Is that related to wrong parser I was using (mpegvideoparse) ? Do I really need to parse it before remuxing?

Additionally, the example TS file is just for a testing purposes, in a real world I'll be getting MPEG-TS without a priori knowledge what kind of streams are there, therefore a static pipeline won't do the trick here. Is the only way to dynamically connect a parsers (if they are needed) to write an app with adding pad ad hoc as the type of stream is know?

Regards,
R
 

śr., 18 wrz 2019 o 18:15 Mathieu Duponchelle <[hidden email]> napisał(a):
mpegtsmux now has support for CBR as you've noticed (the bitrate property), so
it should simply be a matter of remuxing the input file indeed.

If you want to do this from the command line, the command line will need to
match the streams contained in your input file, so it's not possible for us to
give you a working pipeline :)

It should more or less look like:

mpegtsmux bitrate=<bitrate> name=mux ! filesink location=<path> filesrc location=<path> ! tsdemux name=demux \
  demux.sink_%d ! <parser> ! queue ! mux.
  <repeat above for every stream in the input file>

--
Mathieu Duponchelle · https://www.centricular.com

On 9/18/19 5:58 PM, Rafal Garbat wrote:
Hi.

I'm quite new to GStreamer. I have an input MPEG-TS stream with a low bitrate. I need to stuff it with NULL packets to make it higher (of course all the data like PCR must be adjusted).

1. I was thinking about merging my original stream with the one, filled with null packets, but with target bitrate. Is there as some straightforward solution for that? I was thinking about something like: 
      filesrc location=in.ts  ! ...some magic here... !  mpegtsmux bitrate=51253960 ! filesink location=out.ts
I have tried some variations but couldn't setup a working pipeline so far.

2. Maybe there is a simpler and obvious solution I'm missing here.

BR,
Rafal

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Merge two MPEG-TS streams with higher bitrate

Mathieu Duponchelle
tsdemux doesn't number its pads starting from 0, instead it names them according to
the PID of the streams. From the command line you can get away with not explicitly
naming the pads:

demux. ! <parser> ! queue ! mux.

The parser is necessary for most stream types because mpegtsmux expects
parsed streams, check the output of gst-inspect-1.0 mpegtsmux .

If you need to transmux TS files containing arbitrary streams, you should definitely
write an application. You don't have to write it in C however, python and rust are
also options.

--
Mathieu Duponchelle · https://www.centricular.com

On 9/18/19 6:54 PM, Rafal Garbat wrote:
Hi Mathieu.

Thank you for the quick anwer.
The content of the ts file is as follows:
  container: MPEG-2 Transport Stream
    audio: MPEG-1 Layer 2 (MP2)
    subtitles: DVB subtitles
    audio: MPEG-1 Layer 2 (MP2)
    video: MPEG-2 Video (Main Profile)

I have tried the example you gave, but I'm getting errors like:
```
WARNING: from element /GstPipeline:pipeline0/GstTSDemux:demux: Delayed linking failed.
Additional debug info:
./grammar.y(510): gst_parse_no_more_pads (): /GstPipeline:pipeline0/GstTSDemux:demux:
failed delayed linking pad  sink_0 of GstTSDemux named demux to some pad of GstQueue named queue0
```

Is that related to wrong parser I was using (mpegvideoparse) ? Do I really need to parse it before remuxing?

Additionally, the example TS file is just for a testing purposes, in a real world I'll be getting MPEG-TS without a priori knowledge what kind of streams are there, therefore a static pipeline won't do the trick here. Is the only way to dynamically connect a parsers (if they are needed) to write an app with adding pad ad hoc as the type of stream is know?

Regards,
R
 

śr., 18 wrz 2019 o 18:15 Mathieu Duponchelle <[hidden email]> napisał(a):
mpegtsmux now has support for CBR as you've noticed (the bitrate property), so
it should simply be a matter of remuxing the input file indeed.

If you want to do this from the command line, the command line will need to
match the streams contained in your input file, so it's not possible for us to
give you a working pipeline :)

It should more or less look like:

mpegtsmux bitrate=<bitrate> name=mux ! filesink location=<path> filesrc location=<path> ! tsdemux name=demux \
  demux.sink_%d ! <parser> ! queue ! mux.
  <repeat above for every stream in the input file>

--
Mathieu Duponchelle · https://www.centricular.com

On 9/18/19 5:58 PM, Rafal Garbat wrote:
Hi.

I'm quite new to GStreamer. I have an input MPEG-TS stream with a low bitrate. I need to stuff it with NULL packets to make it higher (of course all the data like PCR must be adjusted).

1. I was thinking about merging my original stream with the one, filled with null packets, but with target bitrate. Is there as some straightforward solution for that? I was thinking about something like: 
      filesrc location=in.ts  ! ...some magic here... !  mpegtsmux bitrate=51253960 ! filesink location=out.ts
I have tried some variations but couldn't setup a working pipeline so far.

2. Maybe there is a simpler and obvious solution I'm missing here.

BR,
Rafal

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Merge two MPEG-TS streams with higher bitrate

hrbaty
Hi Mathieu.

Thank you very much. This got me process further.
One more question: is there a appropriate (all -in-one) video and audio parser to use without pads naming (I use `mpegvideoparse`, but - as expected - I got only video stream)?

BR,
Rafal

śr., 18 wrz 2019 o 19:21 Mathieu Duponchelle <[hidden email]> napisał(a):
tsdemux doesn't number its pads starting from 0, instead it names them according to
the PID of the streams. From the command line you can get away with not explicitly
naming the pads:

demux. ! <parser> ! queue ! mux.

The parser is necessary for most stream types because mpegtsmux expects
parsed streams, check the output of gst-inspect-1.0 mpegtsmux .

If you need to transmux TS files containing arbitrary streams, you should definitely
write an application. You don't have to write it in C however, python and rust are
also options.

--
Mathieu Duponchelle · https://www.centricular.com

On 9/18/19 6:54 PM, Rafal Garbat wrote:
Hi Mathieu.

Thank you for the quick anwer.
The content of the ts file is as follows:
  container: MPEG-2 Transport Stream
    audio: MPEG-1 Layer 2 (MP2)
    subtitles: DVB subtitles
    audio: MPEG-1 Layer 2 (MP2)
    video: MPEG-2 Video (Main Profile)

I have tried the example you gave, but I'm getting errors like:
```
WARNING: from element /GstPipeline:pipeline0/GstTSDemux:demux: Delayed linking failed.
Additional debug info:
./grammar.y(510): gst_parse_no_more_pads (): /GstPipeline:pipeline0/GstTSDemux:demux:
failed delayed linking pad  sink_0 of GstTSDemux named demux to some pad of GstQueue named queue0
```

Is that related to wrong parser I was using (mpegvideoparse) ? Do I really need to parse it before remuxing?

Additionally, the example TS file is just for a testing purposes, in a real world I'll be getting MPEG-TS without a priori knowledge what kind of streams are there, therefore a static pipeline won't do the trick here. Is the only way to dynamically connect a parsers (if they are needed) to write an app with adding pad ad hoc as the type of stream is know?

Regards,
R
 

śr., 18 wrz 2019 o 18:15 Mathieu Duponchelle <[hidden email]> napisał(a):
mpegtsmux now has support for CBR as you've noticed (the bitrate property), so
it should simply be a matter of remuxing the input file indeed.

If you want to do this from the command line, the command line will need to
match the streams contained in your input file, so it's not possible for us to
give you a working pipeline :)

It should more or less look like:

mpegtsmux bitrate=<bitrate> name=mux ! filesink location=<path> filesrc location=<path> ! tsdemux name=demux \
  demux.sink_%d ! <parser> ! queue ! mux.
  <repeat above for every stream in the input file>

--
Mathieu Duponchelle · https://www.centricular.com

On 9/18/19 5:58 PM, Rafal Garbat wrote:
Hi.

I'm quite new to GStreamer. I have an input MPEG-TS stream with a low bitrate. I need to stuff it with NULL packets to make it higher (of course all the data like PCR must be adjusted).

1. I was thinking about merging my original stream with the one, filled with null packets, but with target bitrate. Is there as some straightforward solution for that? I was thinking about something like: 
      filesrc location=in.ts  ! ...some magic here... !  mpegtsmux bitrate=51253960 ! filesink location=out.ts
I have tried some variations but couldn't setup a working pipeline so far.

2. Maybe there is a simpler and obvious solution I'm missing here.

BR,
Rafal

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Merge two MPEG-TS streams with higher bitrate

hrbaty
Hm, I almost got my example working with the pipeline:
`gst-launch-1.0 -e  mpegtsmux bitrate=51253960 name=mux ! filesink location=out.ts  filesrc location=in.ts   ! tsdemux emit-stats=true name=demux  \
demux. ! mpegvideoparse ! queue ! mux. \
demux. ! mpegaudioparse ! queue ! mux. \
demux. ! mpegaudioparse ! queue ! mux. \
demux. ! 'subpicture/x-dvb' ! dvbsuboverlay enable=true name=r! queue  ! mux.`

except the subtitles - when I added this subpipe my pipeline stucks in PREROLLING state. Is that something related to queues being out of sync?
Regards

pon., 23 wrz 2019 o 11:51 Rafal Garbat <[hidden email]> napisał(a):
Hi Mathieu.

Thank you very much. This got me process further.
One more question: is there a appropriate (all -in-one) video and audio parser to use without pads naming (I use `mpegvideoparse`, but - as expected - I got only video stream)?

BR,
Rafal

śr., 18 wrz 2019 o 19:21 Mathieu Duponchelle <[hidden email]> napisał(a):
tsdemux doesn't number its pads starting from 0, instead it names them according to
the PID of the streams. From the command line you can get away with not explicitly
naming the pads:

demux. ! <parser> ! queue ! mux.

The parser is necessary for most stream types because mpegtsmux expects
parsed streams, check the output of gst-inspect-1.0 mpegtsmux .

If you need to transmux TS files containing arbitrary streams, you should definitely
write an application. You don't have to write it in C however, python and rust are
also options.

--
Mathieu Duponchelle · https://www.centricular.com

On 9/18/19 6:54 PM, Rafal Garbat wrote:
Hi Mathieu.

Thank you for the quick anwer.
The content of the ts file is as follows:
  container: MPEG-2 Transport Stream
    audio: MPEG-1 Layer 2 (MP2)
    subtitles: DVB subtitles
    audio: MPEG-1 Layer 2 (MP2)
    video: MPEG-2 Video (Main Profile)

I have tried the example you gave, but I'm getting errors like:
```
WARNING: from element /GstPipeline:pipeline0/GstTSDemux:demux: Delayed linking failed.
Additional debug info:
./grammar.y(510): gst_parse_no_more_pads (): /GstPipeline:pipeline0/GstTSDemux:demux:
failed delayed linking pad  sink_0 of GstTSDemux named demux to some pad of GstQueue named queue0
```

Is that related to wrong parser I was using (mpegvideoparse) ? Do I really need to parse it before remuxing?

Additionally, the example TS file is just for a testing purposes, in a real world I'll be getting MPEG-TS without a priori knowledge what kind of streams are there, therefore a static pipeline won't do the trick here. Is the only way to dynamically connect a parsers (if they are needed) to write an app with adding pad ad hoc as the type of stream is know?

Regards,
R
 

śr., 18 wrz 2019 o 18:15 Mathieu Duponchelle <[hidden email]> napisał(a):
mpegtsmux now has support for CBR as you've noticed (the bitrate property), so
it should simply be a matter of remuxing the input file indeed.

If you want to do this from the command line, the command line will need to
match the streams contained in your input file, so it's not possible for us to
give you a working pipeline :)

It should more or less look like:

mpegtsmux bitrate=<bitrate> name=mux ! filesink location=<path> filesrc location=<path> ! tsdemux name=demux \
  demux.sink_%d ! <parser> ! queue ! mux.
  <repeat above for every stream in the input file>

--
Mathieu Duponchelle · https://www.centricular.com

On 9/18/19 5:58 PM, Rafal Garbat wrote:
Hi.

I'm quite new to GStreamer. I have an input MPEG-TS stream with a low bitrate. I need to stuff it with NULL packets to make it higher (of course all the data like PCR must be adjusted).

1. I was thinking about merging my original stream with the one, filled with null packets, but with target bitrate. Is there as some straightforward solution for that? I was thinking about something like: 
      filesrc location=in.ts  ! ...some magic here... !  mpegtsmux bitrate=51253960 ! filesink location=out.ts
I have tried some variations but couldn't setup a working pipeline so far.

2. Maybe there is a simpler and obvious solution I'm missing here.

BR,
Rafal

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Merge two MPEG-TS streams with higher bitrate

vandanachadha
I am getting a parse error: no property "bitrate" in element "mpegtsmux0"

gst-launch-1.0  --gst-debug-level=3 dvbsrc  modulation="QAM 256"
frequency=147000000   ! decodebin name=demux demux. ! queue ! audioresample
! audioconvert ! voaacenc ! mux. mpegtsmux bitrate=4692 name=mux  ! filesink
location=commandline.ts demux. ! queue ! videoconvert ! videoscale ! x264enc
bitrate=1258 tune=zerolatency !
video/x-h264,stream-format=byte-stream,profile=high,width=640,height=480,key-int-max=15
! mux.



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Merge two MPEG-TS streams with higher bitrate

Mathieu Duponchelle
The bitrate property was added recently, you are running an
older version of the element.

On 3/25/20 7:17 PM, vandanachadha wrote:

> I am getting a parse error: no property "bitrate" in element "mpegtsmux0"
>
> gst-launch-1.0  --gst-debug-level=3 dvbsrc  modulation="QAM 256"
> frequency=147000000   ! decodebin name=demux demux. ! queue ! audioresample
> ! audioconvert ! voaacenc ! mux. mpegtsmux bitrate=4692 name=mux  ! filesink
> location=commandline.ts demux. ! queue ! videoconvert ! videoscale ! x264enc
> bitrate=1258 tune=zerolatency !
> video/x-h264,stream-format=byte-stream,profile=high,width=640,height=480,key-int-max=15
> ! mux.
>
>
>
> --
> Sent from: http://gstreamer-devel.966125.n4.nabble.com/
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel