2
votes

I'm developing a UWP app with C# and I need to start FFmpeg in a process.

I use this ffmpeg command which works good in 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

But when I start the process with the same command and arguments in my UWP app I get this error from 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

This is my code:

        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();

EDIT: This is what i have with:

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

1
are you running your app under the same user?Devstr
Try running ffmpeg -list_devices true -f dshow -i dummy inside the app to see what devices are availableDevstr
Yes, i am running my app with the same user (or i guess). The command line: ffmpeg -list_devices true -f dshow -i dummy show me the list of device and my deivce appear.InspiracvionV
If i try this simple line: ffmpeg -i input.mp4 output.avi. Ffmpeg said that permission denied (even the file input.mp4 exist).InspiracvionV
can you please post the output of ffmpeg -list_devices true -f dshow -i dummy when run from inside your UWP app?Devstr

1 Answers

2
votes

UWP apps run in a sandbox. The exe needs to be in your app package, and you need to launch it with the FullTrustProcessLauncher if you want it to run with permission to read directshow information from the OS. I don't think you'll be able to capture the output text using this but you could have ffmpeg save the output to a text file in your package's TemporaryFolder and then read it.

Also if you ever want to use ffmpeg just for A/V playback or frame catpure in a UWP app, you should check out this project.