Skip to main content
Inspiring
May 24, 2017
Frage

system.callSystem() on Mac and ffmpeg

  • May 24, 2017
  • 4 Antworten
  • 4367 Ansichten

Hi,

I've been working a few hours on this with no luck, maybe anyone here can help:

I have an issue on Mac with a script where I want to transcode some files using ffmpeg.

Here's what's going on:

var cmd = pathToFFMpegBin + '/ffmpeg -h';

var output = system.callSystem(cmd);

alert(output);

This works well, the command is executed and the alert shows the help for ffmpeg

But with the full command line to encode a file, like:

var cmd = pathToFFMpegBin + "/ffmpeg -h -i " + inputFilePath + " -c pcm_f32le " + outputFilePath;

var output = system.callSystem(cmd);

alert(output);

After Effects freezes (with the mouse cursor being the waiting cursor) like it's stuck in an endless loop

The alert is not shown, the script is stuck at the callSystem line.

BUT: the encoding does work, the new file is created and working...

- The same command works well in a terminal or as a bash script.

- The script works well in Windows

- If I provide a invalid path to the input file or the output file, it works as expected (the alert shows the error returned by ffmpeg)

- If I set ffmpeg to quiet mode (using the '-v quiet' option), it still don't work.

- I tried creating and executing a bash script, but I can't use File.execute() as it opens the script in a editor (even after I have set it to executable, that's normal behavior on Mac). I have to execute it via a callSystem('./file') and this freezes After Effects too.

- I tried launching the script via ExtendScript toolkit, both After Effecst and ExtendScript toolkit freeze, and I cannot stop the script in ES Toolkit.

- Tested on CC2017 and CC2015, same result.

- Javascript debugging is enabled, but I don't have any debug info, it's really like the script is in an endless loop, except I can't stop it.

Any idea? Or do you think about a workaround?

Oh and the ffmpeg binary was the snapshot build here: wihttps://evermeet.cx/ffmpeg/ the one recommended by the official ffmpeg website.

I still have to test with another version.

Dieses Thema wurde für Antworten geschlossen.

4 Antworten

Participating Frequently
April 12, 2024

This "bug" remains in 2024.....

Participating Frequently
April 12, 2024

Inovking `system.callSystem` on my M3 Macbook Pro will freeze After Effects. But it will not with the same code on a Intel chip Macbook Pro.

Participating Frequently
April 13, 2024

This bug was gone after AE automatically upgrade to 24.3 yesterday...

Alexandre Parenteau
Adobe Employee
Adobe Employee
August 2, 2017

I think the fix is in the latest AE. Hopefully someone here will be able to confirm!

Legend
July 24, 2018

Was this fix ever confirmed in the subsequent release of AE?  I’m getting a similar error, but with calling NodeJS script

Alexandre Parenteau
Adobe Employee
Adobe Employee
May 25, 2017

Nice to know there is a work around!

Looking at AE code, indeed there is a problem on Mac.

Would it be useful to include a fix for this problem in the next release? With the fix, AE will wait for ffmpeg to complete, so need to mock with '&'.

It will look like this:

UQg
Legend
May 25, 2017

CC 2018 ? o_o

Alexandre Parenteau
Adobe Employee
Adobe Employee
May 25, 2017

I meant in a 2017 dot release. Please vote up, if interested.

Mathias Moehl
Community Expert
Community Expert
May 24, 2017

Just a hack, but since it looks like Ae does not notice properly when the command terminated, maybe just append a "&" at the end of the command line call such that it terminates immediately and does not wait until ffmpeg is finished.

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects
Inspiring
May 24, 2017

Hi Mathias!

Thanks! That will do the trick for now
I wish I'd knew Mac OS better....

But, this can only be a temporary hack, as using this there's no proper way to know when the encoding is finished, am I right?

Inspiring
May 24, 2017

You can check if ffmpeg is running via the following (OS X only):

var cmd = 'ps -A | grep "fmpeg"';

var output = system.callSystem(cmd);

if (output != "")

    $.writeln("ffmpeg running");

else

    $.writeln("ffmpeg not running");


Thanks!

Here's what I did, with a timeout, it works well!

     // mac hack, do not wait for ffmpeg as it freezes AE

    if (mac) cmd = cmd + ' &';

    system.callSystem(cmd);

    // mac hack, but let's wait anyway

    if (mac)

    {

      //timeout

      var currentDate = new Date();

      var timeout = currentDate.getTime() + 30000;

      var checkTime = new Date();

      var cmd = 'ps -A | grep "fmpeg"';

      //wait

      while(checkTime.getTime() < timeout)

      {

        var test = system.callSystem(cmd);

        if (test == '') break;

        checkTime = new Date();

      }

    }