GNOME Bugzilla – Bug 772730
avdemux: check if we ran outside of the segment
Last modified: 2018-11-03 12:57:59 UTC
Dear all: I wonder the correctness about the flow within Gstavdemux to check if we ran outside of the segment. Please see the following flow. /* do timestamps, we do this first so that we can know when we * stepped over the segment stop position. */ timestamp = gst_ffmpeg_time_ff_to_gst (pkt.pts, avstream->time_base); if (GST_CLOCK_TIME_IS_VALID (timestamp)) { stream->last_ts = timestamp; } ... if (GST_CLOCK_TIME_IS_VALID (timestamp)) timestamp -= demux->start_time; ... /* check if we ran outside of the segment */ if (demux->segment.stop != -1 && timestamp > demux->segment.stop) goto drop; When we are given the settings below and it means we want to playback P1 B3 B4 only. Presentation order = I1 B1 B2 { P1 B3 B4 } I2 decoding order = I1 P1 B1 B2 I2 B3 B4 PTS of ( I1 B1 B2 P1 B3 B4 I2) = ( 1, 2, 3, 4, 5, 6, 7) DTS of ( I1 B1 B2 P1 B3 B4 I2) = (1, 3, 4, 2, 6, 7, 5) The segment stop is set to "6" accordingly since the PTS of {P1 B3 B4} = ( 4, 5, 6 ). However, notice that the PTS of I2 is "7" which is larger than 6. Also we will demux it before B3 & B4. By the flow : "check if we ran outside of the segment", we will go to the drop label & pause where. The result is we miss the following two B frames, which should be played originally. I think an additional check such as "if we have met the first Key frame whose PTS is greater than segment's stop, go to drop (pause)" will be safe. Thanks.
(In reply to John Chang from comment #0) > I think an additional check such as "if we have met the first Key frame > whose PTS is greater than segment's stop, go to drop (pause)" will be safe. I think that's not necessarily safe either, depending on the codec. Maybe looking at the DTS could help here? Also should check how qtdemux is solving the same issue. Do you want to investigate and propose a patch?
Created attachment 339009 [details] Proposal to fix segment issue Proposal to fix segment issue
Dear Slomo: Could you please help to take a loop to the attached (Proposal to fix segment issue)? It contains 2 proposals & their flowcharts; as well as some execution examples. If you think the proposed flows are correct, we will make the patch later soon. Thank you.
Created attachment 343936 [details] [review] Fix the issue to check if we ran outside of the segment proposed patch to fix; The way to judge is described at the attachment: " Proposal to fix segment issue "; according to flow chart of fig 9.
-- GitLab Migration Automatic Message -- This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gst-libav/issues/29.