C# Windows Forms Using FFMPEG to change video format got no response

问题描述 投票:0回答:0

我正在尝试制作一个 exe 程序来使用 FFMPEG 来更改视频格式,而不是在终端中执行。格式化后的视频将保存在下载文件夹中。我在下面尝试了我的代码,但没有得到任何输出响应。我想知道我是否正确使用了 process() 和 StartInfo,因为我发现的示例和文档让我感到困惑。我仔细检查了 ffmpeg.exe 在 bin 文件夹中,StartInfo() 只是为了获取信息,它在 Process() 下。这就是 Process() 可以访问信息并使用 Start() 启动进程的原因。请帮助并纠正我的理解。 以下是我的部分代码:

private void convertButton_Click(object sender, EventArgs e)
    {
        String input = filepathTextBox.Text;
        String outputResolution = resolutionLabel.Text;
        String output;
        String outputFileType;
        int inputLength = input.Length;
        int l = 0;
        for (int i = (inputLength - 1); inputLength > -1; i--)
        {
            if (input[i] == '.')
            {
                l = i;
                break;
            }
        }
        output = input.Substring(0, l - 1);
        outputFileType = input.Substring(l + 1, inputLength - 1);
        Process process = new Process();
        process.StartInfo.UseShellExecute = true;
        process.StartInfo.FileName = "ffmpeg.exe";
        process.StartInfo.WorkingDirectory = @"C:\Users\User\Downloads\ffmpeg-2023-05-15-git-2953ebe7b6-full_build\bin";
        process.StartInfo.Arguments = "ffmpeg -i" + @"C:\Users\User\Downloads\file_example_MP4_640_3MG.mp4" + "-s 320x240 -r 25 -b:v 500000 -pix_fmt yuv420p -c:v libx264     -vprofile baseline -level  2.1 -x264opts  stitchable=1:level=3.0:keyint=15:ref=1:merange=16:mvrange=32 -acodec pcm_s16le -ar 16000 -ac 1" + @"C:\Users\User\Downloads\440.mp4";
        process.Start();
    }

输出: “myprogram.exe(CoreCLR: clrhost): 已加载‘C:\选项‘仅我的代码’已启用。” 线程 0x79e0 已退出,代码为 0 (0x0)。

c# .net visual-studio-2010 ffmpeg windows-forms-designer
© www.soinside.com 2019 - 2024. All rights reserved.