-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem when using x264enc + mpegtsmux #96
Comments
From what I can see the problem is that in the pipeline without the
But when I add the interpipe it gets 2 segment events, the 1st without the x264 offset and the 2nd with:
And then the |
I don't know if the problem is in the interpipesrc or the mpegtsmux, so I have also created this: https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/issues/1637 |
Reply from gstreamer community:
|
Send all queued events with "timestamp < buffer timestamp" instead of just the 1st one before sending the buffer. Only the 1st event of the event queue with "timestamp < buffer timestamp" was being send before the buffer. But there could be several events in the queue that should sent before the buffer. Fixes RidgeRun#96 The segment event was not being handled properly when using x264enc + mpegtsmux together with interpipesrc/sink. Which was causing 2 segment to be delivered to the mpegtsmux: 1st one generated by the interpipesrc (starting from zero) because no segment existed. 2nd coming from the x264 encoder (correcting the 1000 hours offset added by the encoder). The 1st segment resulted in all subsequent DTS being seen as invalid (backwards) by the muxer. This happened because the event queue contained the following: stream-start, segment, tag, tag, tag. All with timestamp 0. But only the stream-start was sent, then the 1st buffer, then the segment. Which caused the DTS issues.
Hi @mariannasb thanks for your detailed report. Indeed it a problem with interpipes. The problem, as you described, is caused because, currently, the interpipesrc does not configure the segment from the interpipesink. This will cause problems when the timestamps come in a different time base, as with your x264enc. The reason the x264enc uses timestamps starting on 1000 is to allow the encoder to add "negative" timestamps (B-frames may, for example, have such negative timestamps). To work this out, GStreamer configures configures the segment to start on that time, so everything works as it should. It only makes sense to continue using this same segment in the interpipesink. Allow me coordinate this fix internally and assign someone to this. |
PR #97 is a potential fix for this report. |
I have found out late Friday that event though PR #97 improves this problem it is unfortunately not a completely fix, it only shifts the problem. With the fix I can see that However I can see that an extra segment (with a wrong position of 0) is still being generated, and coming afterwards. I haven't succeeded in tracking where it is coming from, who is generating it and why (since there is already a proper segment).
|
From what I could find it seems like the segment gets created by the https://gitlab.freedesktop.org/gstreamer/gstreamer/-/blob/master/libs/gst/base/gstbasesrc.c#L1823
Still no idea on how to "cancel" this segment since we got the proper one from |
My best guess at the moment is that you are missing calling the https://github.com/RidgeRun/gst-interpipe/blob/master/gst/interpipe/gstinterpipesrc.c#L463 https://gitlab.freedesktop.org/gstreamer/gstreamer/-/blob/master/libs/gst/base/gstbasesrc.c#L1570 So I have created #98 which does some of the segment handling from |
It was missing something like what is done in appsrc->create(): https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/blob/master/gst-libs/gst/app/gstappsrc.c#L1676 Related to RidgeRun#96
So #98 makes this work:
However if I split it into 3 different pipelines it stops working again.
So I have tracked the problem to here: https://github.com/RidgeRun/gst-interpipe/blob/master/gst/interpipe/gstinterpipesrc.c#L723 I have now added a fix for that as well in #98 |
Send all queued events with "timestamp < buffer timestamp" instead of just the 1st one before sending the buffer. Only the 1st event of the event queue with "timestamp < buffer timestamp" was being send before the buffer. But there could be several events in the queue that should sent before the buffer. Fixes RidgeRun#96 The segment event was not being handled properly when using x264enc + mpegtsmux together with interpipesrc/sink. Which was causing 2 segment to be delivered to the mpegtsmux: 1st one generated by the interpipesrc (starting from zero) because no segment existed. 2nd coming from the x264 encoder (correcting the 1000 hours offset added by the encoder). The 1st segment resulted in all subsequent DTS being seen as invalid (backwards) by the muxer. This happened because the event queue contained the following: stream-start, segment, tag, tag, tag. All with timestamp 0. But only the stream-start was sent, then the 1st buffer, then the segment. Which caused the DTS issues.
It was missing something like what is done in appsrc->create(): https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/blob/master/gst-libs/gst/app/gstappsrc.c#L1676 Related to RidgeRun#96
Send all queued events with "timestamp < buffer timestamp" instead of just the 1st one before sending the buffer. Only the 1st event of the event queue with "timestamp < buffer timestamp" was being send before the buffer. But there could be several events in the queue that should sent before the buffer. Fixes RidgeRun#96 The segment event was not being handled properly when using x264enc + mpegtsmux together with interpipesrc/sink. Which was causing 2 segment to be delivered to the mpegtsmux: 1st one generated by the interpipesrc (starting from zero) because no segment existed. 2nd coming from the x264 encoder (correcting the 1000 hours offset added by the encoder). The 1st segment resulted in all subsequent DTS being seen as invalid (backwards) by the muxer. This happened because the event queue contained the following: stream-start, segment, tag, tag, tag. All with timestamp 0. But only the stream-start was sent, then the 1st buffer, then the segment. Which caused the DTS issues.
It was missing something like what is done in appsrc->create(): https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/blob/master/gst-libs/gst/app/gstappsrc.c#L1676 Related to RidgeRun#96
Consider the following pipeline which encodes to H264, muxes to MPEG-TS and the streams over UDP
Receive with :
vlc rtp://@:7000
orWorks fine
Now if I add interpipesrc/sink in between:
Doesn't work and I get a lot of complains about backwards DTS:
0:00:00.729042661 192147 0x56175b8f50c0 WARN basetsmux gstbasetsmux.c:1608:gst_base_ts_mux_clip:<mux:sink_0> ignoring DTS going backward
I believe it is somehow related to problems with handling the SEGMENT, since x264enc adds an 1000 hours offset and sends a new SEGMENT event.
If I refuse events it then works:
But if I try to add audio it doesn't anymore:
Which I guess is because the timestamps of audio and video are 1000 hours apart...
And if I then change the video interpipesrc to restart-ts I can get it working again:
Note that the same pipeline (with audio) works without the interpipesrc/sinks:
So, here there is no problem, even though the timestamp difference also exists here.
The text was updated successfully, but these errors were encountered: