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

SumLee 0 Reputation points
2023-05-17T15:32:32.92+00:00

I am trying to make an exe program to change a video format by using FFMPEG instead of doing it in the terminal. The formatted video will be saved in the download folder. I have tried my code below and got no output response. I wonder if I used process() and StartInfo correctly, as examples I found and the documentation just confused me. I have double-checked the ffmpeg.exe is in the bin folder and the StartInfo() is just for getting information, which is under Process(). This is why Process() can access the information and use Start() to start the process. Please help and correct my understanding. Below is part of my code:

Output: "myprogram.exe(CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.15\System.Diagnostics.Process.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled." The thread 0x79e0 has exited with code 0 (0x0).


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;
                return;
            }
        }
        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\1280_10MG.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();
    }
.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,962 questions
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,248 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,091 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.