[英]FFMPEG C++ av_write_uncoded_frame(out_pFormatCtx, frame_index, pFrameRGB);
我试图找到一种方法将我的 opencv 数据复制到我的 RTMP output stream 解码 ZF7B44CFAFD5C58222E
avcodec_decode_video2。
但是当我使用 ret = av_write_uncoded_frame(out_pFormatCtx, frame_index, pFrameRGB) ;
,我从变量“ret”中得到“-40”错误。
ret = avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished, &packet);// Decode video frame
if (frameFinished)
{
static struct SwsContext* img_convert_ctx;
if (img_convert_ctx == NULL)
{
int w = pCodecCtx->width;
int h = pCodecCtx->height;
img_convert_ctx = sws_getContext(w, h,
pCodecCtx->pix_fmt,
w, h, AV_PIX_FMT_RGB24, 4,
NULL, NULL, NULL);
if (img_convert_ctx == NULL)
{
fprintf(stderr, "Cannot initialize the conversion context!\n");
return -1;
}
}
int ret = sws_scale(img_convert_ctx, pFrame->data, pFrame->linesize, 0, pCodecCtx->height, pFrameRGB->data, pFrameRGB->linesize);
if (ret == 0)
{
fprintf(stderr, "SWS_Scale failed [%d]!\n", ret);
return -2;
}
// Save the frame to disk
if (Save>0)
{
SaveFrame(pFrameRGB, pCodecCtx->width, pCodecCtx->height, frame_index);
}
if (Show > 0)
{
CopyDate(pFrameRGB, pCodecCtx->width, pCodecCtx->height, packet.pts - prepts);
//ret = av_write_uncoded_frame(out_pFormatCtx, frame_index, pFrameRGB);........<<<error -40
if (!out_pFormatCtx->oformat->write_uncoded_frame)
{
return AVERROR(ENOSYS);
}
}
frame_index++;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.