By Christian Scheuer @chrscheuer2018-11-30 06:34:09.465Z
A little script to help convert videos to DNxHD 1920x1080p format, QuickTime mov container. Will resize with original aspect ratio, making letter boxes if needed. Will open a Terminal window where you can see the progress and select the newly created MOV file in Finder after successful completion.
function selectFile(message) {
var path = sf.system.execAppleScript({
script: 'return POSIX path of (choose file with prompt "' + message + '" )'
}).result.trim();
if (!path) throw "User cancelled";
if (!sf.file.exists({ path: path }).exists) throw "File not found";
return path;
}
function doScriptInTerminal(script) {
sf.system.execAppleScript({
script: 'tell application "Terminal"\n' +
'do script "' + script.replace(/\"/g, '\\"') + '"\n' +
'end tell'
});
var terminal = sf.ui.app('com.apple.Terminal');
terminal.appActivate();
terminal.windows.first.elementRaise();
}
function execFFmpegAndLocateFile(ffmpegCommandLine, targetPath) {
doScriptInTerminal(ffmpegCommandLine +
' && osascript -e \'tell application "Finder"\' -e activate -e \'reveal POSIX file "' + targetPath + '"\' -e \'end tell\''
);
}
function getFFmpegCmdLine(opts) {
var sourcePath = opts.sourcePath;
var targetPath = opts.targetPath;
var vf = 'scale=1920x1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2,format=yuv422p';
return 'ffmpeg -i "' + sourcePath + '" ' +
'-c:v dnxhd -vf \'' + vf + '\' -b:v 36M ' +
'-c:a pcm_s24le ' +
'-threads 6 -sn -y "' + targetPath + '"';
}
var sourcePath = selectFile('Please select the video file you\'d like to convert');
var targetPath = sourcePath + '.dnxhd.mov';
execFFmpegAndLocateFile(getFFmpegCmdLine({
sourcePath: sourcePath,
targetPath: targetPath,
}), targetPath);
- In reply tochrscheuer⬆:Chris Atkins @iamchrisatkins
Let me know when this works! :-)
Christian Scheuer @chrscheuer2019-01-22 07:30:20.756Z
@iamchrisatkins,
http://macappstore.org/ffmpeg/
The reason why this is not working is most likely you don't have the open source component ffmpeg on your computer. When we release this as a package, you'll be guided visually on how to install it, but for now you can do it manually, for instance try following this guide:Chris Atkins @iamchrisatkins
Amazing! yes it works perfectly!