Results 1 to 3 of 3

Thread: Qprocess error with ffmpeg

  1. #1
    Join Date
    Sep 2010
    Location
    Denmark
    Posts
    25
    Thanks
    10
    Thanked 3 Times in 1 Post
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Qprocess error with ffmpeg

    Hi.

    I work on a storyboard program.
    In line 3-10, I make a series of png-images (640x480 pix), and numbers them "im_00001.png", "im_00002.png" etc. That part works fine.
    Qt Code:
    1. void animatic::exportAnimatic()
    2. {
    3. int teller = 1;
    4. for (int i = 0; i < pixmapList.size();i++){
    5. QImage image = pixmapList[i].toImage();
    6. for (int j = 0;j < infoList[i][frames].toInt();j++){
    7. image.save(projFilePath + sceneDir + "/" + sceneDir +
    8. tr("_%1.png","DO NOT TRANSLATE").arg(QString::number(teller),5,'0'));
    9. teller += 1;
    10. }
    11. }
    12. sl << "-i " + projFilePath + sceneDir + "/" + sceneDir + "_%5d.png";
    13. QString sr;
    14. sl << "-r " + sr.setNum(fps) ;
    15. sl << projFilePath + sceneDir + "/" + sceneDir + ".mp4";
    16. qDebug() << sl;
    17. proc.start("ffmpeg",sl);
    18. int c = 1;
    19. while (proc.state() > 0) {
    20. sleep(5);
    21. qDebug() << proc.state() << c;
    22. c+=1;
    23. }
    24. qDebug() << proc.state() << " at the end...";
    25. qDebug() << proc.exitCode() << " exitcode";
    26. qDebug() << proc.error() << " error";
    27. qDebug() << proc.errorString() << " errorstring";
    28. }
    To copy to clipboard, switch view to plain text mode 
    It works fine untill it starts the proc (QProcess).
    Here are the debug-messages:
    Qt Code:
    1. ("-i /home/david/tegnefilm/david2/h3/h3_%5d.png", "-r 25", "/home/david/tegnefilm/david2/h3/h3.mp4")
    2. 2 1 (while-loop)
    3. 2 2 (while-loop)
    4. 0 3 (while-loop)
    5. 0 at the end...
    6. 1 exitcode
    7. 5 error
    8. "Ukendt fejl" errorstring ("Unknown error")
    To copy to clipboard, switch view to plain text mode 
    If I run:
    ffmpeg -i /home/david/tegnefilm/david2/h3/h3_%5d.png -r 25 /home/david/tegnefilm/david2/h3/h3.mp4
    in a terminal, it produces a fine mp4-file.
    ffmpeg is in the path. I have run the the command from several positions, and it produces a mp4-video every time.
    I have also tried to write "/usr/bin/ffmpeg" as the command in line 18, but with the same error messages.
    Can anyone help here?

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,391
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Qprocess error with ffmpeg

    I think it is because you have arguments that contains spaces - on windows they are wrapped in "quotes" and passed to the called process as single argument, look:
    Qt Code:
    1. // simple program that will write passed command line arguments into file
    2.  
    3. #include <stdio.h>
    4.  
    5. int main(int argc, char ** argv){
    6. FILE * f = fopen("args.txt","w");
    7. int i=0;
    8. for (i=0 ; i<argc ; ++i){
    9. fprintf(f,"%s\n",argv[i]);
    10. }
    11. fclose(f);
    12. return 0;
    13. }
    14.  
    15. // QProcess test code:
    16.  
    17. ...
    18. sl << "no_space" << "what is this" << "out.txt";
    19. qDebug() << sl;
    20. QProcess proc;
    21. proc.start("args.exe",sl);
    22. qDebug() << proc.waitForStarted();
    23. qDebug() << proc.waitForFinished();
    To copy to clipboard, switch view to plain text mode 
    args.txt will contain four arguments, as "what is this" string was passed in as single string, I think you can see how different it is from calling the same process from the console:
    Qt Code:
    1. args.exe no_space what is this out.txt
    To copy to clipboard, switch view to plain text mode 
    now args.txt will contain six arguments.
    I don't know how ffmpeg handles its arguments, but my guess is - you have to separate the "-i" and "-r" arguments:
    Qt Code:
    1. sl << "-i";
    2. sl << projFilePath + sceneDir + "/" + sceneDir + "_%5d.png";
    3. sl << "-r"
    4. sl << sr.setNum(fps) ;
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to stampede for this useful post:

    davidlamhauge (3rd February 2014)

  4. #3
    Join Date
    Sep 2010
    Location
    Denmark
    Posts
    25
    Thanks
    10
    Thanked 3 Times in 1 Post
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qprocess error with ffmpeg

    Thanks!
    I followed your advice, and now it works like a charm...

Similar Threads

  1. Qprocess that call ffmpeg in mac
    By polin in forum Qt Programming
    Replies: 1
    Last Post: 11th April 2013, 22:11
  2. Qt Mac g++ Linking Error on while compiling FFMPEG
    By polin in forum Qt Programming
    Replies: 0
    Last Post: 17th January 2013, 11:08
  3. Qprocess Bus Error
    By augusbas in forum Qt for Embedded and Mobile
    Replies: 2
    Last Post: 8th July 2010, 08:23
  4. Ffmpeg?
    By nthung in forum Qt Programming
    Replies: 1
    Last Post: 10th June 2010, 12:17
  5. QProcess error Using Arguments Qt 4.5
    By xanders in forum Qt Programming
    Replies: 6
    Last Post: 15th May 2009, 16:56

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.