Created
September 26, 2016 07:43
-
-
Save kidapu/0fff7a081415e6130eba15b306c745dd to your computer and use it in GitHub Desktop.
ffmpegで動画を繰り刻む君.txt
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
// require | |
var _exec = require('child_process').execSync; | |
var _util = require('util'); | |
// static const | |
var _scale = 1.0; | |
var _fps = 30; | |
var _input_path = "./src/test.mov"; | |
var _output_format ="./dest/test%d.mov" | |
// start , duration の順番で刻みたい順番を入れます | |
var _rec_datas = [ | |
[14.4, 1.8], | |
[17.5, 1.5], | |
]; | |
// convert | |
convert(); | |
function convert() | |
{ | |
// width, height | |
var width = Math.floor(""+ _exec('ffmpeg -i ' + _input_path + ' 2>&1 > /dev/null | grep Stream | grep -o "[1-9][0-9]\\+x[1-9][0-9]\\+" | cut -d x -f1')); | |
var height = Math.floor(""+ _exec('ffmpeg -i ' + _input_path + ' 2>&1 > /dev/null | grep Stream | grep -o "[1-9][0-9]\\+x[1-9][0-9]\\+" | cut -d x -f2')); | |
var new_width = width * _scale; | |
var new_height = height * _scale; | |
// calc | |
console.log( "target w:" + new_width + " / h:" + new_height); | |
for(var i = 0; i <_rec_datas.length; i++) | |
{ | |
var output_path = _util.format(_output_format, i) | |
var command = _util.format( "ffmpeg -ss %d -i %s -t %d -vcodec copy -acodec copy %s", _rec_datas[i][0], _input_path, _rec_datas[i][1], output_path ); | |
var log = _exec( command ); | |
console.log( "- - - - - - - - - - - - - "); | |
console.log( "コマンド : " + command); | |
console.log( "ログ:" + log ); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment