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

use Handbrake to transcode video after render finishes

Participant ,
Jul 27, 2018 Jul 27, 2018

Copy link to clipboard

Copied

I'm writing a script that would transcode all my renders after they are rendered. This is the code...

//render finished here

var command = "HandBrakeCLI -i /path/to/file/filename.mov -o /path/to/file/filename.mp4";

alert(command);

var response = system.callSystem(command);

alert(response);   //never executed due to AE freezing

alert("done");

I am getting a very weird behaviour. The file "filename.mov" is successfully transcoded and placed at the specified location, but after effects freezes and blocks me out completely when it reaches

var response = system.callSystem(command);

So every time I render and transcode, I need to force quit AE.

This is the only command I encountered that freezes AE. I'd much appreciate any tips on how to handle this kind of problem. HandbrakeCLI is available here: https://handbrake.fr/downloads2.php

I am running macos Sierra.

TOPICS
Scripting

Views

1.5K

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 31, 2018 Jul 31, 2018

Copy link to clipboard

Copied

LATEST

On macOS, you can send an AppleScript to the system.callSystem() method.  This will spawn a new Terminal thread for your command line to run in.  You can have a string in your ExtendScript code like:

var handbrakeCommand = "HandBrakeCLI -i /path/to/file/filename.mov -o /path/to/file/filename.mp4"

var sysCommand = "osascript -e 'tell app \"Terminal\" to do script \"" + handbrakeCommand  + "; exit;\"' -e 'tell app \"Terminal\" to activate'";

system.callSystem(sysCommand);

osascript is Apple's standard command line interpreter for running AppleScript files.  In the code above the -e switch allows you to place literal AppleScript language on the command line.  You can have multiple -e switches to have osascript interpret more than one script in order.

You may need to escape some characters in the handbrakeCommand string for it to work, but the idea is to use AppleScript to launch a separate Terminal process outside of AE's main thread, and have it run your command or script asynchronously.

Hope this helps!

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