Permalink
Browse files

fixed bug in version determination, fixed lint errors in metadata

  • Loading branch information...
1 parent d4cac2c commit b85526494d36067d337ad3890d67f8b2b076f027 @schaermu schaermu committed Jul 3, 2012
Showing with 17 additions and 14 deletions.
  1. +2 −1 grunt.js
  2. +14 −12 lib/metadata.js
  3. +1 −1 test/coverage.html
View
@@ -21,7 +21,8 @@ module.exports = function(grunt) {
undef: true,
boss: true,
eqnull: true,
- node: true
+ node: true,
+ laxcomma: true
},
globals: {
exports: true
View
@@ -58,14 +58,16 @@ exports = module.exports = function Metadata(inputfile) {
, is_synched = (/start: 0.000000/.exec(stderr) !== null)
, rotate = /rotate[\s]+:[\s]([\d]{2,3})/.exec(stderr) || none
, getVersion = /ffmpeg version (?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)/i.exec(stderr)
- , ffmpegVersion = 0
+ , ffmpegVersion = 0;
if (getVersion) {
ffmpegVersion = [
- getVersion[1]||0,
- getVersion[2]||0,
- getVersion[3]||0
- ].join('.')
+ getVersion[1]>=0 ? getVersion[1] : null,
+ getVersion[2]>=0 ? getVersion[2] : null,
+ getVersion[3]>=0 ? getVersion[3] : null
+ ].filter(function(val) {
+ return val !== null;
+ }).join('.');
}
// build return object
@@ -84,30 +86,30 @@ exports = module.exports = function Metadata(inputfile) {
, bitrate: (video_bitrate.length > 1) ? parseInt(video_bitrate[1], 10) : 0
, codec: video_codec[1] || ''
, resolution: {
- w: resolution.length > 2 ? parseInt(resolution[2]) : 0
- , h: resolution.length > 3 ? parseInt(resolution[3]) : 0
+ w: resolution.length > 2 ? parseInt(resolution[2], 10) : 0
+ , h: resolution.length > 3 ? parseInt(resolution[3], 10) : 0
}
- , rotate: rotate.length > 1 ? parseInt(rotate[1]) : 0
+ , rotate: rotate.length > 1 ? parseInt(rotate[1], 10) : 0
, fps: fps.length > 1 ? parseFloat(fps[1]) : 0.0
, stream: video_stream.length > 1 ? parseFloat(video_stream[1]) : 0.0
}
, audio: {
codec: audio_codec[1] || ''
- , bitrate: audio_bitrate.length > 1 ? parseInt(audio_bitrate[1]) : 0
- , sample_rate: sample_rate.length > 1 ? parseInt(sample_rate[1]) : 0
+ , bitrate: audio_bitrate.length > 1 ? parseInt(audio_bitrate[1], 10) : 0
+ , sample_rate: sample_rate.length > 1 ? parseInt(sample_rate[1], 10) : 0
, stream: audio_stream.length > 1 ? parseFloat(audio_stream[1]) : 0.0
}
};
if (channels.length > 0) {
- ret.audio.channels = {stereo:2, mono:1}[channels[1]] || 0
+ ret.audio.channels = {stereo:2, mono:1}[channels[1]] || 0;
}
// save aspect ratio for auto-padding
if (aspect.length > 0) {
ret.video.aspectString = aspect[1];
var n = aspect[1].split(":");
- ret.video.aspect = parseFloat((parseInt(n[0]) / parseInt(n[1])).toFixed(2));
+ ret.video.aspect = parseFloat((parseInt(n[0], 10) / parseInt(n[1], 10)).toFixed(2));
} else {
if(ret.video.resolution.w !== 0) {
ret.video.aspect = parseFloat((ret.video.resolution.w / ret.video.resolution.h).toFixed(2));
View

0 comments on commit b855264

Please sign in to comment.