Skip to content

Instantly share code, notes, and snippets.

@yadex205
Created January 24, 2017 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yadex205/f4327ad3a0c73eea5905842869adca0c to your computer and use it in GitHub Desktop.
Save yadex205/f4327ad3a0c73eea5905842869adca0c to your computer and use it in GitHub Desktop.
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