How to interact with FFMPEG ?

  1. 8 months ago

    Vincent V

    12 Nov 2018 Amsterdam, The Netherlands

    I’m trying to write a small GUI-program for the popular video converter FFMPEG, which is a command line tool.
    https://evermeet.cx/ffmpeg/ffmpeg-92400-gc47b48c0a6.dmg

    Using the Shell class, conversion works, but the GUI freezes during video encoding and doesn’t update until the task is finished. I would like to show the progress percentage in the GUI.

    It seems to be possible, see:
    https://stackoverflow.com/questions/747982/can-ffmpeg-show-a-progress-bar

    But how would I get Xojo to read these callback progress data?

    Here's the Xojo project download

    Take a look at this:

    Shell to ffmpeg demo

    You will need to determine HOW you deal with the output.

  2. If you use a Shell with mode=0 (i.e. Synchronous), then the Execute method will always block until the command is finished.

    If you want to get the text printed out by FFMPEG while it is executing, then you need to set the 'mode' of your Shell to 1 or 2 (preferably 2, as it doesn't change anything really).

  3. Vincent V

    12 Nov 2018 Amsterdam, The Netherlands

    Thanks, but when I set it to Mode=2 the Textarea doesn't update at all and conversion fails...
    Also, I wonder how I would read the terminal output in realtime, so that I can parse it for a progress percentage.

  4. Whenever you set mode to 2 (or 1), you NEED to have a Shell object somewhere in your Window so you can write some code for the different events it provides.

    It is impossible to write some code like:

    dim sh as new Shell
    sh.mode = 2
    ... //do some stuff

  5. Christoph D

    12 Nov 2018 Pre-Release Testers, Xojo Pro

    On a side note: using FFmpeg in a commercial app is not allowed and you will receive a letter from MPEG LA very fast (trust me, I know :-/ )

  6. Vincent V

    12 Nov 2018 Amsterdam, The Netherlands

    Thanks Christoph, but my company has been fully licensed by MPEG LA since 2004.
    Considering you have experience with FFmpeg & Xojo. Do you know the solution to my problem?

  7. Tim J

    12 Nov 2018 Pre-Release Testers, Xojo Pro Dehydrating in AZ

    @Stéphane ;Mons It is impossible to write some code like:

    dim sh as new Shell
    sh.mode = 2
    ... //do some stuff

    That is only correct in that you've not handled waiting for the shell. This would be more correct and works very well:

    Dim sh As New Shell
    sh.Mode = 2
    sh.Execute "LongRunningCommand"
    Do
      sh.Poll
      CallSomeMethod
      Check sh.Result for a prompt
    Loop Until Not sh.IsRunning Or InStrB(sh.Result, WatchedForPrompt) <> 0
  8. Vincent V

    12 Nov 2018 Amsterdam, The Netherlands

    Hi Tim. Thanks for that. However, I'm afraid it doesn't work here. Are you sure you tested it with FFmpeg?

  9. Tim J

    12 Nov 2018 Pre-Release Testers, Xojo Pro Dehydrating in AZ

    Hi Vincent,

    That works with everything. What particular ffmpeg command are you executing?

  10. Vincent V

    12 Nov 2018 Amsterdam, The Netherlands

    ffmpeg -stats -i input.mov -c:v libx264 output.mp4

  11. Tim J

    12 Nov 2018 Pre-Release Testers, Xojo Pro Answer Dehydrating in AZ

    Take a look at this:

    Shell to ffmpeg demo

    You will need to determine HOW you deal with the output.

  12. Vincent V

    12 Nov 2018 Amsterdam, The Netherlands

    Brilliant. Thanks !

  13. 7 months ago

    Vincent V

    12 Dec 2018 Amsterdam, The Netherlands

    I'm having an issue with the build of my project. My app works fine with FFmpeg in the IDE, but when I add the FFmpeg console application to my project with a build step (copy files), the resulting compiled, single binary does not work.

    When I run my Xojo app (with built-in FFmpeg binary) from the desktop, the console output says::

    bash: /Users/vincent/Desktop/FFmpeg: No such file or directory

    Clearly the Xojo app does not see the FFmpeg binary.

    Any idea what’s wrong?

  14. Tim J

    12 Dec 2018 Pre-Release Testers, Xojo Pro Dehydrating in AZ

    You really can't do that - both license-wise for ffmpeg and binary requirements, you'll run into issues. Rather than trying to include ffmpeg within your all, you need to do what others do and simply state that the user must download and preinstall the ffmpeg binary and provide the link to the downloads.

or Sign Up to reply!