我解码使用FFMpeg。我正在解码的视频是使用C代码的H.264或MPEG4视频。我正在使用32位库。我已经成功解码并提取了第一帧的元数据。我现在想解码最后一帧。我有一个确定的视频持续时间,并认为这是一个安全的假设,说isLastFrame = duration
。这是我的,有什么建议吗?如何FFmpeg解码并从最后一帧提取元数据?
AVFormatContext* pFormatCtx = avformat_alloc_context();
avformat_open_input(&pFormatCtx, filename, NULL, NULL);
int64_t duration = pFormatCtx->duration;
i=0;
while(av_read_frame(pFormatCtx, &packet)>=0) {
/* Is this a packet from the video stream? */
if(packet.stream_index==videoStream) {
/* Decode video frame*/
avcodec_decode_video2(pCodecCtx, pFrame, &duration, &packet);
}
任何帮助非常感谢! :)