I'm using a simple QProcess-Project on a WindowsXP-Machine:
QString program = "U:\\ffmpeg.exe";
QStringList arguments;
argu开发者_如何学JAVAments << "-i" << "U:\\clock.avi" << "U:\\tmp_jpeg\\foo-%03d.jpeg";
process.setStandardOutputFile("U:\\log.txt", QIODevice::Append);
process.start(program, arguments);
The Process works just fine, ffmpeg creates all the files i want to. But the log-File keeps completely empty. The same happens when I want to write the standard-output at qDebug()... Why does this happen and how can I fix it?
This happens because usually processes print into two files: "standard output" file and "standard error" file. Programmer can manually decide which file to output to (they're accessed via std::cout
and std::cerr
). The rule of thumb is to print to stdout the actual result of the program, and to stderr - errors, diagnostics etc.
I run ffmpeg and it so happens, that it prints nothing to stdout (probably, reserving it for special mode, where encoded file is printed there), and all text messages are printed to stderr. So you should use setStandardErrorFile()
function to capture the output.
精彩评论