I am executing the below ffmpeg
command for trimming videos.The issue I am having is that if filepath contains spaces then the command fails.I tried many ways to ha
//Process ffmpeg;
public string exec(string input, string output, string parametri,string fileName)
{
//Create the output and streamreader to get the output
string output1 = null; StreamReader srOutput = null;
input = addQuotes(input);
Process ffmpeg = new Process();
try
{
ffmpeg.StartInfo.Arguments = " -i " + input + " -ss 00:00:00.100 -vframes 1" + " " + output;
ffmpeg.StartInfo.FileName = fileName;
ffmpeg.StartInfo.UseShellExecute = false;
ffmpeg.StartInfo.RedirectStandardOutput = true;
ffmpeg.StartInfo.RedirectStandardError = true;
ffmpeg.StartInfo.CreateNoWindow = true;
ffmpeg.Start();
ffmpeg.WaitForExit();
//get the output
srOutput = ffmpeg.StandardError;
//now put it in a string
output1 = srOutput.ReadToEnd();
ffmpeg.Close();
}
catch
{
ffmpeg.Close();
output = string.Empty;
}
finally
{
//now, if we succeded, close out the streamreader
if (srOutput != null)
{
srOutput.Close();
srOutput.Dispose();
}
}
return output;
}
public string addQuotes(string s)
{
return "\"" + s + "\"";
}
You must switch to string-array variant of Runtime.exec(), as described in ffmpeg-android-java.
For the adventurous, there is a hidden trick in ffmpeg, but IMHO working with String[] is both easier and more robust.