[Ffmpeg-devel] counting Frames
Patrick Fischer
patrick_fischer
Wed Jul 13 12:04:15 CEST 2005
I have a Problem with counting Frames.
This part Code seems to works fine but the Framecounter shows different
Framenumbers then avidemux or Mainactor.
My algo shows ~23000 proceded Frames, but avidemux and Mainactor shows
me ~25000 Frames.
After upto 10 Frame the first Frame is missing.
What has happen?
sFrame VideoStream::getNextFrame() {
int found = 0 ;
while(av_read_frame(pFormatCtx, &packet)>=0 && !found ) {
// Is this a packet from the video stream?
if(packet.stream_index==videoStream) {
// Decode video frame
avcodec_decode_video(pCodecCtx, pFrame, &frameFinished,
packet.data, packet.size);
// Did we get a video frame?
if(frameFinished) {
currentFrameNumber++;
// Convert the image from its native format to Gray
......
av_free_packet(&packet);
found = 1;
}
}
// Free the packet that was allocated by av_read_frame
av_free_packet(&packet);
}
sFrame frame;
*frame.data = *pFrameGRAY->data;
if(firstFrame) {
firstFrame=0;
frame.number = pCodecCtx->frame_number;
} else {
//frame.number = currentFrameNumber;
frame.number = pCodecCtx->frame_number-firstPTS;
}
return frame;
}
More information about the ffmpeg-devel
mailing list