Skip to content

Commit

Permalink
Merge pull request #83 from inaes-tic/master
Browse files Browse the repository at this point in the history
Fix onCodecData for newer ffmpeg
  • Loading branch information
schaermu committed Nov 28, 2012
2 parents eef4eba + e848639 commit 6b2e4fd
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions lib/processor.js
Expand Up @@ -396,18 +396,32 @@ exports = module.exports = function Processor(command) {
}; };


this._checkStdErrForCodec = function(stderrString) { this._checkStdErrForCodec = function(stderrString) {
var audio = /Audio\: ([^,]+)/.exec(stderrString); var format= /Input #[0-9]+, ([^ ]+),/.exec(stderrString);
var video = /Video\: ([^,]+)/.exec(stderrString); var dur = /Duration\: ([^,]+)/.exec(stderrString);
var codecObject = { audio: '', video: '' }; var audio = /Audio\: (.*)/.exec(stderrString);
var video = /Video\: (.*)/.exec(stderrString);
var codecObject = { format: '', audio: '', video: '', duration: '' };

if (format && format.length > 1) {
codecObject.format = format[1];
}

if (dur && dur.length > 1) {
codecObject.duration = dur[1];
}


if (audio && audio.length > 1) { if (audio && audio.length > 1) {
codecObject.audio = audio[1]; audio = audio[1].split(', ');
codecObject.audio = audio[0];
codecObject.audio_details = audio;
} }
if (video && video.length > 1) { if (video && video.length > 1) {
codecObject.video = video[1]; video = video[1].split(', ');
codecObject.video = video[0];
codecObject.video_details = video;
} }


var codecInfoPassed = /Press \[q\] to stop/.test(stderrString); var codecInfoPassed = /Press (\[q\]|ctrl-c) to stop/.test(stderrString);
if (codecInfoPassed) { if (codecInfoPassed) {
this.options.onCodecData(codecObject); this.options.onCodecData(codecObject);
this.options.onCodecData = null; this.options.onCodecData = null;
Expand Down

0 comments on commit 6b2e4fd

Please sign in to comment.