gpt4 book ai didi

video - UWP运行ffmpeg进程捕获

转载 作者:行者123 更新时间:2023-12-04 22:48:19 25 4
gpt4 key购买 nike

我正在用 C# 开发一个 UWP 应用程序,我需要在一个进程中启动 FFmpeg。

我用这个ffmpeg在 CMD 中运行良好的命令:

D:\ffmpeg.exe -f dshow -crossbar_video_input_pin_number 1 -i video="AVerMedia BDA Analog Capture" -vcodec rawvideo -pix_fmt yuv420p -s 864x768 -r 10 "D:\capture\output.yuv" -loglevel 16



但是,当我在我的 UWP 应用程序中使用相同的命令和参数启动该过程时,我从 ffmpeg 收到此错误:

[dshow @ 000001bd43907e80] Unable to BindToObject for AVerMedia BDA Analog Capture [dshow @ 000001bd43907e80] Could not find video device with name [AVerMedia BDA Analog Capture] among source devices of type video. video=AVerMedia BDA Analog Capture: I/O error



这是我的代码:
        string filename = @"D:\ffmpeg.exe";
string arg = " -f dshow -crossbar_video_input_pin_number [VIDEOPIN] -i video=\"AVerMedia BDA Analog Capture\" -vcodec rawvideo -pix_fmt [PIXELCONF] -s [SIZE] -r [FPS] \"[FOLDER]\\[VIDEONAME]\" -loglevel 16";
arg = path.Text;
if (!File.Exists(filename))
System.Diagnostics.Debug.WriteLine("Not exist ffmpeg");



arg = arg.Replace("[VIDEOPIN]", "1");
arg = arg.Replace("[VIDEODEVICE]", "AVerMedia BDA Analog Capture");
arg = arg.Replace("[PIXELCONF]", "yuv420p");
arg = arg.Replace("[SIZE]", "864x768");
arg = arg.Replace("[FPS]", "10");
arg = arg.Replace("[FOLDER]", "D:\\capture");
arg = arg.Replace("[VIDEONAME]", "output.yuv");

ProcessStartInfo pi = new ProcessStartInfo(filename, arg);
System.Diagnostics.Debug.WriteLine(pi.FileName + " " + pi.Arguments.ToString());
pi.RedirectStandardInput = true;
pi.RedirectStandardOutput = true;
pi.RedirectStandardError = true;
pi.UseShellExecute = false;

pi.CreateNoWindow = true;
process = new Process();
process.StartInfo = pi;
process.EnableRaisingEvents = true;
process.OutputDataReceived += new DataReceivedEventHandler(MyProcOutputHandler);
process.ErrorDataReceived += new DataReceivedEventHandler(MyProcErrorHandler);
process.Exited += new EventHandler(ExitedProcess);



process.Start();
process.BeginErrorReadLine();
process.BeginOutputReadLine();

编辑:这就是我所拥有的:

ffmpeg -list_devices true -f dshow -i dummy

ffmpeg version N-90054-g474194a8d0 Copyright (c) 2000-2018 the FFmpeg developers built with gcc 7.2.0 (GCC) configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libmfx --enable-amf --enable-cuda --enable-cuvid --enable-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth libavutil 56. 7.101 / 56. 7.101 libavcodec 58. 11.101 / 58. 11.101 libavformat 58. 9.100 / 58. 9.100 libavdevice 58. 1.100 / 58. 1.100 libavfilter 7. 12.100 / 7. 12.100 libswscale 5. 0.101 / 5. 0.101 libswresample 3. 0.101 / 3. 0.101 libpostproc 55. 0.100 / 55. 0.100 [dshow @ 0000029065b07940] DirectShow video devices (some may be both video and audio devices) [dshow @ 0000029065b07940] "AVerMedia BDA Analog Capture" [dshow @ 0000029065b07940] Alternative name "@device_pnp_\?\pci#ven_1a0a&dev_6202&subsys_620f1461&rev_01#4&3632f028&0&00e6#{65e8773d-8f56-11d0-a3b9-00a0c9223196}{ca465100-deb0-4d59-818f-8c477184adf6}" [dshow @ 0000029065b07940] "AVerMedia BDA Analog Capture Secondary" [dshow @ 0000029065b07940] Alternative name "@device_pnp_\?\pci#ven_1a0a&dev_6202&subsys_620f1461&rev_01#4&3632f028&0&00e6#{65e8773d-8f56-11d0-a3b9-00a0c9223196}{ede957b0-eaa5-4bf4-acf3-6e10cb4836c3}" [dshow @ 0000029065b07940] DirectShow audio devices [dshow @ 0000029065b07940] Could not enumerate audio only devices (or none found). dummy: Immediate exit requested

最佳答案

UWP 应用在沙盒中运行。该 exe 需要在您的应用程序包中,您需要使用 FullTrustProcessLauncher 启动它如果您希望它以从操作系统读取 directshow 信息的权限运行。我认为您无法使用它来捕获输出文本,但您可以使用 ffmpeg save the output to a text file在您的包裹的 TemporaryFolder 中,然后阅读它。

此外,如果您想在 UWP 应用程序中仅将 ffmpeg 用于 A/V 播放或帧捕获,您应该查看此 project .

关于video - UWP运行ffmpeg进程捕获,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48814611/

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