gstreamer preserve timestamp when encoding ts

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

gstreamer preserve timestamp when encoding ts

gugovind
Hi,
I have a series of ts files(h265) which are part of a m3u8 manifest which are fed into the pipeline through fdsrc. I use the following pipeline to transcode them to H264 to be played on a Hlsjs web browser.

cat 2021-06-30T00-55-41Z_2000000.ts | gst-launch-1.0  -q mpegtsmux name=mux ! fdsink fd=1 fdsrc ! tsdemux name=demux demux. ! queue ! h265parse ! nvh265dec ! videoconvert ! videoscale ! video/x-raw,width=640,height=360 ! nvh264enc ! mux.

The individual ts segments are transcoded successfully and can be played.

However the DTS is out of aligment and when these ts segments are played as part of the hls manifest, it is not able to play as DTS is out of order.

```
[mpegts @ 0x7fb69100a400] DTS 6496420096 < 6496446847 out of order
[hls @ 0x7fb69580ea00] DTS 6496420096 < 6496446847 out of order
```

In FFMPEG we have copyts to preserve the timestamp.
Is there something similar in gstreamer to preserve the timestamp? Or atleast generate a timestamp with the current time so that the player doesnt complain?

I tried fdsrc do-timestamp=true but that didnt work.

I appreciate any help in this.

Best
Reply | Threaded
Open this post in threaded view
|

Re: gstreamer preserve timestamp when encoding ts

Marianna S. Buschle
I don't know if there are any specific properties for this, you can try tsdemux which might have something.

Otherwise you can use a buffer probe and re-timestamp them yourself.
Something like:

def check_pts(self, pad, info, name):
        buf = info.get_buffer()
        info.get_buffer().pts = self.pipeline[0].get_current_running_time()
        return Gst.PadProbeReturn.OK

Reply | Threaded
Open this post in threaded view
|

Re: gstreamer preserve timestamp when encoding ts

gugovind
Thanks for your response Marianna,
I could not find anything helpful in tsdemux. The problem is I am calling the pipeline through command line in golang. I will try to write a custom probe pad and let you know how it works.

Thanks a lot!
Reply | Threaded
Open this post in threaded view
|

Re: gstreamer preserve timestamp when encoding ts

gugovind
Hi Marianna,
I tried setting the PTS values to the pipelines running clock time. However because the buffers arrive at a much faster rate, the DTS values which needs to be sequential and increasing in order and fails in the decoder.

I had to slightly modify it by incrementing it with the current timestamp and the offset value.

It then took it and works.

Thanks a lot for your help.