Unable to read Qprocess output



  • I am using qprocess to execute command line ffmpeg. when i pass "-help" commant to ffmpeg then this return me results otherwise this show me blank screen.
    Here is my code.
    @#include <QtCore/QCoreApplication>
    #include <QProcess>
    #include <QDebug>
    #include <QTextStream>

    int main(int argc, char *argv[])
    {
    QCoreApplication a(argc, argv);

    QProcess *proc= new QProcess();
    QString line;
    QStringList argumenta= QStringList()<<"-i"<<" a.mp3";
    proc->start("ffmpeg/ffmpeg",argumenta);
    proc->waitForFinished();
    qDebug()<<proc->readAllStandardOutput();
    QTextStream *reader = new QTextStream(proc->readAllStandardOutput());
    while((line=reader->readAll())!=NULL)
    {
        //qDebug()<<line;
    }
    
    return a.exec&#40;&#41;;
    

    }
    @



  • Hi,

    maybe ffmpeg prints on standard error?
    @proc->readAllStandardError()@



  • Might I recommend that you don't use the synchronous API (waitFor...), but use the async API (signals & slots) instead? Note that you can also combine both the output streams by using setProcessChannelMode(QProcess::MergedChannels).



  • Hi ,
    i created slots for this
    @
    QProcess *proc = new QProcess();
    void ffmpeghandler::OnBtnStartClicked()
    {
    QObject parent;

    QString codec = "ffmpeg/ffmpeg";
    QStringList arguments;// = new List<string>();
    arguments<<"-i";
    arguments<<"abc.wmv";
    arguments<<"-acodec";
    arguments<<"mp3";
    arguments<<"abc.mp3";
    proc->execute(codec, arguments);
    

    }

    void ffmpeghandler::OnProcessOutputReady()
    {
    proc->waitForBytesWritten();
    qDebug()<< "Transcoding Done."<< proc->readAllStandardOutput();
    }@

    This is working for the windows but not for the iMac OSX. I am using OSX build for MAC(ffmpeg) and for windows i am using (ffmpeg.exe).
    Is there is any other way to to this.

    This code is working for the MAC.
    @proc->startDetached(codec, arguments);
    proc->waitForFinished();
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.