Quantcast
Channel: Questions in topic: "command line"
Viewing all articles
Browse latest Browse all 123

Running command line action through C# script

$
0
0
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); process.WaitForExit(); process.Close(); } The problem I have is that it freezes Unity when I run it through this code: if (dialog.FileName.EndsWith(".mp4")) { ConvertVideo.ExecuteCommand(dialog.FileName); } url = dialog.FileName.Split('.')[0] + ".ogg"; Any idea what might fix my problem? Edit: Platform is Windows in case that could make a difference.

Viewing all articles
Browse latest Browse all 123

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>