[Libav-user] How to get a video with the actual total length?

Object leachong at qq.com
Thu Jun 5 11:02:41 CEST 2014


I have a video with actual total length over 10 seconds. But when I opened it with VFormatContext.duration, it showed that it is only 10 seconds long. And then I tried to get the pts of final frame via seek, but unfortunately, the got_picture is always 0. 

int err;
int ret = av_seek_frame(video_in, -1, INT64_MAX, AVSEEK_FLAG_FRAME);
if (ret < 0)
{
    return -1;
}
avcodec_flush_buffers(video_dec);

err = av_read_frame(video_in, &pkt);
if(err == AVERROR(EAGAIN) || err < 0)
{
    return -1;
}
if (pkt.stream_index == st_video_index)
{
    int got_picture = 0;
    avcodec_decode_video2(video_dec, &frame, &got_picture, &pkt);
    if (got_picture)
    {
        pts = frame.best_effort_timestamp * AV_TIME_BASE_LL * video_stream->time_base.num / video_stream->time_base.den;
    }
}
Is there anybody that has any idea to get the actual total length of the video? Thanks in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20140605/601949ab/attachment.html>


More information about the Libav-user mailing list