gpt4 book ai didi

ffmpeg av_read_frame 返回错误码 -5

转载 作者:行者123 更新时间:2023-12-04 23:21:58 34 4
gpt4 key购买 nike

我使用ffmpeg的dll读取USB摄像头,在控件上显示图片,并将图片保存到文件中。起初,读数正常。可以保存声音和图像。但是读了几分钟后,无法读取数据,av_read_frame返回错误码为-5,相机自动关机。当我去读取相机并保存文件时直接使用ffmpeg.exe,它不会有几个小时的问题。谁能告诉我如何返回 - 5 错误代码以及如何处理它?
ffmpeg 版本是 4.2.3
像这样的代码:

while (1)
{
if ((ret = av_read_frame(m_pVidFmtCtx, dec_pkt)) == 0)
{
ret = avcodec_send_packet(m_pVidFmtCtx->streams[dec_pkt->stream_index]->codec, dec_pkt);
while(ret >= 0)
{
ret = avcodec_receive_frame(m_pVidFmtCtx->streams[dec_pkt->stream_index]->codec, pframe);
sws_scale(img_rgb_ctx, pframe->data, pframe->linesize, 0, cy, dstData, dstLinesize);
var bitmap = new Bitmap(dstWidth, dstHeight, dstLinesize[0], PixelFormat.Format24bppRgb, convertedFrameBufferPtr);
}
}
else
{
printf("Error code: %d", ret); // Here ret is -5
}
}

最佳答案

FFmpeg 错误代码基于 errno 上使用的标准 POSIX 错误代码.但是 FFmpeg 直接返回这些 AVERROR宏,这实际上使它成为一个负数。
所以错误代码 -5 是 AVERROR(EIO) .显然输入/输出有严重问题。

关于ffmpeg av_read_frame 返回错误码 -5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63911900/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com