Я пытаюсь реализовать функцию, которая может получить следующий кадр, но когда я вызываю эту функцию в 3-й раз
int ret = decoder.get_next_frame(mat);
ret = decoder.get_next_frame(mat);
ret = decoder.get_next_frame(mat); // error
ffmpeg avcodec_send_packet return errи сообщение будет [h264 @ 0x8bd2780] Неверный размер блока NAL (10848> 766).[h264 @ 0x8bd2780] Ошибка разделения входа на блоки NAL.переменная с префиксом '_' - все члены var
int VideoDecoder::get_next_frame(cv::Mat& mat) {
int ret = 0;
bool got_frame = false;
while (!got_frame && av_read_frame(_p_fmt_ctx, _p_packet) >= 0) {
if (_p_packet->stream_index == _video_stream_index) {
ret = avcodec_send_packet(_p_dec_ctx, _p_packet);
if (ret < 0 || ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
break;
}
while (ret >= 0) {
ret = avcodec_receive_frame(_p_dec_ctx, _p_frame);
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
break;
}
sws_scale(_p_img_convert_ctx, _p_frame->data, _p_frame->linesize,
0, _p_dec_ctx->height, _p_frame_rgb->data, _p_frame_rgb->linesize);
mat = cv::Mat(_p_frame->height, _p_frame->width, CV_8UC3, _p_frame_rgb->data[0]);
got_frame = true;
}
}
av_packet_unref(_p_packet);
}
if (got_frame) {
return _p_dec_ctx->frame_number;
}
return 0;
}
, так в чем же проблема?