[Libav-user] Save frame to jpg with data from avcodec_decode_video2

Simon Daniels simondaniels23 at gmail.com
Tue Jun 26 08:18:51 CEST 2012


Hey guys,

I'm walking through frames of a video to do some analysis on the pixel
data. I'd like to save each frame as an image so I can verify the analysis
algorithm is running on the expected data.

I don't want to use the ffmpeg command-line to save out the frames because
for some reason the frame counts are not matching. Ffmpeg.exe saves more
frame jpegs than avcodec_decode_video2 seems to find.

Here's my code:


while (av_read_frame(pFormatCtx, &packet) >= 0)
{

// Is this a packet from the video stream?
if (packet.stream_index == videoStreamIndex &&
(frameLocation++ % frameSkip == 0)
)
{
 // Decode video frame
avcodec_decode_video2(pCodecCtx, pFrameYUV, &isFrameFinished, &packet);

// Did we get a video frame?
if (isFrameFinished) {

             // I'D LIKE TO SAVE FRAME AS A JPEG HERE

}

}
}


This is with ffmpeg 0.11.1.

Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20120625/4fd5c867/attachment.html>


More information about the Libav-user mailing list