Reputation: 2323
I've been looking around for this, and Can't seem to find it. I have an RTSP stream that I am pulling from using ffmpeg. Objects at my disposal include an AVPacket, AVFrame, AVCodecContext, and an AVFormatContext . I would like to get the absolute time that a frame was taken at. (ideally with granularity as small as milliseconds, though that's not completely necessary).
Is there an easy way to do this using the ffmpeg libraries? I've looked at av_frame_get_best_effort_timestamp
as well as codec_context->time_base
, but that seems to give the answers in seconds since the beginning of the video, and I don't necessarily know when the video started.
Upvotes: 2
Views: 5555
Reputation: 3305
Use int64_t AVFormatContext::start_time_realtime
, and then add the frame time since the beginning of the stream.
[EDIT]
Also take into account that start_time_realtime
is expressed in milliseconds, while AVFrame::best_effort_timestamp
is expressed in AVStream->time_base units
Upvotes: 2