Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QProcess::setStandardOutputFile only creates 0kb File

I'm using a simple QProcess-Project on a WindowsXP-Machine:

QString program = "U:\\ffmpeg.exe";
QStringList arguments;
arguments << "-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?

like image 478
Berschi Avatar asked Nov 24 '25 09:11

Berschi


1 Answers

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.

like image 124
P Shved Avatar answered Nov 28 '25 15:11

P Shved



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!