Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions HandbrakeServerConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
var HandbrakeServerConfig = {}

HandbrakeServerConfig.main = {};

HandbrakeServerConfig.main.rootFolder = "/home/samba/video";
HandbrakeServerConfig.main.outputFolder = "/home/samba/video/output";
HandbrakeServerConfig.main.listenPort = 8181;
HandbrakeServerConfig.main.handbrakeExit = "Encode done!";

HandbrakeServerConfig.profiles = {
"high-profile":"-i {inputFile} -o {outputFile}.mp4 -e x264 -q 20.0 -a 1,1 -E copy:ac3,faac -B 160,160 -6 auto,dpl2 -R Auto,Auto -D 0.0,0.0 -f mp4 --detelecine --decomb --loose-anamorphic -m -x b-adapt=2:rc-lookahead=50",
"android-tablet":"-i {inputFile} -o {outputFile}.m4v -e x264 -q 20.0 -r 30 --pfr -a 1 -E faac -B 160 -6 dpl2 -R Auto -D 0.0 -f mp4 -4 -X 1280 --loose-anamorphic -m",
"universal":"-i {inputFile} -o {outputFile}.mp4 -e x264 -q 20.0 -a 1,1 -E faac,copy:ac3 -B 160,160 -6 dpl2,auto -R Auto,Auto -D 0.0,0.0 -f mp4 -X 720 --loose-anamorphic -m -x cabac=0:ref=2:me=umh:bframes=0:weightp=0:8x8dct=0:trellis=0:subme=6",
"ipod":"-i {inputFile} -o {outputFile}.mp4 -e x264 -b 700 -a 1 -E faac -B 160 -6 dpl2 -R Auto -D 0.0 -f mp4 -I -X 320 -m -x level=30:bframes=0:weightp=0:cabac=0:ref=1:vbv-maxrate=768:vbv-bufsize=2000:analyse=all:me=umh:no-fast-pskip=1:subme=6:8x8dct=0:trellis=0",
"iphone+ipod-touch":"-i {inputFile} -o {outputFile}.mp4 -e x264 -q 20.0 -a 1 -E faac -B 128 -6 dpl2 -R Auto -D 0.0 -f mp4 -X 480 -m -x cabac=0:ref=2:me=umh:bframes=0:weightp=0:subme=6:8x8dct=0:trellis=0",
"iphone-4":"-i {inputFile} -o {outputFile}.mp4 -e x264 -q 20.0 -r 29.97 --pfr -a 1 -E faac -B 160 -6 dpl2 -R Auto -D 0.0 -f mp4 -4 -X 960 --loose-anamorphic -m",
"ipad":"-i {inputFile} -o {outputFile}.mp4 -e x264 -q 20.0 -r 29.97 --pfr -a 1 -E faac -B 160 -6 dpl2 -R Auto -D 0.0 -f mp4 -4 -X 1024 --loose-anamorphic -m",
"apple-tv":"-i {inputFile} -o {outputFile}.mp4 -e x264 -q 20.0 -a 1,1 -E faac,copy:ac3 -B 160,160 -6 dpl2,auto -R Auto,Auto -D 0.0,0.0 -f mp4 -4 -X 960 --loose-anamorphic -m -x cabac=0:ref=2:me=umh:b-pyramid=none:b-adapt=2:weightb=0:trellis=0:weightp=0:vbv-maxrate=9500:vbv-bufsize=9500",
"apple-tv-2":"-i {inputFile} -o {outputFile}.mp4 -e x264 -q 20.0 -a 1,1 -E faac,copy:ac3 -B 160,160 -6 dpl2,auto -R Auto,Auto -D 0.0,0.0 -f mp4 -4 -X 1280 --loose-anamorphic -m",
"normal":"-i {inputFile} -o {outputFile}.mp4 -e x264 -q 20.0 -a 1 -E faac -B 160 -6 dpl2 -R Auto -D 0.0 -f mp4 --strict-anamorphic -m -x ref=2:bframes=2:subme=6:mixed-refs=0:weightb=0:8x8dct=0:trellis=0",
"classic":"-i {inputFile} -o {outputFile}.mp4 -b 1000 -a 1 -E faac -B 160 -6 dpl2 -R Auto -D 0.0 -f mp4"
};

module.exports = HandbrakeServerConfig;
27 changes: 7 additions & 20 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ var app = module.exports = express.createServer(),
process.chdir(appPath);

// Configuration

app.configure(function(){
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
Expand All @@ -34,22 +33,10 @@ app.configure('production', function(){
// Routes

YUI().use("json","substitute",function(Y){

var rootFolder = "/storage/Video",
outputFolder = "/storage/Video",
profiles = {
"high-profile":"-i {inputFile} -o {outputFile}.mp4 -e x264 -q 20.0 -a 1,1 -E copy:ac3,faac -B 160,160 -6 auto,dpl2 -R Auto,Auto -D 0.0,0.0 -f mp4 --detelecine --decomb --loose-anamorphic -m -x b-adapt=2:rc-lookahead=50",
"android-tablet":"-i {inputFile} -o {outputFile}.m4v -e x264 -q 20.0 -r 30 --pfr -a 1 -E faac -B 160 -6 dpl2 -R Auto -D 0.0 -f mp4 -4 -X 1280 --loose-anamorphic -m",
"universal":"-i {inputFile} -o {outputFile}.mp4 -e x264 -q 20.0 -a 1,1 -E faac,copy:ac3 -B 160,160 -6 dpl2,auto -R Auto,Auto -D 0.0,0.0 -f mp4 -X 720 --loose-anamorphic -m -x cabac=0:ref=2:me=umh:bframes=0:weightp=0:8x8dct=0:trellis=0:subme=6",
"ipod":"-i {inputFile} -o {outputFile}.mp4 -e x264 -b 700 -a 1 -E faac -B 160 -6 dpl2 -R Auto -D 0.0 -f mp4 -I -X 320 -m -x level=30:bframes=0:weightp=0:cabac=0:ref=1:vbv-maxrate=768:vbv-bufsize=2000:analyse=all:me=umh:no-fast-pskip=1:subme=6:8x8dct=0:trellis=0",
"iphone+ipod-touch":"-i {inputFile} -o {outputFile}.mp4 -e x264 -q 20.0 -a 1 -E faac -B 128 -6 dpl2 -R Auto -D 0.0 -f mp4 -X 480 -m -x cabac=0:ref=2:me=umh:bframes=0:weightp=0:subme=6:8x8dct=0:trellis=0",
"iphone-4":"-i {inputFile} -o {outputFile}.mp4 -e x264 -q 20.0 -r 29.97 --pfr -a 1 -E faac -B 160 -6 dpl2 -R Auto -D 0.0 -f mp4 -4 -X 960 --loose-anamorphic -m",
"ipad":"-i {inputFile} -o {outputFile}.mp4 -e x264 -q 20.0 -r 29.97 --pfr -a 1 -E faac -B 160 -6 dpl2 -R Auto -D 0.0 -f mp4 -4 -X 1024 --loose-anamorphic -m",
"apple-tv":"-i {inputFile} -o {outputFile}.mp4 -e x264 -q 20.0 -a 1,1 -E faac,copy:ac3 -B 160,160 -6 dpl2,auto -R Auto,Auto -D 0.0,0.0 -f mp4 -4 -X 960 --loose-anamorphic -m -x cabac=0:ref=2:me=umh:b-pyramid=none:b-adapt=2:weightb=0:trellis=0:weightp=0:vbv-maxrate=9500:vbv-bufsize=9500",
"apple-tv-2":"-i {inputFile} -o {outputFile}.mp4 -e x264 -q 20.0 -a 1,1 -E faac,copy:ac3 -B 160,160 -6 dpl2,auto -R Auto,Auto -D 0.0,0.0 -f mp4 -4 -X 1280 --loose-anamorphic -m",
"normal":"-i {inputFile} -o {outputFile}.mp4 -e x264 -q 20.0 -a 1 -E faac -B 160 -6 dpl2 -R Auto -D 0.0 -f mp4 --strict-anamorphic -m -x ref=2:bframes=2:subme=6:mixed-refs=0:weightb=0:8x8dct=0:trellis=0",
"classic":"-i {inputFile} -o {outputFile}.mp4 -b 1000 -a 1 -E faac -B 160 -6 dpl2 -R Auto -D 0.0 -f mp4"
},
var HandbrakeServerConfig = require('./HandbrakeServerConfig');
var rootFolder = HandbrakeServerConfig.main.rootFolder,
outputFolder = HandbrakeServerConfig.main.outputFolder,
profiles = HandbrakeServerConfig.profiles,
handbrake,
config = {
jobs:{},
Expand Down Expand Up @@ -78,7 +65,7 @@ YUI().use("json","substitute",function(Y){
checkJobs();

if (!module.parent) {
app.listen(8181);
app.listen(HandbrakeServerConfig.main.listenPort);
console.log("Express server listening on port %d", app.address().port);
}
});
Expand Down Expand Up @@ -171,7 +158,7 @@ YUI().use("json","substitute",function(Y){
if (p.charAt(0) !== '/') { cb('Relative path: ' + p); return; }

var ps = path.normalize(p).split('/');
path.exists(p, function (exists) {
fs.exists(p, function (exists) {
if (exists) cb(null);
else mkdirP(ps.slice(0,-1).join('/'), mode, function (err) {
if (err && err.errno !== process.EEXIST){
Expand Down Expand Up @@ -208,7 +195,7 @@ YUI().use("json","substitute",function(Y){
job = config.jobs[config.currentJobID],
h,m,s;

if(updateMsg.match("Rip done!")){
if(updateMsg.match(HandbrakeServerConfig.main.handbrakeExit)){
job.complete = true;
}

Expand Down