Discussion:
[Libav-user] Inconsistent dts/pts in packets read by av_read_frame from rtsp stream. Is it expected behavior?
JC Yang
2018-10-24 13:41:25 UTC
Permalink
While I'm using av_read_frame to extract frames from some rtsp stream from IP cameras, the dts/pts of the next frame occasionally will be smaller than the previous frames. Yet the doc of av_read_frame hasn't indicated whether any dts-out-of-order should be expected. Is it a bug of libav or a P frame or maybe there's a bug in the IP cameras' rtsp implementation? If that's expected, in order to to correctly handle it/mux it with av_interleave_write_frame, I have to cache and reorder those frames before write, do I? If this is not expected and it's probably a bug in the camera's rtsp codes, then I should discard the consequent frames with smaller dts when I mux it to avoid non increasing dts, should I?

Any guides/explanation or help are welcome.
Thanks in advance.

Get Outlook for Android<https://aka.ms/ghei36>
Hristo Ivanov
2018-10-24 14:08:57 UTC
Permalink
Hi Yang,

> While I'm using av_read_frame to extract frames from some rtsp stream
from IP cameras, the dts/pts of the next frame occasionally will be smaller
than the previous frames.
Currently I am facing the same problem.

> Is it a bug of libav or a P frame or maybe there's a bug in the IP
cameras' rtsp implementation?
I doubt this being a bug with libav, but I can not tell if it is a bug in
the IP cameras or something inherited from the rtsp protocol itself.

> then I should discard the consequent frames with smaller dts when I mux
it to avoid non increasing dts, should I?
Currently my solution to this problem does exactly this, but ffmpeg(the
tool) uses other solution, which is to modify the pts/dts values. [
https://github.com/FFmpeg/FFmpeg/blob/master/fftools/ffmpeg.c#L782 ]
My current solution works fine, but I will try the one ffmpeg uses.

I hope this helps.
JC Yang
2018-10-26 14:09:50 UTC
Permalink
Thanks, Ivanov.
I'll stick to my current solution now.
Same as you, will further consider the way ffmpeg workaround it in the future.

Get Outlook for Android<https://aka.ms/ghei36>

________________________________
From: Libav-user <libav-user-***@ffmpeg.org> on behalf of Hristo Ivanov <***@gmail.com>
Sent: Wednesday, October 24, 2018 10:08:57 PM
To: This list is about using libavcodec, libavformat, libavutil, libavdevice and libavfilter.
Subject: Re: [Libav-user] Inconsistent dts/pts in packets read by av_read_frame from rtsp stream. Is it expected behavior?

Hi Yang,

> While I'm using av_read_frame to extract frames from some rtsp stream from IP cameras, the dts/pts of the next frame occasionally will be smaller than the previous frames.
Currently I am facing the same problem.

> Is it a bug of libav or a P frame or maybe there's a bug in the IP cameras' rtsp implementation?
I doubt this being a bug with libav, but I can not tell if it is a bug in the IP cameras or something inherited from the rtsp protocol itself.

> then I should discard the consequent frames with smaller dts when I mux it to avoid non increasing dts, should I?
Currently my solution to this problem does exactly this, but ffmpeg(the tool) uses other solution, which is to modify the pts/dts values. [ https://github.com/FFmpeg/FFmpeg/blob/master/fftools/ffmpeg.c#L782 ]
My current solution works fine, but I will try the one ffmpeg uses.

I hope this helps.
Loading...