• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

system.callSystem() on Mac and ffmpeg

Explorer ,
May 24, 2017 May 24, 2017

Copy link to clipboard

Copied

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.

TOPICS
Scripting

Views

2.9K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 24, 2017 May 24, 2017

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 24, 2017 May 24, 2017

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 24, 2017 May 24, 2017

Copy link to clipboard

Copied

Yes, this is the disadvantage of this approach. In case the ffmpeg command produces some text output when it is finished, you could try

/ffmpeg ...yourparameters...  > result.txt &

which will write the text output of the ffmpeg call to the file result.txt

Then you can let the aescript run in an endless loop (maybe with some kind of timeout) waiting until the file result.txt exists and then check whether it contains the expected output. But again, it is just a hack.

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
May 24, 2017 May 24, 2017

Copy link to clipboard

Copied

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");

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 24, 2017 May 24, 2017

Copy link to clipboard

Copied

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();

      }

    }

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
May 24, 2017 May 24, 2017

Copy link to clipboard

Copied

Looks good. I would add a $.sleep(300) call inside your wait loop to keep the CPU utilization down during your polling. A value of 300 should be a good balance between responding quickly to ffmpeg ending vs CPU usage while polling. The sleep value is in milliseconds.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
May 25, 2017 May 25, 2017

Copy link to clipboard

Copied

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:

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
May 25, 2017 May 25, 2017

Copy link to clipboard

Copied

CC 2018 ? o_o

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
May 25, 2017 May 25, 2017

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 25, 2017 May 25, 2017

Copy link to clipboard

Copied

Yes, that would be very useful

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Aug 02, 2017 Aug 02, 2017

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jul 23, 2018 Jul 23, 2018

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 11, 2024 Apr 11, 2024

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 12, 2024 Apr 12, 2024

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 12, 2024 Apr 12, 2024

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 23, 2024 Apr 23, 2024

Copy link to clipboard

Copied

.... It got event worse, some system.callSystem won't freeze but others will.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 23, 2024 Apr 23, 2024

Copy link to clipboard

Copied

LATEST

If the parameter of command passed to system.callSystem contains non-ascii symbols (I tested Chinese and Japanese characters) will 100% freeze the host (After Effeects in my case).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines