[Solved]Arguments formatting when calling ffmpeg from QProcess



  • Hi,
    I am trying to call a command line program (ffmpeg) from my Widgets Qt application.The program is starting but the arguments are not being passed correctly(The window is disappearing before I can see what is going wrong).
    The command I want pass is:

    ffmpeg.exe -i video1.avi video.wmv

    (All is working fine when I call it myself from the command line).
    Can anyone suggest a way I can get my arguments interpreted correctly by Qt?The relevant code to the question is shown below.

    Thank you for your time.

    @
    QString program1="ffmpeg.exe";

      QStringList arguments;
      arguments << "-i"<< "video.avi" << "video.wmv";
    
      QProcess *myProcess = new QProcess(this);
      if(myProcess->startDetached(program1,arguments))
          ui->pushButton->setText("YOUR PROGRAM STARTED.");//for debugging purposes.
    

    @


  • Lifetime Qt Champion

    Hi,

    It should be something like:

    @
    arguments << "-i" << "video1.avi" << "video.wmv";
    @

    However relative path to the video files might be a bad idea



  • Thank you ,
    I resolved to using full paths:
    @
    QString program1="D:\ffmpeg\bin\ffmpeg.exe";

      arguments << "-i"<< "D:\\ffmpeg\\bin\\ohm.avi" <<"-r"<<"24" <<"D:\\ffmpeg\\bin\\output.flv";
    

    @

    and it is working fine now.


  • Lifetime Qt Champion

    You're welcome !

    Depending on how you intend to use your program you might better offer a configuration option to set the path to ffmpeg rather than hardcode it.

    Since it's working now, don't forget to update the thread title prepending [solved] so other forum users may know a solution has been found :)


Log in to reply
 

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