Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
starting rewrite with native library
- Loading branch information
Showing
16 changed files
with
416 additions
and
389 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
node_modules | ||
|
||
build | ||
binding.node | ||
.lock-wscript |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,6 @@ node_modules | |
.gitignore | ||
.git/ | ||
.git* | ||
build | ||
binding.node | ||
.lock-wscript |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,25 @@ | ||
#!/usr/bin/env node | ||
|
||
var fs = require('fs'); | ||
var path = require('path'); | ||
var transcode = require('transcode'); | ||
var util = require('util'); | ||
|
||
var paths = process.argv.slice(2); | ||
if (!paths.length) { | ||
util.puts('no input files'); | ||
var opts = require('tav').set({ | ||
}); | ||
|
||
if (opts.args.length < 1) { | ||
console.log('no input file specified'); | ||
return; | ||
} | ||
|
||
var inputFile = path.normalize(opts.args[0]); | ||
if (!path.existsSync(inputFile)) { | ||
console.log('input file not found'); | ||
return; | ||
} | ||
|
||
transcode.queryInfo(paths, function(err, infos) { | ||
for (var n = 0; n < infos.length; n++) { | ||
var info = infos[n]; | ||
util.puts('Info for ' + paths[n] + ':'); | ||
util.puts(util.inspect(info, false, 3)); | ||
} | ||
transcode.queryInfo(inputFile, function(err, info) { | ||
util.puts('Info for ' + inputFile + ':'); | ||
util.puts(util.inspect(info, false, 3)); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,81 @@ | ||
#!/usr/bin/env node | ||
|
||
var fs = require('fs'); | ||
var path = require('path'); | ||
var transcode = require('transcode'); | ||
var util = require('util'); | ||
|
||
var paths = process.argv.slice(2); | ||
if (!paths.length) { | ||
util.puts('no input files'); | ||
var opts = require('tav').set({ | ||
profile: { | ||
note: 'Encoding profile', | ||
value: 'APPLE_TV_2' | ||
} | ||
}); | ||
|
||
if (!opts.args.length) { | ||
console.log('All profiles:'); | ||
for (var key in transcode.profiles) { | ||
var profile = transcode.profiles[key]; | ||
console.log(' ' + key + ': ' + profile.name); | ||
} | ||
return; | ||
} | ||
|
||
if (opts.args.length < 1) { | ||
console.log('no input file specified'); | ||
return; | ||
} | ||
if (paths.length < 2) { | ||
util.puts('no output file'); | ||
|
||
var inputFile = path.normalize(opts.args[0]); | ||
if (!path.existsSync(inputFile)) { | ||
console.log('input file not found'); | ||
return; | ||
} | ||
var outputPath = paths.pop(); | ||
|
||
var transcoder = transcode.createTranscoder(paths); | ||
transcoder.setProfile(transcode.profiles.APPLE_TV); | ||
transcoder.writeToFile(outputPath, function(err) { | ||
util.puts('complete!'); | ||
process.exit(); | ||
if (opts.args.length < 2) { | ||
// No output given, so just query info | ||
transcode.queryInfo(inputFile, function(err, info) { | ||
util.puts('Info for ' + inputFile + ':'); | ||
util.puts(util.inspect(info, false, 3)); | ||
}); | ||
return; | ||
} | ||
|
||
var profile = transcode.profiles[opts['profile']]; | ||
if (!profile) { | ||
console.log('unknown profile: ' + profile); | ||
return; | ||
} | ||
|
||
var outputFile = path.normalize(opts.args[1]); | ||
var outputPath = path.dirname(outputFile); | ||
if (!path.existsSync(outputPath)) { | ||
fs.mkdirSync(outputPath); | ||
} | ||
|
||
console.log('transcoding ' + inputFile + ' -> ' + outputFile); | ||
|
||
var task = transcode.createTask(inputFile, outputFile, { | ||
profile: profile | ||
}); | ||
task.on('begin', function(sourceInfo, targetInfo) { | ||
// transcoding beginning | ||
console.log('transcoding beginning...'); | ||
console.log('source:'); | ||
console.log(util.inspect(sourceInfo)); | ||
console.log('target:'); | ||
console.log(util.inspect(targetInfo)); | ||
}); | ||
task.on('progress', function(timestamp, duration) { | ||
// new progress made, currrently at timestamp out of duration | ||
console.log('progress ' + progress.timestamp + ' / ' + progress.duration); | ||
}); | ||
task.on('error', function(err) { | ||
// error occurred | ||
console.log('error: ' + err); | ||
}); | ||
task.on('end', function() { | ||
// transcoding has completed | ||
console.log('finished'); | ||
}); | ||
task.start(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,32 @@ | ||
var ffmpeg = require('./transcode/ffmpeg'); | ||
var profiles = require('./transcode/profiles'); | ||
var util = require('util'); | ||
|
||
var ffmpegInfo = ffmpeg.detect(); | ||
var binding = require('./transcode/binding'); | ||
|
||
exports.profiles = profiles; | ||
exports.profiles = require('./transcode/profiles'); | ||
|
||
exports.verifyConfiguration = function(callback) { | ||
var err = null; | ||
if (!ffmpegInfo) { | ||
err = new Error('FFMPEG not found'); | ||
} | ||
if (!err) { | ||
// TODO: chain into ffmpeg to detect features/etc | ||
callback(null); | ||
} else { | ||
callback(err); | ||
} | ||
exports.queryInfo = function(source, callback) { | ||
binding.queryInfo(source, callback); | ||
}; | ||
|
||
exports.Transcoder = require('./transcode/transcoder').Transcoder; | ||
exports.createTranscoder = function(inputs) { | ||
return new exports.Transcoder(ffmpegInfo, inputs); | ||
exports.createTask = function(source, target, options) { | ||
return new binding.Task(source, target, options); | ||
}; | ||
|
||
var queryInfo = require('./transcode/mediainfo').queryInfo; | ||
exports.queryInfo = function(inputs, callback) { | ||
return queryInfo(ffmpegInfo, inputs, callback); | ||
exports.transcode = function(source, target, profile, callback) { | ||
var sourceInfoStash = null; | ||
var targetInfoStash = null; | ||
var task = exports.createTask(source, target, { | ||
profile: profile | ||
}); | ||
task.on('begin', function(sourceInfo, targetInfo) { | ||
sourceInfoStash = sourceInfo; | ||
targetInfoStash = targetInfo; | ||
}); | ||
task.on('error', function(err) { | ||
callback(err, sourceInfo, targetInfo); | ||
}); | ||
task.on('end', function() { | ||
callback(null, sourceInfo, targetInfo); | ||
}); | ||
task.start(); | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module.exports = require('../../build/Release/node_transcode.node'); | ||
|
||
// WEAK: required in v0.6 | ||
function inheritEventEmitter(type) { | ||
function extend(target, source) { | ||
for (var k in source.prototype) { | ||
target.prototype[k] = source.prototype[k]; | ||
} | ||
} | ||
var events = require('events'); | ||
extend(type, events.EventEmitter); | ||
} | ||
inheritEventEmitter(module.exports.Task); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.