Click here to Skip to main content
15,890,282 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is a simple code to create ffmpeg log output in a file instead of console.

But this code doesn't create an output log file wherein the same arrangements when used in command prompt it works. Can anybody help in this? what more needs to be done to get the output in the log file?

Regards Arunava

What I have tried:

<pre>string fullPath = "d:";
        string fileName= "wildlife.wmv";
        string pathfile = "D:";
        process.StartInfo.Arguments = "-i \"" + fullPath + "\" + fileName + +\" 2> \"" + pathfile + "\ffmpeglog.log\"";

        process.StartInfo.UseShellExecute = false;
        process.StartInfo.RedirectStandardError = true;
        process.StartInfo.CreateNoWindow = false;
        process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
        process.Start();
        string output2 = process.StandardError.ReadToEnd();
        process.WaitForExit();
        process.Close();
Posted
Updated 9-Nov-17 1:50am

A quick check with your debugger would show you that your parameters are wrong as you have unescaped backslashes in your strings. So the code:
C#
string fullPath = "d:";
        string fileName= "wildlife.wmv";
        string pathfile = "D:";
        process.StartInfo.Arguments = "-i \"" + fullPath + "\" + fileName + +\" 2> \"" + pathfile + "\ffmpeglog.log\"";

results in the string:
process.StartInfo.Arguments =  -i "d:" + fileName + +" 2> "D:fmpeglog.log"

It should be:
C#
process.StartInfo.Arguments = "-i \"" + fullPath + "\\" + fileName + "\" 2> \"" + pathfile + "\\ffmpeglog.log\"";
 
Share this answer
 
Tried with the above code but its not working. When we run ffmpeg with the same code we need to remove the final "\" after ffmpeglog.log to generate the log.
When I am using
" -i \"d:\\wildlife.wmv 2> \"D:\\ffmpeglog.log\""


The log is not generating but cannot remove the "\" from the string since its throwing Newline constant error.

How can I use

" -i \"d:\\wildlife.wmv 2> \"D:\\ffmpeglog.log""


instead of the previous code. Or we need to make some changes in the configuration? Current configuration is as follows.

startProcess.CreateNoWindow = true;
           startProcess.ErrorDialog = false;
           startProcess.UseShellExecute = false;
           startProcess.RedirectStandardOutput = true;
           //startProcess.RedirectStandardError = false;
           startProcess.RedirectStandardError = true;
           startProcess.RedirectStandardInput = true;


Please advise.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900