I am using ffmpeg commands with C# processes. I used a command to change the audio of a video and it was working but I also wanted to write the output to a text file. The new command works from cmd but apparently, it does not work while using a C# process. The command that does not work with the Process is:
ffmpeg -i videoPath -i audioPath -c:v copy -map 0:v:0 -map 1:a:0 -shortest newVideoPath > textFilePath 2>&1
And the working command is the same without the last part:
ffmpeg -i videoPath -i audioPath -c:v copy -map 0:v:0 -map 1:a:0 -shortest newVideoPath
Here is the C# code:
Process proc = new Process();
proc.StartInfo.FileName = ffmpegPath;
proc.StartInfo.RedirectStandardError = true;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.Arguments = "-i " + videoPath + " -i " + newAudioPath + " -c:v copy" + " -map" + " 0:v:0 " + "-map 1:a:0 " + "-shortest " + newVideoPath + " > " + @"F:\Videos\log.txt"+ " 2>&1";
proc.EnableRaisingEvents = true;
proc.Exited += UpdateVideoSource;
proc.Start();
I checked the arguments over and over again, and looked for missing spaces but nothing worked. What can be the problem?