ffmpeg avformat_open_input()无法打开包含汉字的dshow设备url

ffmpeg avformat_open_input()无法打开包含汉字的dshow设备url,ffmpeg,Ffmpeg,USB网络摄像头还可以,但我要使用的设备是一个名为无他伴侣(竖屏)", 其视频来自Android或iOS等智能手机。将手机连接到PC,在手机上运行应用程序,然后运行PC客户端应用程序,该应用程序可以预览视频。手机应用程序称为“无他相机,并调用PC应用程序无他伴侣,其网站为 我在Windows命令行中使用命令FFmpeg-list_devices true-f dshow-I dummy运行FFmpeg,可以列出设备。(为了正确显示中文,请提前运行chcp 65001) 运行命令ffplay-f

USB网络摄像头还可以,但我要使用的设备是一个名为无他伴侣(竖屏)", 其视频来自Android或iOS等智能手机。将手机连接到PC,在手机上运行应用程序,然后运行PC客户端应用程序,该应用程序可以预览视频。手机应用程序称为“无他相机,并调用PC应用程序无他伴侣,其网站为

我在Windows命令行中使用命令
FFmpeg-list_devices true-f dshow-I dummy
运行FFmpeg,可以列出设备。(为了正确显示中文,请提前运行
chcp 65001

运行命令
ffplay-f dshow-i video=”无他伴侣(竖屏)“
,可以播放视频。(当然,您需要事先确认其PC客户端预览正常。)

现在我想从程序中的虚拟摄像机中获取解码帧,我用
视频调用
avformat\u open\u 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;
}

FFmpeg可能无法直接处理中文字符。如果设备名称包含中文聊天符,FFmpeg将报告找不到具有给定名称的设备。我尝试了Windows API函数
wideChartMultiByte()
,它可以工作。

在这里分享你剪下的代码,以便我们更好地理解。我添加了我的代码片段。@thekamilzTry this
wchar\t url[]=L”视频=无他伴侣(竖屏)“
而不是上面(
charurl[]=”视频=无他伴侣(竖屏)“;//这不好
)函数
avformat\u open\u input()
会抱怨
类型为“wchar\u t*”的参数与类型为“const char*”的参数不兼容
无法将参数2从“wchar\u t[15]”转换为“const char*”
@thekamilzI use
wsctombs()
要将宽字符串转换为多字节字符串,此函数成功。但是
avformat\u open\u input()
仍然失败。@thekamilz