I have a class that loads video frames from a file and displays them in a
window. The preview is silent, I only show video. I need to update a slider
like the one video players have. I don't know where to get information I
need. All the fields I could use like AVFrame.pts
or AVFrame.display_picture_number and AVStream.nb_frames are filled with
zeroes.
I use this code to get new frames for my preview.
AVFrame* pInPicture;
int nProgressPercentage = -1;
.....
bool NextFrame()
{
AVPacket packet;
int frame_finished;
int frames_passed = 0;
for (;;)
{
int ret = av_read_frame(m_pFormatCtx, &packet);
if (ret < 0) // likely reached EOF
return false;
// Is this a packet from the video stream?
if(packet.stream_index == nVideoStream)
{
// Decode video frame
avcodec_decode_video(m_pCodecCtx, pInPicture, &frame_finished,
packet.data, packet.size);
// Did we get a video frame?
if (frame_finished)
{
// cleanup
av_free_packet(&packet);
nProgressPercentage = ???;
// return what we found
return true;
}
}
// Free the packet that was allocated by av_read_frame
av_free_packet(&packet);
}
}
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user