0

I have difficult to pass the -vo argument to mplayer using QProcess, Here a minimal example:

MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    QString program;
    program = "C:\\mplayer-svn-38008\\mplayer.exe";

    QStringList arguments;
    arguments << "-vo gl" << "C:\\test.mp4"; 

    QProcess *m_process = new QProcess(this);
    m_process->start(program, arguments);
}

The process outputs:

Unknown option on the command line: -vo gl

using the same argument on Windows shell leads to the correct behavior:

>mplayer -vo gl C:/test.mp4

Also, removing that argument from the QStringList works. Why the -vo option is recognized from command line but not from QProcess?

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Mark
  • 4,338
  • 7
  • 58
  • 120

1 Answers1

3

You have to separate each argument that is separated by a space:

arguments << "-vo"<< "gl" << "C:\\test.mp4"; 
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
  • Ahh, that's finally resolving to a simply typo. How silly not to check using the debugger what's passed to the `arguments`. –  Jan 25 '18 at 20:18
  • Well, I've checked with the debugger and the output string seemed correct: "-vo gl", "C:\\test.mp4" – Mark Jan 25 '18 at 20:27
  • How should I catch the "typo"? – Mark Jan 25 '18 at 20:28
  • 1
    @Mark No, typo is that you were wrong to write it but that is something that Qt do not document. – eyllanesc Jan 25 '18 at 20:30