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. QProcess: invalid arguments
Forum Updated to NodeBB v4.3 + New Features

QProcess: invalid arguments

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 4 Posters 1.0k Views 4 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.
  • C Offline
    C Offline
    cdwijs
    wrote on last edited by
    #1

    Hi All,

    I'm working on a rasperry pi running rasperian, with Qt Creator 4.2.0 based on Qt 5.7.1
    I'm trying to start the external process "raspivid -o file.h264". I've written the following code snippet:

    void ExternalCamera::slotStartCapture(QString filename)
    {
        QStringList arguments;
    
        arguments <<"-o file.h264";
    
    
        myProcess->setArguments(arguments);
        myProcess->setProgram("/usr/bin/raspivid");
    
        myProcess->start();
        myProcess->waitForFinished(20000);
        qDebug()<<myProcess->exitCode();
        qDebug()<<myProcess->errorString();
    
    
    }
    

    Then I see this in the applications output window:

    "Invalid command line option (-o file.h264)\n"
    64
    "Unknown error"
    

    What am I doing wrong?
    Cheers,
    Cedric

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      can you try
      arguments <<"-o" << "file.h264";

      C 1 Reply Last reply
      2
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        As @mrjj as well as QProcess's documentation, each element of the options should be put in the argument list separately.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        2
        • mrjjM mrjj

          Hi
          can you try
          arguments <<"-o" << "file.h264";

          C Offline
          C Offline
          cdwijs
          wrote on last edited by
          #4

          @mrjj said in QProcess: invalid arguments:

          arguments <<"-o" << "file.h264";

          It works, Thank you. For future reference:

          void ExternalCamera::slotStartCapture(QString filename)
          {
              QStringList arguments;
              arguments <<"-o" << "file.h264";
              //arguments <<"-o file.h264";
          
          
              myProcess->setArguments(arguments);
              myProcess->setProgram("/usr/bin/raspivid");
          
              myProcess->start();
              myProcess->waitForFinished(20000);
              qDebug()<<myProcess->exitCode();
              qDebug()<<myProcess->errorString();
          
          
          }
          

          console output:

          0
          "Unknown error"
          
          Pablo J. RoginaP 1 Reply Last reply
          1
          • C cdwijs

            @mrjj said in QProcess: invalid arguments:

            arguments <<"-o" << "file.h264";

            It works, Thank you. For future reference:

            void ExternalCamera::slotStartCapture(QString filename)
            {
                QStringList arguments;
                arguments <<"-o" << "file.h264";
                //arguments <<"-o file.h264";
            
            
                myProcess->setArguments(arguments);
                myProcess->setProgram("/usr/bin/raspivid");
            
                myProcess->start();
                myProcess->waitForFinished(20000);
                qDebug()<<myProcess->exitCode();
                qDebug()<<myProcess->errorString();
            
            
            }
            

            console output:

            0
            "Unknown error"
            
            Pablo J. RoginaP Offline
            Pablo J. RoginaP Offline
            Pablo J. Rogina
            wrote on last edited by
            #5

            @cdwijs it looks your issue is solved. If so, please don't forget to mark your post as such. Thanks.

            Upvote the answer(s) that helped you solve the issue
            Use "Topic Tools" button to mark your post as Solved
            Add screenshots via postimage.org
            Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            1

            • Login

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