No internet connection
  1. Home
  2. How to

How to convert video to DNxHD

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);
Solved in post #2, click to view
  • 4 replies
  1. Solution in question

    ReplySolution
    1. In reply tochrscheuer:
      Chris Atkins @iamchrisatkins
        2019-01-22 07:27:38.940Z

        Let me know when this works! :-)

        1. @iamchrisatkins,
          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:

          http://macappstore.org/ffmpeg/
          1. Chris Atkins @iamchrisatkins
              2019-01-22 07:46:39.210Z

              Amazing! yes it works perfectly!