Hello,

I'm writing an ffmpeg wrapper in C# and Qt and been trying for the past 2 weeks 
to get output from ffmpeg without much luck. I've realised by trial and error 
that it actually outputs into StandardError rather than StandardOutput. But I 
can only get partial output, then it stops and I've got no idea how to get the 
rest. I would greatly appreciate it if any one could please help. Instead of 
opening a console, I'd like to get all ffmpeg output (as if it was running in a 
console) into a text box in real time so that I can also show progress.

Here's my code:

Connect(proc, SIGNAL("readyReadStandardError()"), 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);
}

[Q_SLOT]
private void OnProcessOutputReady() {
        proc.WaitForBytesWritten();
        QByteArray output = proc.ReadAllStandardError();
        String txtoutput = output.ConstData();
        this.txtLog.Append(txtoutput);
}

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%"

Thank you.
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to