fluent-ffmpeg / node-fluent-ffmpeg Goto Github PK
View Code? Open in Web Editor NEWA fluent API to FFMPEG (http://www.ffmpeg.org)
License: MIT License
A fluent API to FFMPEG (http://www.ffmpeg.org)
License: MIT License
Is there a way to do this? I can't seem to find a way. Thanks.
We keep our node.js server in subversion and the .svn folder was breaking the .forEach loop that includes the presets. (fluent-ffmpeg.js). (Sorry I've never used github, but I wanted to report this so someone that works on it can include it in future releases).
We added this to make it not crash on us:
fs.readdirSync(__dirname + '/presets').forEach(function(file) {
var modname = file.substring(0, file.length - 3);
+ if (file.substring(0, 1) == '.') {
+ return true;
+ }
var preset = require('./presets/' + modname);
if (typeof preset.load == 'function') {
presets[modname] = preset;
}
});
Edit for markup
I found that using both applyAutopadding
and withAspect
together sometimes results in a 0-byte file. For example:
.withAspect('16:9')
.withSize('?x360')
.applyAutopadding(true)
I'm a little unclear on what exactly the failure conditions are, but when using it on an 852x480 input it fails. At first I assumed it had only to do with the aspect ratio, but I don't get the failure condition when testing with a 640x360 input.
Currently if you run you get an error about input file being undefined. The problem is due to this refering to the global object instead of to the options object.
The fix is to use self instead of this, the author already set var self = this up and just forgot to use it; just a simple typo. The fix will be applied to Processor.js line 242.
Here is the change with some context
https://gist.github.com/1728346
Have to look into a more generic way to handle os-independant checks for tool availability (flvtool2 or nice).
var ffmpeg = require('fluent-ffmpeg'),
proc;
proc = new ffmpeg({ source: '/Users/nicholas/Music/KYPO.aif' })
.withAudioCodec('libmp3lame')
.withAudioBitrate('64k')
.withAudioChannels(2);
proc.saveToFile('/Users/nicholas/KYPO.mp3', function(retCode, err) {
console.log(retCode);
console.log(err);
});
The code above times out, sending a -99 WARN error.
I'm posting this as an issue, but I am willing to help you out as well with a pull request. I first want to know if you agree on this issue, or maybe you prefer to do it yourself if so.
The callback is called both on a successful conversion and on a failure. Normally, one would do something like if (err) { // conversion failed somehow }
. At the moment, it is not possible to programatically detect a failed convertion because the error object simply contains all data send to ffmpeg's process' stderr
channel.
Unfortunately the data send to stderr
is almost not parseable, as it contains all kinds of debugging information rather than something like {conversionStatus : 0, msg : 'conversion failed', reason: 'libvorbis library not found'}
.
For me it is of crucial importance to be able to detect whether conversion succeeded, as I need to inform my users if not (even better would be if I could tell them why not, although this is not mandatory).
Do you agree this is an issue? Do you have any ideas or suggestions on how this could be improved?
Has to be able to accept most common loggers as a facility, no custom implementation.
implement adapters for
I did an NPM install of fluent-ffmpeg on both OSX lion and CentOS.
I've tried all the examples with no success:
Error: Source is not a ReadableStream
at new FfmpegCommand (/home/alloyking/nodeJS/node_modules/fluent-ffmpeg/lib/fluent-ffmpeg.js:20:13)
at new (/home/alloyking/nodeJS/node_modules/fluent-ffmpeg/lib/fluent-ffmpeg.js:240:10)
at Object. (/home/alloyking/nodeJS/app.js:3:12)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:31)
at Function._load (module.js:308:12)
at Array.0 (module.js:479:10)
at EventEmitter._tickCallback (node.js:192:40)
The only thing that I has not produced an error is when pulling Metadata.
So I built my own preset that simply converted an AVI to an MP4. I tested the script in the terminal with success, but within fluent-ffmpeg it still shows not a ReadableStream.
Any advice?
Hey somehow i dont get it to work properly. My ffmpeg was an installation for airVideo, so maybe that's the problem? Can you look over it and maybe say what i'm doing wrong?
Thanks for your great engagement to do a cool wrapper.
Spruce
Error thrown of actual code
Error: meta data contains no duration, aborting screenshot creation
at module.exports.takeScreenshots.screenshotcount (/home/spruce/fbrowser/node_modules/fluent-ffmpeg/lib/processor.js:345:27)
at FfmpegCommand._prepare (/home/spruce/fbrowser/node_modules/fluent-ffmpeg/lib/fluent-ffmpeg.js:297:9)
at module.exports._loadDataInternal (/home/spruce/fbrowser/node_modules/fluent-ffmpeg/lib/metadata.js:165:7)
at ChildProcess.exithandler (child_process.js:544:7)
at ChildProcess.EventEmitter.emit (events.js:99:17)
at maybeClose (child_process.js:638:16)
at Process._handle.onexit (child_process.js:680:5)
your example of getting meta info
{ ffmpegversion: 0,
title: '',
artist: '',
album: '',
track: '',
date: '',
durationraw: '',
durationsec: 0,
synched: false,
major_brand: undefined,
video:
{ container: '',
bitrate: 0,
codec: '',
resolution: { w: 0, h: 0 },
resolutionSquare: { w: 0, h: NaN },
rotate: 0,
fps: 0,
stream: 0,
aspect: 0,
pixel: 0 },
audio: { codec: '', bitrate: 0, sample_rate: 0, stream: 0 } }
Output off ffmpeg -i filmname.mkv
ffmpeg version UNKNOWN, Copyright (c) 2000-2011 the FFmpeg developers
built on Apr 27 2012 01:14:46 with gcc 4.4.5
configuration: --enable-pthreads --disable-shared --enable-static --enable-gpl --enable-libx264 --enable-libmp3lame --disable-decoder=aac
libavutil 51. 2. 1 / 51. 2. 1
libavcodec 53. 3. 0 / 53. 3. 0
libavformat 53. 0. 3 / 53. 0. 3
libavdevice 53. 0. 0 / 53. 0. 0
libavfilter 2. 4. 0 / 2. 4. 0
libswscale 0. 14. 0 / 0. 14. 0
[matroska,webm @ 0x1cecd60] Estimating duration from bitrate, this may be inaccurate
Input #0, matroska,webm, from 'filmname.mkv':
Duration: 01:23:05.53, start: 0.000000, bitrate: 1760 kb/s
Chapter #0.0: start 0.000000, end 242.283000
Metadata:
title : Chapter.01
Chapter #0.1: start 242.283000, end 614.322000
Metadata:
title : Chapter.02
Chapter #0.2: start 614.322000, end 947.905000
Metadata:
title : Chapter.03
Chapter #0.3: start 947.905000, end 1226.642000
Metadata:
title : Chapter.04
Chapter #0.4: start 1226.642000, end 1627.000000
Metadata:
title : Chapter.05
Chapter #0.5: start 1627.000000, end 1819.984000
Metadata:
title : Chapter.06
Chapter #0.6: start 1819.984000, end 2103.017000
Metadata:
title : Chapter.07
Chapter #0.7: start 2103.017000, end 2470.926000
Metadata:
title : Chapter.08
Chapter #0.8: start 2470.926000, end 2714.712000
Metadata:
title : Chapter.09
Chapter #0.9: start 2714.712000, end 2994.449000
Metadata:
title : Chapter.10
Chapter #0.10: start 2994.449000, end 3241.821000
Metadata:
title : Chapter.11
Chapter #0.11: start 3241.821000, end 3522.185000
Metadata:
title : Chapter.12
Chapter #0.12: start 3522.185000, end 3819.232000
Metadata:
title : Chapter.13
Chapter #0.13: start 3819.232000, end 4073.778000
Metadata:
title : Chapter.14
Chapter #0.14: start 4073.778000, end 4491.737000
Metadata:
title : Chapter.15
Chapter #0.15: start 4491.737000, end 4491.737000
Metadata:
title : Chapter.16
Stream #0.0: Video: h264 (High), yuv420p, 1280x534 [PAR 1:1 DAR 640:267], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc
Stream #0.1(ger): Audio: ac3, 48000 Hz, stereo, s16, 224 kb/s (default)
Metadata:
title : 2.0 AC3MD THX to TwixX
Stream #0.2(eng): Audio: dca (DTS), 48000 Hz, 5.1, s16, 1536 kb/s
At least one output file must be specified
In the examples, every case given is with a static file. Is there any way to feed in a "dshow" source into node-fluent-ffmpeg and use it to kick off a live streaming session?
Hi, first thanks for that module, very handy.
I've been trying to get screenshots of some videos but it happens that the result was not enough precise. I found that TimemarkToSeconds function floors the result of the duration.
this.ffmpegTimemarkToSeconds = function(timemark) {
...
// split sec/msec part
var secParts = parts[2].split('.');
// add seconds
secs += parseInt(secParts[0], 10);
'You dont add msec part.'
return secs;
};
The problem is that, in the screenshots function you use durationsec to calculate the frame i want so i'm not able to get the last one when i put '100%'
timemarks[i] = (parseInt(timemarks[i], 10) / 100) * meta.durationsec;
Is there any particular reason to drop the milliseconds part in timemarkToSeconds ?
The error message I get is:
child_process.js:413
throw new Error('customFds not yet supported');
^
Error: customFds not yet supported
at setStreamOption (child_process.js:413:13)
at ChildProcess.spawn (child_process.js:425:3)
at child_process.js:343:9
at FfmpegCommand._spawnProcess (***/node_modules/fluent-ffmpeg/lib/processor.js:278:19)
at ***/node_modules/fluent-ffmpeg/lib/processor.js:90:33
at ***/node_modules/fluent-ffmpeg/lib/fluent-ffmpeg.js:221:9
at ***/node_modules/fluent-ffmpeg/lib/metadata.js:88:9
at ChildProcess.exithandler (child_process.js:287:7)
at ChildProcess.emit (events.js:70:17)
at maybeExit (child_process.js:361:16)
Tried to pass FD instead of stream, but it didn't work either.
The path to ffmpeg in processor.js is hard coded to ffmpeg. When running node,js from a cron job on a shared server, ffmpeg may not be in a path available to cron and so it can not be run. For example the path to ffmpeg on my shared server is /usr/local/bin/ffmpeg. When the cron job runs, node cannot find ffmpeg because it is not in the path used by cron. I do not have root access to add ffmpeg to the PATH used by cron.
If I replace 'ffmpeg' with '/usr/local/bin/ffmpeg' in processor.js it works.
I would like a method in the api to specify the location of ffmpeg so I don't have to modify processor.js.
Thanks,
Dale
At line 210: https://github.com/schaermu/node-fluent-ffmpeg/blob/master/lib/processor.js#L210
There is a typo '7' at the end of the line, and two other problems:
On a side note, can you execute renice immediately without waiting for a callback from the spawn command (if there is such thing)? Aka, does that process exist immediately after calling spawn?
Finally, should there be a check if 'nice' or 'renice' exists on the system during initialization, eg. for when node is available on windows?
Since _prepare does asynchronous operations before piping the input stream to ffmpeg stdin, some data events are missed. The stream is being paused but that does not guarantee data events won't happen as discussed here.
The solution is to buffer the data events in memory while _prepare does its thing.
Hi,
FFmpeg has an option to drop audio completely and that's achieved using "-an", so an option like .withNoAudio() that would pass "-an" to FFmpeg would do the job.
Regards,
Krenar
I'm sure something is still going wrong with the file descriptors. Anyway, the synchronized file descriptor closing methods you were using were causing the following error:
return binding.close(fd);
^
Error: EBADF, Bad file descriptor
at Object.closeSync (fs.js:192:18)
at ChildProcess.<anonymous> (/media/sda3/Workspaces/Node.js/node-fluent-ffmpeg/lib/processor.js:118:18)
at ChildProcess.emit (events.js:67:17)
at ChildProcess.onexit (child_process.js:192:12)
Apparently, the fd was properly closed already. I fixed this by making the call asynchronous (which it should be anyway), like so:
ffmpegProc.on('exit', function(code, signal) {
if (processTimer) clearTimeout(processTimer);
// close file descriptor on outstream
fs.close(stream.fd, function() {
if (self.options.inputstream) {
fs.close(self.options.inputstream.fd, function() {
callback(code, stderr);
});
}
else {
callback(code, stderr);
}
});
});
Unfortunately a 5Mb mp3 is only converted to 23KB of ogg audio, which plays for about 1 second. The awkward thing is that retcode is 0 indiciating a normal termination of ffmpeg. This is the output:
DEBUG: inputStream end event: stream received EOF, no more data events DEBUG: inputStream close event: file descriptor has been closed DEBUG: input stream written to write stream successfully, err: ffmpeg version git-N-30727-gd127d26, Copyright (c) 2000-2011 the FFmpeg developers built on Jun 12 2011 14:49:21 with gcc 4.4.5 configuration: --disable-encoder=vorbis --enable-libvorbis libavutil 51. 8. 0 / 51. 8. 0 libavcodec 53. 7. 0 / 53. 7. 0 libavformat 53. 3. 1 / 53. 3. 1 libavdevice 53. 1. 1 / 53. 1. 1 libavfilter 2. 15. 1 / 2. 15. 1 libswscale 0. 14. 1 / 0. 14. 1 [NULL @ 0x3251400] Format mp3 detected only with low score of 25, misdetection possible! [mp3 @ 0x32533a0] Header missing [mp3 @ 0x3251400] Estimating duration from bitrate, this may be inaccurate Input #0, mp3, from 'pipe:': Duration: N/A, start: 0.000000, bitrate: 160 kb/s Stream #0.0: Audio: mp3, 44100 Hz, stereo, s16, 160 kb/s Output #0, ogg, to 'pipe:1': Metadata: encoder : Lavf53.3.1 Stream #0.0: Audio: libvorbis, 44100 Hz, stereo, s16, 64 kb/s Stream mapping: Stream #0.0 -> #0.0 [mp3 @ 0x32533a0] Header missing Error while decoding stream #0.0 [mp3 @ 0x32533a0] overread, skip -6 enddists: -2 -2 [mp3 @ 0x32533a0] overread, skip -7 enddists: -5 -5 [mp3 @ 0x32533a0] overread, skip -7 enddists: -3 -3 [mp3 @ 0x32533a0] Header missing Error while decoding stream #0.0 [mp3 @ 0x32533a0] incomplete frame Error while decoding stream #0.0 size= 24kB time=00:00:02.71 bitrate= 72.0kbits/s video:0kB audio:20kB global headers:4kB muxing overhead 1.083495%
You can see my code here: https://github.com/tommedema/NodeFFmpegTest/blob/master/main.js
Note that this is exactly the same input file as I used before, which was handled successfully.
Is there a way we can avoid polluting Object.prototype? Perhaps by namespacing?
I realize this may not be an issue specific to your project, it's more an issue of mine. If there is a better place to post this please tell me.
Anyway, I have created a simple test project using your library, called NodeFFmpegTest, as you can see here:
https://github.com/tommedema/NodeFFmpegTest/blob/master/main.js
The goal of this test is to provide a demo of converting an incoming audio stream (at the moment mp3) to a writable stream (currently ogg vorbis). This is a very common use case, for example to allow iPad users to listen to music in their browsers using HTML5's audio tag (it supports ogg vorbis, but not mp3).
Please look at the link above to see my simple code. The problem I face is that the input mp3 is about 5MB while by default, the output ogg vorbis file 28.8MB (yet it's supposed to be a highly optimized format for the web).
Strangely enough, the setAudioBitrate option does not seem to have any effect on file size. Could this be a bug? I've also tried setting the -ar option, which had the same result (or lack thereof).
Forcing mono sound (1 channel) instead of 2 did reduce the size to about 14MB, but this should not be necessary. This original MP3 is in stereo as well.
An audio frequency of 22050 did help, it reduced the size to 15.8MB, note that the MP3 apparently has a frequency of 44100Hz. As expected, a frequency of 11025 makes the sound quality horrible.
The -aq option (audio quality) appears to have no effect at all.
Have you experimented with such conversion? Any help would be greatly appreciated.
To convert corectly image and audiotrack to video I use the following command:
ffmpeg -loop 1 -i videoimage.jpg -i audio.mp3 -t 00:06:46.81 video.mp4 (ffmpeg --i videoimage.jpg -i audio.mp3 video.mp4 doesn't work for me)
How to implement this command with fluent-ffmpeg API?
Hello,
We are recently updated our node modules linking the latest version of [email protected].
Unfortunately, when I try to start my nodejs application, I get an error. Nodejs is not able to find the "fluent-ffmpeg" module.
I see the package.json file, and it seems to be correct, but I saw that in the package.json file the "main" key is set to "index" but my tree has not an index.js file in the root folder of fluent-ffmpeg.
Could you please have a look into this?
Maybe the npm remote module has temporary broken?
Thanks in advance
/home/andre/node-fluent-ffmpeg/test/conversion.test.js:41
test.ok(stats.size > 0);
^
TypeError: Cannot read property 'size' of undefined
the express streaming example also fails, the player shows stream not found, and browsing directly to the stream link downloads a 0 bytes file.
-using node v0.6.13
-using latest version of fluent-ffmpeg
-using debian squeeze with multimedia repo.
ffmpeg version 0.7.12, Copyright (c) 2000-2011 the FFmpeg developers
built on Apr 11 2012 07:40:07 with gcc 4.4.5
configuration: --enable-libdc1394 --prefix=/usr --extra-cflags='-Wall -g ' --cc='ccache cc' --enable-shared --enable-libmp3lame --enable-gpl --enable-libvorbis --enable-pthreads --enable-libfaac --enable-libxvid --enable-postproc --enable-x11grab --enable-libgsm --enable-libtheora --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-libspeex --enable-nonfree --disable-stripping --enable-avfilter --enable-libdirac --disable-decoder=libdirac --enable-libfreetype --enable-libschroedinger --disable-encoder=libschroedinger --enable-version3 --enable-libopenjpeg --enable-libvpx --enable-librtmp --extra-libs=-lgcrypt --disable-altivec --disable-armv5te --disable-armv6 --disable-vis
libavutil 50. 43. 0 / 50. 43. 0
libavcodec 52.123. 0 / 52.123. 0
libavformat 52.111. 0 / 52.111. 0
libavdevice 52. 5. 0 / 52. 5. 0
libavfilter 1. 80. 0 / 1. 80. 0
libswscale 0. 14. 1 / 0. 14. 1
libpostproc 51. 2. 0 / 51. 2. 0
I recently updated fffmpeg. My addOptions now don't work. ffmpeg can't parse them. Can someone tell me what I'm doing wrong here?
proc.addOptions [
'-y', '-ac 2', '-ar 48000', '-bf 0', '-refs 1', '-wpred-dct8x8', '-flags2'
'-level 30', '-maxrate 10M', '-bufsize 10M'
'-g ' + (Math.ceil origVideoMeta.video.fps)
]
Wish I had more info about what is going on but the title about says it. Whenever I require it, it seems to work properly but it seems as if it doesnt "close" a connection or process as node will peak at 100% and disallow any further interaction.
While I can convert a single image into a video from the command line, nothing that I tried with fluent-ffmpeg worked for me. This is the simple command line call:
ffmpeg -i 'image.jpg' -r 1 out.mp4
It should produce a one second video, but, either I couldn't figure out the proper syntax, or this library is unable to do this.
Is there a way to use any arbitrary option when processing? For example, I don't see an option for transposition, and It would be nice if I could just pass in -vf transpose=2
.
I want to use the calculate module like the metadata module since resizing ogv videos currently breaks with ffmpeg (so I've found). I tested out video resizing with ffmpeg2theora and it works great, so I want to be able to use the nice API provided by fluent to dynamically calculate the video resolutions (a-la 420x?, x?200, 50%). I already did a rough cut of this as a proof of concept, you can see it here. I'm going to clean it up and send a PR, I think this is the easiest solution for ogv video's right now. That is unless you want to incorporate ffmpeg2theora to fluent in the future, I'm not sure what else that program offers though, I'm not too familiar with it.
I did a npm install fluent-ffmpeg
on Ubuntu 10.10, and this version throws the following error when I tried a simple mp3 to ogg conversion.
Error: Source is not a ReadableStream
at new FfmpegCommand (/home/kishore/Others/app/node_modules/fluent-ffmpeg/lib/fluent-ffmpeg.js:21:13)
at new <anonymous> (/home/kishore/Others/app/node_modules/fluent-ffmpeg/lib/fluent-ffmpeg.js:241:10)
at convertFile (/home/kishore/Others/app/test.js:6:16)
at Object.<anonymous> (/home/kishore/Others/app/test.js:23:1)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:31)
at Function._load (module.js:308:12)
at Array.0 (module.js:479:10)
at EventEmitter._tickCallback (node.js:192:40)
This is the simple program I tried (modified from one of the examples):
var fs = require('fs'),
ffmpeg = require('fluent-ffmpeg');
function convertFile(fPath) {
console.log('Converting file: '+fPath);
var proc = new ffmpeg({
// input source, required
source: fPath,
// timout of the spawned ffmpeg sub-processes in seconds (optional, defaults to 30)
timeout: 30,
// default priority for all ffmpeg sub-processes (optional, defaults to 0 which is no priorization)
priority: 0,
// set a custom [winston](https://github.com/flatiron/winston) logging instance (optional, default null which will cause fluent-ffmpeg to spawn a winston console logger)
logger: null,
// completely disable logging (optional, defaults to false)
nolog: false
});
proc.saveToFile(fPath.substr(0, fPath.lastIndexOf('.')) + '.ogg', function(retcode, error) {
console.log('file has been converted succesfully');
});
}
convertFile('/home/kishore/test.mp3');
I believe the examples do not work on 0.3.0? I then did a npm install of the master tarball and the file conversion worked.
When using the sample express-stream.js with NodeJS 0.4.9 or latest version and ffmpeg latest release or from latest code, with latest express, on Ubuntu 10.04, there are few issues:
This makes me think: Is the lib code aligned with this sample?
Thanks,
Mike
I use the takeScreenshots feature but I find it slightly inconvenient to use. I have to namespace my files in a dictionary since I have no option to supply a prefix for the files to make them unique. This causes me to make/delete directories for all videos. I would like to be able to pass in an optional file name prefix to solve this.
Then when the screenshot(s) are generated I need to find out what their name are. The naming formula is rather simple but even if I ask for specific times or know the duration of the video there is no guaranty you can know what the file name will be. I would suggest that the takeScreenshots callback is invoked with a second argument containing a list of file names generated.
Thanks
I'm working on a project and I'd like to implement an interface where I can pass the stream of a .mov file to fluent and let ffmpeg do it's thing converting/stripping video/etc. However, it doesn't look like ffmpeg supports streaming .mov files via stdin in this way, see this thread: http://ffmpeg-users.933282.n4.nabble.com/STDIN-amp-QuickTime-Movie-Part-Deux-td937297.html. I tried to google around as much as possible, that's all I could find on this topic.
I was thinking about implementing a .mov stream check within fluent, if the stdin is a .mov stream (by checking file extention?), simply pipe the stream to a temporary file, pass it to ffmpeg, let it process, then return a stream. Ideally it would stay a stream the whole way, but since ffmpeg can't handle .mov streams I was thinking this would be an acceptable work around. If this is something you think belongs in fluent I can implement it, otherwise I'll figure something else out in my application logic. At the very least I think it would be helpful to have an error message saying .mov streams on stdin aren't supported, since ffmpeg doesn't really spell that out.
I can create a pull request for this if you like.
At the moment, you are checking for available libraries during every spawn (eg. exec('which flvtool2', ...
) while this only has to be done during initialization, after which a boolean can be set (eg. flvtool2Found = true/false
).
Hi,
FFmpeg has built-in support for multithreading using "-thread ", so an option like .withThreads(n) that passes "-thread " to FFmpeg would do the job.
Regards,
Krenar
I'm trying to stitch several videos together, but node-fluent-ffmpeg doesn't seem to be able to perform the concat function. This is what I'm trying to accomplish:
ffmpeg -i input1.avi -qscale:v 1 intermediate1.mpg
ffmpeg -i input2.avi -qscale:v 1 intermediate2.mpg
ffmpeg -i concat:"intermediate1.mpg|intermediate2.mpg" -c copy intermediate_all.mpg
ffmpeg -i intermediate_all.mpg -qscale:v 2 output.avi
I've seen a few places where it's using synchronous I/O read (to load the presets for example), is there any rewrite of these planned?
The library expects this kind of input:
new ffmpeg('/path/to/your_movie.avi')
Thus, it expects the movie/audio to be stored on the server. When receiving an audio stream, it makes no sense to store this on the server if the goal is to immediately pipe it to another client. This is exactly what I need to do.
Instead of having to give a static file, I need the ability to input a read stream or supply ordered chunks whenever I have them.
Would this be difficult to implement?
Some fluent-ffmpeg functions (saveToFile or when creating Metadata object) work incorrectly with not normalized file paths on Windows (when you use slashes in path instead of backslashes), so user need to normalize it explicitly when passing to the functions.
Maybe it is better to use path.normalize inside fluent-ffmpeg.
Figure out some way to report the conversion progress to the user (maybe using stderr scanning for some patterns).
I'm not sure if this happens with all padded video but my output is not centered (majority of the black padding is on the right) when:
input = 270x480
.withAspect('16:9')
.withSize('?x480')
.applyAutopadding(true)
on timeout, callback will be called twice
fixing this right now...
I'm trying to convert mp3 to ogg with libvorbis.
/***/node_modules/fluent-ffmpeg/lib/metadata.js:80
ret.video.aspectString = aspect[1];
^
TypeError: Cannot read property '1' of null
at /var/www/player/node_modules/fluent-ffmpeg/lib/metadata.js:80:40
at ChildProcess.exithandler (child_process.js:287:7)
I'm using Windows 7 x64 with node 0.6.15 and I'm trying to get fluent to run in an express project. Whenever I require the fluent-ffmpeg library it maxes out one of my cpu cores and hangs until I restart the server.
I'm trying to use this inside one of my mongoose-js models to create a thumbnail before it saves the model. If I require the library at the top of the file, my app doesn't start.
If I require the library within the creation function the app starts and will execute the thumbnail command and give me what I'm after, but it will hang once this is completed.
Any ideas or anything you need me to do to help debug?
It seems that node-fluent-ffmpeg runs ffmpeg async,
so the writeToStream() of processor.js runs after my main.js is over.
I want to run ffmpeg with standard input, and bring data after.
but writeToStream() runs after others!
comments?
/Users/Firejune/Workspace/velox/node_modules/fluent-ffmpeg/lib/processor.js:235
if (!meta.durationsec) {`
^
TypeError: Cannot read property 'durationsec' of undefined
at module.exports.takeScreenshots.screenshotcount (/Users/Firejune/Workspace/velox/node_modules/fluent-ffmpeg/lib/processor.js:235:18)
at FfmpegCommand._prepare (/Users/Firejune/Workspace/velox/node_modules/fluent-ffmpeg/lib/fluent-ffmpeg.js:287:11)
at module.exports._loadDataInternal (/Users/Firejune/Workspace/velox/node_modules/fluent-ffmpeg/lib/metadata.js:163:7)
at ChildProcess.exithandler (child_process.js:544:7)
at ChildProcess.EventEmitter.emit (events.js:96:17)
at maybeClose (child_process.js:638:16)
at Socket.ChildProcess.spawn.stdin (child_process.js:815:11)
at Socket.EventEmitter.emit (events.js:93:17)
at Socket._destroy.destroyed (net.js:357:10)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)
I've got a rather complex problem here, which should be solveable in theory, but I am not sure whether ffmpeg allows for this to work out of the box.
Basically, what I need is to get the audio codec as soon as it is detected while having ffmpeg convert an incoming audio stream to a certain format.
The reason I need to get this audio codec while already converting it, is because I can only access this stream once and I do not want to buffer the initial chunks in memory so that I could use these first for audio codec detection and then for conversion.
If I detect a certain audio format, I want to stop the process.
In the end, this is the API that I need. I wonder if you can tell me whether this is possible:
new ffmpeg(inputStream)
.withAudioCodec('libvorbis')
.toFormat('ogg')
.informFileType(function(type, processor) {
if (type == 'ogg') processor.stop();
})
.writeToStream(outputStream, function(retcode, err) {
});
Note that this also requires a processor object with utility functions, which is why I'd also recommend a different construction API, but this is not compulsory:
var processor = ffmpeg.createProcessor(inputstream)
processor.on('done', function(retcode, err) { });
processor.on('timeout', function(err) { });
processor.on('fileType', function(type) { });
....
Could you tell me whether such informFileType
method is possible, or maybe a informAudioCodec
and informVideoCodec
is better?
I can create a pull request for this if you like.
Nice allows processes to be seen as less important by the kernel, see http://en.wikipedia.org/wiki/Nice_(Unix)
This can be really helpful as you do not want ffmpeg processes to slow down the webserver, especially when you're converting 50+ streams at a time.
Adding such priority as an optional parameter would fix this.
Hi,
Right now, fluent-ffmpeg uses -keyint_min for setting the framerate (@ https://github.com/schaermu/node-fluent-ffmpeg/blob/master/lib/processor.js#L433) and I think -r is the right option to be used.
Regards,
Krenar
Looks like the function should be .applyAutopadding(true, 'white')
Try catch blocks actually cost considerable performance: http://code.google.com/p/v8/issues/detail?id=1065
May I ask why these are in there at all? Can child processes throw exceptions?
I could create a pull request to fix this issue, but need to know what you think might throw an exception inbetween those blocks.
Tom
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.