USB摄像头还可以,但我想用的是一台名为"无他伴侣(竖屏)“的”虚拟相机“,它的视频来自安卓或iOS等智能手机。将手机连接到PC,在手机上运行应用程序,然后运行PC客户端应用程序,该应用程序可以预览视频。它的网站是https://www.wuta-cam.com/,手机应用程序名为"无他相机",PC应用程序名为"无他伴侣“。
我在Windows命令行中用ffmpeg -list_devices true -f dshow -i dummy命令运行了FFmpeg,可以列出设备。(为了正确显示中文,请提前运行chcp 65001。)
运行ffplay -f dshow -i video="无他伴侣(竖屏)"命令,即可播放视频(当然需要提前确认其PC客户端预览无误)。
现在我想从我的程序中的虚拟摄像机中获得解码的帧,我用video=无他伴侣(竖屏)调用avformat_open_input(),它失败了,返回值是-5,I/O错误。
有人知道原因吗?请帮帮忙。提前谢谢。
下面是我的代码片段。
avdevice_register_all();
avcodec_register_all();
//const char * url= "video=Logitech Webcam C930e";// This is fine.
char url[] = "video=无他伴侣(竖屏)";// This is bad.
AVFormatContext *pFmtCtx = avformat_alloc_context();
AVInputFormat *iformat = av_find_input_format("dshow");
int nRet = 0;
nRet = avformat_open_input(&pFmtCtx, url, iformat, NULL);
if (nRet)
{
const size_t buffer_size = 256;
char err_description[buffer_size];
av_strerror(nRet, err_description, buffer_size);
printf("%s.\n", err_description);// --> I/O error.
printf("FAILED to open input.(Line:%d,%d)\n", __LINE__, nRet);
return -1;
}发布于 2020-05-09 12:05:21
FFmpeg不能直接处理中文字符。如果设备名称包含中文聊天字符,FFmpeg将报告找不到具有给定名称的设备。我尝试了Windows API函数WideCharToMultiByte(),它可以工作。
https://stackoverflow.com/questions/61476316
复制相似问题