Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Unable to read Qprocess output
Forum Updated to NodeBB v4.3 + New Features

Unable to read Qprocess output

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 3.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jaswinder
    wrote on last edited by
    #1

    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;;
    

    }
    @

    1 Reply Last reply
    0
    • L Offline
      L Offline
      luca.cossaro
      wrote on last edited by
      #2

      Hi,

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

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        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).

        1 Reply Last reply
        0
        • J Offline
          J Offline
          Jaswinder
          wrote on last edited by
          #4

          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();
          @

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved