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.
_______________________________________________
Libav-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/libav-user

Reply via email to