Running command line action through C# script

For a project I need to load in video files from the computer. However, as Unity does not support any other format besides “ogg” (right?), I will have to convert the videos from .mp4 to .ogg first. To do this I found ffmpeg that I can simply call from the command line and then it converts the video nicely.

However I would now like to automate this process by running that command line script dynamically from the Unity game itself, so the user won’t have to perform any extra actions.

The script I tried to use for this looks like this:

public static void ExecuteCommand (string inputVideo)
        var processInfo = new ProcessStartInfo("cmd.exe", @"ffmpeg -i " + inputVideo + @" -acodec libvorbis -vcodec libtheora -f ogg " + inputVideo.Split('.')[0] + @".ogg");
        processInfo.CreateNoWindow = true;
        processInfo.UseShellExecute = false;

        var process = Process.Start(processInfo);


The problem I have is that it freezes Unity when I run it through this code:

if (dialog.FileName.EndsWith(".mp4"))
            url = dialog.FileName.Split('.')[0] + ".ogg";

Any idea what might fix my problem?

Edit: Platform is Windows in case that could make a difference.

I think that’s because the conversion takes place on the same Thread as Unity’s. For this to be executed parallel to Unity you need to put the task on a seperate thread.

Maybe this is a start:

Is there a way to do this during play mode? My thread keeps getting aborted, likely by Unity.

what if I want the command prompt to run a certain input when I use it. Ideally I want to push a button that will enable command prompt to pull up as a background process with a pre-input text that it responds to and continue to run in the background. How to do that all at a click of a button with c script?

The Command window is used to execute commands or aliases directly in the Visual Studio integrated development environment (IDE). You can execute both menu commands and commands that do not appear on any menu. To display the Command window, choose Other Windows from the View menu, and select Command Window.