[Kde-bindings] C#, Qyoto, Qt - How to read output from QProcess?
linuxoidoz at yahoo.com.au
linuxoidoz at yahoo.com.au
Mon Feb 22 08:38:21 UTC 2010
I've done a bit more investigation and it looks like 'readyReadStandardOutput()' doesn't fire even though the output is available.
Here's my code:
Connect(proc, SIGNAL("readyReadStandardOutput()"), this, SLOT("OnProcessOutputReady()"));
Connect(btnStart, SIGNAL("clicked()"), this, SLOT("OnBtnStartClicked()"));
[Q_SLOT]
private void OnBtnStartClicked() {
QProcess proc = new QProcess(this);
string codec = "ffmpeg";
List<string> arguments = new List<string>();
arguments.Add("-i");
arguments.Add("video.avi"); // <- this file is actually selected with an open file dialog
arguments.Add("video.mkv"); // <- this file is actually selected with an open file dialog
proc.Start(codec, arguments);
proc.WaitForFinished();
QByteArray cmdoutput = proc.ReadAllStandardOutput();
String txtoutput = cmdoutput.ConstData();
this.txtLog.Append(txtoutput);
cmdoutput = proc.ReadAllStandardError();
txtoutput = cmdoutput.ConstData();
this.txtLog.Append(txtoutput);
}
[Q_SLOT]
private void OnProcessOutputReady() {
QMessageBox.About(this, "About", "Process Output Ready");
}
and the code does work, the file does get converted and some of the ffmpeg output does get displayed in the txtLog:
"FFmpeg version UNKNOWN, Copyright (c) 2000-2010 Fabrice Bellard, et al.
built on Feb 6 2010 12:16:08 with gcc 4.4.1 [gcc-4_4-branch revision 150839]
configuration: --shlibdir=/usr/lib64 --prefix=/usr --mandir=/usr/share/man --libdir=/usr/lib64 --enable-shared --enable-libmp3lame --enable-libvorbis --enable-libtheora --enable-libspeex --enable-libfaad --enable-libfaac --enable-nonfree --enable-libxvid --enable-postproc --enable-gpl --enable-x11grab --enable-libschroedinger --enable-libdirac --enable-libgsm --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-libdc1394 --enable-pthreads
libavutil 50. 8. 0 / 50. 8. 0
libavcodec 52.52. 0 / 52.52. 0
libavformat 52.50. 0 / 52.50. 0
libavdevice 52. 2. 0 / 52. 2. 0
libswscale 0.10. 0 / 0.10. 0
libpostproc 51. 2. 0 / 51. 2. 0
Input #0, avi, from '/home/linuxoid/Temp/video.avi':
Duration: 00:00:09.00, start: 0.000000, bitrate: 554 kb/s
Stream #0.0: Video: msvideo1, rgb555le, 160x100, 10 tbr, 10 tbn, 10 tbc
Output #0, matroska, to '/home/linuxoid/Temp/video.mkv':
Stream #0.0: Video: mpeg4, yuv420p, 160x100, q=2-31, 200 kb/s, 1k tbn, 10 tbc
Stream mapping:
Stream #0.0 -> #0.0
Press [q] to stop encoding
frame= 90 fps= 0 q=2.9 Lsize= 268kB time=9.00 bitrate= 243.6kbits/s
video:266kB audio:0kB global headers:0kB muxing overhead 0.471088%"
Do you know why the 'readyReadStandardOutput()' doesn't trigger? Any suggestions on how to display the rest of the output? Thank you.
More information about the Kde-bindings
mailing list