fluent-ffmpeg / node-fluent-ffmpeg

A fluent API to FFMPEG (http://www.ffmpeg.org)
MIT License
7.92k stars 880 forks source link

onProgress not triggering #199

Closed nodeGarden closed 10 years ago

nodeGarden commented 10 years ago

The onProgress event is not triggering for me, but nor is there any error.

Code:

var ffmpeg = require('fluent-ffmpeg');
var Metalib = require('fluent-ffmpeg').Metadata(path_video+video, function(meta){
        log("info", "Meta:");
        console.log(meta);
        var proc = new ffmpeg({ source: path_video+video }, convertComplete)
            .withAudioBitrate('128k')
            .withAudioCodec('libmp3lame')
            .toFormat('mp3')
            .onProgress(function(progress) {
                console.log("PROGRESS => ");
                console.log(progress);
            })
            .saveToFile(path_track+serviceID+'.mp3', function(stdout, stderr) {
                log('info', 'file has been converted succesfully');
            });
    });

Gives me the following output:

[info] :: Meta:
{ ffmpegversion: '2.1.3',
  title: '',
  artist: '',
  album: '',
  track: '',
  date: '',
  durationraw: '00:04:59.21',
  durationsec: 299,
  synched: true,
  major_brand: 'mp42',
  video:
   { container: 'mov',
     bitrate: 384,
     codec: 'h264',
     resolution: { w: 320, h: 240 },
     resolutionSquare: { w: 320, h: 240 },
     rotate: 0,
     fps: 29.97,
     stream: 0,
     aspectString: '4:3',
     aspect: 1.3333333333333333,
     pixelString: '1:1',
     pixel: 1 },
  audio: { codec: 'aac', bitrate: 95, sample_rate: 44100, stream: 0 } }
[info] :: file has been converted succesfully

So it appears the meta data is processed correctly, so it has its duration and codec. I just ran updates to ffmpeg.

OSX Mavericks 10.9 Brew-installed FFMPEG v2.1.3 Node v0.10.15 NPM v1.3.5 Fluent-FFMPEG v1.5.2

bencevans commented 10 years ago

I've just looked on Travis and our test that coveres onProgress is passing:

https://travis-ci.org/schaermu/node-fluent-ffmpeg/jobs/18623287#L553 (Line 553) https://github.com/schaermu/node-fluent-ffmpeg/blob/master/test/processor.test.js#L59

I've just tried it locally and experienced the same as you however I can't dive any deeper into the issue at the moment.

A couple of things worth trying:

If you could report on your results that would be excellent!

nodeGarden commented 10 years ago

Grabbed Master branch, and ran tests (after installing dependencies):

08:03 ~/dev/mondo/node-fluent-ffmpeg (master) $ make test

  Command
    usingPreset
      ✓ should properly generate the command for the requested preset
      ✓ should throw an exception when a preset it not found
    withNoVideo
      ✓ should apply the skip video argument
      1) should skip any video transformation options
    withNoAudio
      ✓ should apply the skip audio argument
      ✓ should skip any audio transformation options
    withVideoBitrate
      2) should apply default bitrate argument by default
      3) should apply additional bitrate arguments for CONSTANT_BITRATE
    withSize
      ✓ should calculate the missing size part (height)
      ✓ should calculate the missing size part (width)
      ✓ should calculate the size based on a percentage
    applyAutopadding
      ✓ should apply color if provided
      ✓ should calculate the correct size for output video stream
      ✓ should calculate the correct aspect ratio if omitted in favor of size
      ✓ should calculate size if a fixed width and an aspect ratio is provided
      ✓ should calculate size if a fixed height and an aspect ratio is provided
    withMultiFile
      ✓ should allow image2 multi-file input format
    withFps
      ✓ should apply the rate argument
    addingAdditionalInput
      ✓ should allow for additional inputs
    withAspect
      ✓ should apply the aspect ratio argument
    withVideCodec
      ✓ should apply the video codec argument
    withAudioBitrate
      4) should apply the audio bitrate argument
    loop
      ✓ should add the -loop 1 argument
      ✓ should add the -loop 1 and a time argument (seconds)
      ✓ should add the -loop 1 and a time argument (timemark)
    takeFrames
      ✓ should add the -vframes argument
    withAudioCodec
      ✓ should apply the audio codec argument
    withAudioChannels
      ✓ should apply the audio channels argument
    withAudioFrequency
      ✓ should apply the audio frequency argument
    withAudioQuality
      ✓ should apply the audio quality argument
    setStartTime
      ✓ should apply the start time offset argument
    setDuration
      ✓ should apply the record duration argument
    addOption(s)
      ✓ should apply a single option
      ✓ should apply supplied extra options
    toFormat
      ✓ should apply the target format

  Debug
    getArgs
      ✓ should properly return arguments in callback
    getCommand
      ✓ should properly compile options into an ffmpeg command line call

  Extensions
    toAspectRatio
      ✓ should convert an aspect ratio string to a proper object
      ✓ should return undefined when an invalid aspect ratio is passed
    parseVersionString
      ✓ should parse the major/minor/patch version correctly
    atLeastVersion
      ✓ should correctly compare a full version number
      ✓ should correctly compare a version number without patch version
      ✓ should correctly compare a major version number
      ✓ should correctly compare an exact version match
    ffmpegTimemarkToSeconds
      ✓ should correctly convert a simple timestamp
      ✓ should correctly convert a complex timestamp
      ✓ should correclty convert a simple float timestamp

  Processor
    ✓ should properly limit niceness
    ✓ should report codec data through event onCodecData (120ms)
    ✓ should report progress through event onProgress (14635ms)
    ✓ should properly take a certain amount of screenshots at defined timemarks (116ms)
    ✓ should report all generated filenames in the second callback argument (109ms)
    ✓ should save the output file properly to disk using a stream (153ms)
    ✓ should kill the process on timeout (47ms)
    saveToFile
      ✓ should save the output file properly to disk (117ms)
      ✓ should accept a stream as its source (135ms)
    mergeToFile
      ✓ should merge multiple files (116ms)
    writeToStream
      ✓ should save the output file properly to disk using a stream (159ms)
      ✓ should accept a stream as its source (160ms)
    takeScreenshot
      ✓ should return error with wrong size

  Registry
    set
      ✓ should set a value in the global registry
      ✓ should update a value that was already set
    set
      ✓ should return the value for a certain key from the global registry
      ✓ should return false when key is not present

  60 passing (16s)
  4 failing

  1) Command withNoVideo should skip any video transformation options:
     Uncaught AssertionError: expected -1 to be above -1
      at Assertion.prop.(anonymous function) [as greaterThan] (/usr/local/lib/node_modules/should/lib/should.js:60:14)
      at /Users/mondo/dev/mondo/node-fluent-ffmpeg/test/args.test.js:65:38
      at /Users/mondo/dev/mondo/node-fluent-ffmpeg/lib/debug.js:37:13
      at /Users/mondo/dev/mondo/node-fluent-ffmpeg/lib/fluent-ffmpeg.js:304:11
      at /Users/mondo/dev/mondo/node-fluent-ffmpeg/lib/metadata.js:174:7
      at /Users/mondo/dev/mondo/node-fluent-ffmpeg/node_modules/exec-queue/index.js:22:13
      at ChildProcess.exithandler (child_process.js:641:7)
      at ChildProcess.EventEmitter.emit (events.js:98:17)
      at maybeClose (child_process.js:735:16)
      at Socket.<anonymous> (child_process.js:948:11)
      at Socket.EventEmitter.emit (events.js:95:17)
      at Pipe.close (net.js:466:12)

  2) Command withVideoBitrate should apply default bitrate argument by default:
     AssertionError: expected -1 to be above -1
      at Assertion.prop.(anonymous function) [as greaterThan] (/usr/local/lib/node_modules/should/lib/should.js:60:14)
      at /Users/mondo/dev/mondo/node-fluent-ffmpeg/test/args.test.js:99:37
      at /Users/mondo/dev/mondo/node-fluent-ffmpeg/lib/debug.js:37:13
      at FfmpegCommand.FfmpegCommand._prepare (/Users/mondo/dev/mondo/node-fluent-ffmpeg/lib/fluent-ffmpeg.js:308:7)
      at FfmpegCommand.Debug.command.getArgs (/Users/mondo/dev/mondo/node-fluent-ffmpeg/lib/debug.js:28:12)
      at Context.<anonymous> (/Users/mondo/dev/mondo/node-fluent-ffmpeg/test/args.test.js:98:10)
      at Test.Runnable.run (/usr/local/lib/node_modules/mocha/lib/runnable.js:204:15)
      at Runner.runTest (/usr/local/lib/node_modules/mocha/lib/runner.js:374:10)
      at /usr/local/lib/node_modules/mocha/lib/runner.js:452:12
      at next (/usr/local/lib/node_modules/mocha/lib/runner.js:299:14)
      at /usr/local/lib/node_modules/mocha/lib/runner.js:309:7
      at next (/usr/local/lib/node_modules/mocha/lib/runner.js:247:23)
      at Object._onImmediate (/usr/local/lib/node_modules/mocha/lib/runner.js:276:5)
      at processImmediate [as _immediateCallback] (timers.js:330:15)

  3) Command withVideoBitrate should apply additional bitrate arguments for CONSTANT_BITRATE:
     AssertionError: expected -1 to be above -1
      at Assertion.prop.(anonymous function) [as greaterThan] (/usr/local/lib/node_modules/should/lib/should.js:60:14)
      at /Users/mondo/dev/mondo/node-fluent-ffmpeg/test/args.test.js:107:37
      at /Users/mondo/dev/mondo/node-fluent-ffmpeg/lib/debug.js:37:13
      at FfmpegCommand.FfmpegCommand._prepare (/Users/mondo/dev/mondo/node-fluent-ffmpeg/lib/fluent-ffmpeg.js:308:7)
      at FfmpegCommand.Debug.command.getArgs (/Users/mondo/dev/mondo/node-fluent-ffmpeg/lib/debug.js:28:12)
      at Context.<anonymous> (/Users/mondo/dev/mondo/node-fluent-ffmpeg/test/args.test.js:106:10)
      at Test.Runnable.run (/usr/local/lib/node_modules/mocha/lib/runnable.js:204:15)
      at Runner.runTest (/usr/local/lib/node_modules/mocha/lib/runner.js:374:10)
      at /usr/local/lib/node_modules/mocha/lib/runner.js:452:12
      at next (/usr/local/lib/node_modules/mocha/lib/runner.js:299:14)
      at /usr/local/lib/node_modules/mocha/lib/runner.js:309:7
      at next (/usr/local/lib/node_modules/mocha/lib/runner.js:247:23)
      at Object._onImmediate (/usr/local/lib/node_modules/mocha/lib/runner.js:276:5)
      at processImmediate [as _immediateCallback] (timers.js:330:15)

  4) Command withAudioBitrate should apply the audio bitrate argument:
     AssertionError: expected -1 to be above -1
      at Assertion.prop.(anonymous function) [as greaterThan] (/usr/local/lib/node_modules/should/lib/should.js:60:14)
      at /Users/mondo/dev/mondo/node-fluent-ffmpeg/test/args.test.js:284:38
      at /Users/mondo/dev/mondo/node-fluent-ffmpeg/lib/debug.js:37:13
      at FfmpegCommand.FfmpegCommand._prepare (/Users/mondo/dev/mondo/node-fluent-ffmpeg/lib/fluent-ffmpeg.js:308:7)
      at FfmpegCommand.Debug.command.getArgs (/Users/mondo/dev/mondo/node-fluent-ffmpeg/lib/debug.js:28:12)
      at Context.<anonymous> (/Users/mondo/dev/mondo/node-fluent-ffmpeg/test/args.test.js:283:10)
      at Test.Runnable.run (/usr/local/lib/node_modules/mocha/lib/runnable.js:204:15)
      at Runner.runTest (/usr/local/lib/node_modules/mocha/lib/runner.js:374:10)
      at /usr/local/lib/node_modules/mocha/lib/runner.js:452:12
      at next (/usr/local/lib/node_modules/mocha/lib/runner.js:299:14)
      at /usr/local/lib/node_modules/mocha/lib/runner.js:309:7
      at next (/usr/local/lib/node_modules/mocha/lib/runner.js:247:23)
      at Object._onImmediate (/usr/local/lib/node_modules/mocha/lib/runner.js:276:5)
      at processImmediate [as _immediateCallback] (timers.js:330:15)

make: *** [test] Error 4
nodeGarden commented 10 years ago

I copied over the newer version of fluent-ffmpeg, and progress works. Yay. Closing this unless you want to re-open because of test results, which are still "true".

bencevans commented 10 years ago

Thanks, we've got the test output on Travis anyway so we'll leave this closed :smile: