我想实现这个功能,利用ffmpeg库,对实时rtsp流每一秒截一张图.我自己写了段代码
while(av_read_frame(pAVFormatContext,&pAVPacket) >= 0){
if(pAVPacket.stream_index == videoStreamIndex){
avcodec_decode_video2(pAVCodecContext,pAVFrame,&m_i_frameFinished,&pAVPacket);
if(m_i_frameFinished){
sws_scale(pSwsContext,(const uint8_t* const *)pAVFrame->data,pAVFrame->linesize,0,videoHeight,pAVPicture.data,pAVPicture.linesize);
saveJpeg(&pAVPicture,videoWidth,videoHeight,++index);
}
sleep(1);
}
av_free_packet(&pAVPacket);
}
但是我发现这样写,每25张图,都是同一秒的内容.
有没有哪位大神知道应该怎么做?