2
我有一个代码,(应)给我使用ffmpeg每次调用另一帧。我的问题是,它始终是相同的帧,我解码...C++ ffmpeg:总是一样的框架?
有人可以告诉我,我在这里失踪了什么?
bool nextFrameFound = false;
while(!nextFrameFound)
{
AVPacket pkt;
int err = av_read_frame(ctx, &pkt);
if (err < 0)
{
break;
system("Pause");
exit(2);
}
if (pkt.stream_index == strm)
{
int got = 0;
AVFrame * frame = av_frame_alloc();
int videoFrameBytes = avcodec_decode_video2(codecCtx, frame, &got, &pkt);
if (got)
{
AVFrame * rgbFrame = av_frame_alloc();
avpicture_alloc((AVPicture *)rgbFrame, AV_PIX_FMT_RGB24, codecCtx->width, codecCtx->height);
sws_scale(swCtx, frame->data, frame->linesize, 0, frame->height, rgbFrame->data, rgbFrame->linesize);
for (int i = 0; i < codecCtx->height; i++)
{
char * data = (char*)rgbFrame->data[0] + i*rgbFrame->linesize[0];
//process data
}
nextFrameFound = true;
avcodec_close(codecCtx);
}
av_free_packet(&pkt);
}
}
avformat_network_deinit();
我想,这是在使用的ffmpeg一个missunderstanding,但我不能帮助自己:(
感谢您的帮助
如果它总是帧,它应该在for循环中......你确定要访问'rgbFrame-> data [0]'有史以来的时间吗? – hgiesel
我认为,该rgbFrame只在我的视频帧,而不是一个视频序列 – 3DExtended
所有其他数据项为零,所以这不是问题 – 3DExtended