Created
January 24, 2017 15:01
-
-
Save yadex205/f4327ad3a0c73eea5905842869adca0c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const async = require('async') | |
const path = require('path') | |
const spawn = require('child_process').spawn | |
const CONCURRENCY = 6 | |
const VIDEO_STORE_ROOT = 'K:' | |
const VJ_VIDEO_STORE = 'Motion Graphics (VJ, Hap)' | |
const sources = require('yargs').argv._ | |
function convertForVJ(source_filepath, callback) { | |
let target_dir = path.join(VIDEO_STORE_ROOT, VJ_VIDEO_STORE) | |
let target_filename = path.basename(source_filepath, path.extname(source_filepath)) + '.mov' | |
let target_filepath = path.join(target_dir, target_filename) | |
spawn('ffmpeg', [ | |
'-i', source_filepath, '-y', '-hide_banner', | |
'-f', 'mov', | |
'-c:v', 'hap', '-aspect', '16:9', '-s', '1280x720', | |
'-an', | |
target_filepath | |
], { stdio: ['ignore', 1, 2] }).on('close', () => { callback(null, source_filepath) }) | |
} | |
let queue = async.queue((filepath, callback) => { | |
async.waterfall([ | |
function (done) { convertForVJ(filepath, done) } | |
], function (err) { | |
if (!err) { console.error(err) } | |
callback() | |
}) | |
}, CONCURRENCY) | |
queue.push(sources) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment