mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 02:01:12 +00:00
avdemux: fix negative pts if start_time is bigger than the ts
The start time is supposed to be the ts of the first frame. FFmpeg uses fractions to represent timestamps and the start time may use a different base than the frame pts. So we may end up having the start time bigger than the pts because of rounding when converting to gst ts. See https://gitlab.freedesktop.org/gstreamer/gst-libav/issues/51 for details.
This commit is contained in:
parent
1e01f2764b
commit
1d293764e5
1 changed files with 8 additions and 2 deletions
|
@ -1473,8 +1473,14 @@ gst_ffmpegdemux_loop (GstFFMpegDemux * demux)
|
|||
goto drop;
|
||||
#endif
|
||||
|
||||
if (GST_CLOCK_TIME_IS_VALID (timestamp))
|
||||
timestamp -= demux->start_time;
|
||||
if (GST_CLOCK_TIME_IS_VALID (timestamp)) {
|
||||
/* start_time should be the ts of the first frame but it may actually be
|
||||
* higher because of rounding when converting to gst ts. */
|
||||
if (demux->start_time >= timestamp)
|
||||
timestamp = 0;
|
||||
else
|
||||
timestamp -= demux->start_time;
|
||||
}
|
||||
|
||||
/* check if we ran outside of the segment */
|
||||
if (demux->segment.stop != -1 && timestamp > demux->segment.stop)
|
||||
|
|
Loading…
Reference in a new issue