Skip to content

Instantly share code, notes, and snippets.

@oxyflour
Last active November 18, 2015 08:39
Show Gist options
  • Save oxyflour/c468381f66e0dbee6ebc to your computer and use it in GitHub Desktop.
Save oxyflour/c468381f66e0dbee6ebc to your computer and use it in GitHub Desktop.
convert image sequence to avi with ffmpeg
var PREFIX = 'c' + Math.floor(Math.random() * 1000) + '-',
EXTENSION = 'bmp',
ROOT_DIR = '',
FFMPEG_PATH = 'ffmpeg-20151116-git-1fe82ab-win64-static\\bin\\ffmpeg.exe',
FFMPEG_ARGS = '-framerate 30',
FILE_OUTPUT = 'test.avi'
var app = WScript.CreateObject('Shell.Application'),
shell = WScript.CreateObject('WScript.Shell'),
fso = WScript.CreateObject('Scripting.FileSystemObject')
var folder = app.BrowseForFolder(0, 'Select the folder for the images', 0, ROOT_DIR)
if (!folder) WScript.Quit()
// what the hell 'Self' is?
var folderPath = folder.Self.Path,
files = fso.getFolder(folderPath).Files,
names = [ ]
for (var i = new Enumerator(files); !i.atEnd(); i.moveNext()) {
var path = '' + i.item(),
name = path.split('\\').pop(),
suffix = name.split('.').pop()
if (suffix === EXTENSION)
names.push(name)
}
var selected = shell.Popup('Continue with ' + names.length + ' files?', 0, 'Warning', 1)
if (selected === 2) WScript.Quit()
var ffmpeg = shell.CurrentDirectory + '\\' + FFMPEG_PATH
shell.CurrentDirectory = folderPath
names = names.sort()
for (var i = 0; i < names.length; i ++) {
var index = (i + 1e9 + '').slice(-9)
fso.MoveFile(names[i], PREFIX + index + '.' + EXTENSION)
}
var cmd = '"' + ffmpeg + '" -i "' + PREFIX + '%09d.' + EXTENSION + '" ' +
FFMPEG_ARGS + ' -y ' + FILE_OUTPUT
shell.Run(cmd, 1, true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment