RidgeRun / gst-interpipe

GStreamer plug-in for interpipeline communication
Other
143 stars 64 forks source link

Switch interpipesrc with MPEG-TS data between live and filesrc #88

Closed mariannasb closed 3 years ago

mariannasb commented 3 years ago

Hi, I'm doing something similar to https://github.com/RidgeRun/gst-interpipe/issues/74 however I use H264 encoded data (in a MPEG-TS container).

The idea is to have several live sources (from UDP) and the possibility of replay from a file. All data is H264 encoded and packed in a MPEG-TS (with the possibility of audio included).

In the final solution the file source pipeline will only be started when needed and will be SEEK'ed to the proper position.

But for testing purposes I'm using a simplified setup where the file is set to loop and all pipelines go to PLAYING from the start.

pipelines.append("videotestsrc is-live=true pattern=ball ! video/x-raw,framerate=30/1,format=NV12 ! timeoverlay ! "
                 "tee name=t ! queue ! videoconvert ! ximagesink sync=0 "
                 "t. ! queue ! x264enc key-int-max=30 speed-preset=1 tune=zerolatency ! video/x-h264,profile=high ! mpegtsmux ! interpipesink name=vtest1 sync=false async=false ")

pipelines.append("videotestsrc is-live=true ! video/x-raw,framerate=30/1,format=NV12 ! timeoverlay ! "
                 "tee name=t ! queue ! videoconvert ! ximagesink sync=0 "
                 "t. ! queue ! x264enc key-int-max=30 speed-preset=1 tune=zerolatency ! video/x-h264,profile=high ! mpegtsmux ! interpipesink name=vtest2 sync=false async=false ")

pipelines.append("multifilesrc loop=1 name=replay location=/home/msb/test.ts ! identity sync=true ! "
                 "tee name=t ! queue ! "
                 "tsdemux : identity sync=true ! h264parse ! avdec_h264 ! videoconvert ! ximagesink sync=0 "
                 "t. ! queue ! interpipesink name=vreplay sync=true async=false")

pipelines.append("interpipesrc listen-to=vtest1 name=vselect is-live=true stream-sync=passthrough-ts ! "
                 "tsdemux : identity sync=true ! h264parse ! avdec_h264 ! videoconvert ! textoverlay text=out ! ximagesink sync=0 ")

And for the test file:

gst-launch-1.0 videotestsrc is-live=true pattern=ball num-buffers=300 !
video/x-raw,framerate=30/1,format=NV12 ! timeoverlay ! x264enc
key-int-max=30 speed-preset=1 tune=zerolatency ! video/x-h264,profile=high !
mpegtsmux ! filesink location=test.ts -v -e

If the interpipesrc is set to listen-to=vtest1 from the start then I can change between vtest1 and vtest2 without any issues. But if I try to change to vreplay the output stalls. And I don't seem to get any error/warning/debug from the interpipe elements. I can change back to vtest1/vtest2.

If I change tsdemux : identity sync=true ! h264parse ! avdec_h264 ! videoconvert ! textoverlay text=out ! ximagesink sync=0 to simply fakesink dump=1 I can see that there is no data coming at all when changing listen-to to vreplay

If I start with listen-to=vreplay it plays fine, but trying to change to vtest1/vtest2 doesn't have any effect, the stream from vreplay keeps being displayed.

I have tried demuxing the stream to operate on the h264 stream directly, but get somewhat similar behavior, and would actually like to be able to use the muxed data in order to avoid audio synchronization issues in the future.

mariannasb commented 3 years ago

Depending on the specific test scenario I'm getting such warnings:

0:00:04.258268211 1332980 0x7f29f039b980 WARN            videodecoder gstvideodecoder.c:2909:gst_video_decoder_prepare_finish_frame:<avdec_h264-1> decreasing timestamp (0:00:03.591666666 < 1000:00:04.133333333)

The 1000 hours difference is very strange for me...

Update: from what I can read it seems that this 1000 hours offset is something that was added in gstreamer 1.6 in order to be able to handle negative timestamps. But seems to only be present in encoded streams?

So maybe it is something that the interpipesrc/sink is not handling properly?

michaelgruner commented 3 years ago

This problem is the same as reported on #96, let's continue over there.