On Tue, Jun 26, 2012 at 1:11 PM, Simon Daniels <[email protected]> wrote: > Hi Michael -- after reading into things a bit more, I agree that it's risky > what I'm doing. However, I only need about 3 frames per second so maybe > waiting for a key frame isn't the end of the world... > > Is there a safer way? The decoding is extremely expensive so I only want to > do it when I absolutely need to.
I'm not the most knowledgable about this, so someone correct me if I'm wrong/if there's a better way... You've got an H264 stream. H264 streams can have P and B-frames, and both P and B-frames depend on the previous frame to be properly decoded. If you're just skipping frames without decoding them, it's possible (and I'd say quite likely) you'll try and decode a P or B-frame after skipping the previous frame that this frame depended on. The only way I know of to "skip" every X frames is to: decode all the frames, and only use the ones you need, or only decode keyframes (but it's possible there can be a few seconds between two keyframes). AVPacket.flag can be used to know if the packet has a keyframe (check for AV_PKT_FLAG_KEY). _______________________________________________ Libav-user mailing list [email protected] http://ffmpeg.org/mailman/listinfo/libav-user
