Skip to content

Instantly share code, notes, and snippets.

@lomadurov
Created July 30, 2014 20:46
Show Gist options
  • Save lomadurov/024ffbf1dbd23e6c457c to your computer and use it in GitHub Desktop.
Save lomadurov/024ffbf1dbd23e6c457c to your computer and use it in GitHub Desktop.
var ffmpeg = require('fluent-ffmpeg');
function getFull(inputFile, outputName) {
getVideo(inputFile, 'mp4', outputName);
getVideo(inputFile, 'ogv', outputName);
getVideo(inputFile, 'webm', outputName);
}
function getVideo(inputFile, type, outputName) {
var codec = type === 'ogv' ? 'libtheora' : type === 'webm' ? 'libvpx' : 'libx264'
ffmpeg()
.input('./.in/' + inputFile)
.inputFormat('gif')
.input('./watermark2.png')
.noAudio()
.videoCodec(codec)
.videoBitrate('400k')
.complexFilter(['scale=trunc(iw/2)*2:trunc(ih/2)*2[rescaled]', {
filter: "overlay",
options: { x: 'main_w-overlay_w-10', y: 'main_h-overlay_h-10' },
inputs: 'rescaled',
outputs: 'result'
}], 'result')
.output('./.out/' + outputName + '.' + type)
.on('end', function() {
console.log('Finished processing');
})
.run();
}
getFull('3.gif', '3');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment