2
0
mirror of https://github.com/thumbsup/thumbsup synced 2024-11-03 15:40:14 +00:00

Fix #19: support for MTS files, with full-frame mp4 export

This commit is contained in:
Romain Prieto 2014-11-29 17:06:13 +11:00
parent 92c6d6b9d3
commit c72f46e463
5 changed files with 16 additions and 8 deletions

Binary file not shown.

View File

@ -19,6 +19,7 @@
"url": "https://github.com/rprieto/thumbsup.git"
},
"scripts": {
"clean": "rm -rf _site/*",
"example": "node bin/thumbsup --config example.json",
"open": "open _site/index.html"
},

View File

@ -32,7 +32,7 @@ exports.build = function(opts) {
buildStep({
message: 'Original media',
ext: 'jpg|jpeg|png|mp4|mov',
ext: 'jpg|jpeg|png|mp4|mov|mts',
dest: '/original/$path/$name.$ext',
func: fs.copy
}),
@ -52,22 +52,22 @@ exports.build = function(opts) {
}),
buildStep({
message: 'Videos (web)',
ext: 'mp4|mov',
message: 'Videos (resized)',
ext: 'mp4|mov|mts',
dest: '/large/$path/$name.mp4',
func: thumbs.videoWeb
}),
buildStep({
message: 'Videos (poster)',
ext: 'mp4|mov',
ext: 'mp4|mov|mts',
dest: '/large/$path/$name.jpg',
func: thumbs.videoLarge
}),
buildStep({
message: 'Videos (thumbs)',
ext: 'mp4|mov',
ext: 'mp4|mov|mts',
dest: '/thumbs/$path/$name.jpg',
func: thumbs.videoSquare
}),

View File

@ -27,7 +27,7 @@ exports.update = function(opts, callback) {
nonull: false,
nocase: true
};
glob('**/*.{jpg,jpeg,png,mp4,mov}', globOptions, callback);
glob('**/*.{jpg,jpeg,png,mp4,mov,mts}', globOptions, callback);
}
function pathAndDate(filePath, next) {
@ -78,7 +78,7 @@ exports.update = function(opts, callback) {
}
function mediaType(fileInfo) {
return fileInfo.relative.match(/\.(mp4|mov)$/i) ? 'video' : 'photo';
return fileInfo.relative.match(/\.(mp4|mov|mts)$/i) ? 'video' : 'photo';
}
findFiles(function(err, files) {

View File

@ -1,4 +1,5 @@
var exec = require('child_process').exec;
var path = require('path');
var gm = require('gm');
var async = require('async');
@ -27,7 +28,13 @@ exports.photoLarge = function(src, dest, callback) {
// Web-streaming friendly video
exports.videoWeb = function(src, dest, callback) {
var ffmpeg = 'ffmpeg -i "' + src + '" -vcodec libx264 -ab 96k -vb 1200k -y "'+ dest +'"';
var ffmpeg = 'ffmpeg -i "' + src + '" -y "'+ dest +'" -f mp4 -vcodec libx264 -ab 96k';
// AVCHD/MTS videos need a full-frame export to avoid interlacing artefacts
if (path.extname(src).toLowerCase() === '.mts') {
ffmpeg += ' -vf yadif=1 -qscale:v 4';
} else {
ffmpeg += ' -vb 1200k';
}
exec(ffmpeg, callback);
};