How to interact with FFMPEG ?

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

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).

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.

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

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 :-/ )

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?

[quote=413895:@StphaneMons]It is impossible to write some code like:

dim sh as new Shell
sh.mode = 2
… //do some stuff[/quote]
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

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

Hi Vincent,

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

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

Take a look at this:

Shell to ffmpeg demo

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

Brilliant. Thanks !

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?

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.