I want to transfer the file loaded in ffmpeg. I am using node.js and it does not work!
I ended up testing the ffmpeg input pipeline from the local file, and this also does not work. Here is my code:
var processVideo = function(videoStream, resultPath) {
var cmdParams = [
'-i', '-',
'-y',
'-f', 'mp4',
'-vcodec', 'libx264',
'-vf', 'scale=-1:720',
'-f', 'mp4',
resultPath
];
var ffmpeg = child_process.spawn('ffmpeg', cmdParams);
var data = '';
ffmpeg.stdout
.on('data', function(chunk) { data += chunk; })
.on('end', function() { console.log('result', data); });
var err = '';
ffmpeg.stderr
.on('data', function(chunk) { err += chunk; })
.on('end', function() { console.log('error', err);});
videoStream.pipe(ffmpeg.stdin);
};
processVideo(fs.createReadStream(pathToLocalMP4File), localPathToResultFile);
The output I get is
error ffmpeg version 2.8 Copyright (c) 2000-2015 the FFmpeg developers
built with Apple LLVM version 7.0.0 (clang-700.1.76)
configuration:
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fd1e2802a00] stream 0, offset 0x20: partial file
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fd1e2802a00] Could not find codec parameters for stream 0 (Video: h264 (avc1 / 0x31637661), none, 1920x1080, 16242 kb/s): unspecified pixel format
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input
Metadata:
major_brand : mp42
minor_version : 537134592
compatible_brands: mp42
creation_time : 2015-12-26 12:47:49
Duration: 00:00:04.00, bitrate: N/A
Stream
Metadata:
creation_time : 2015-12-26 12:47:49
encoder : AVC Coding
Stream
Metadata:
creation_time : 2015-12-26 12:47:49
[buffer @ 0x7fd1e1c08e20] Unable to parse option value "-1" as pixel format
Last message repeated 1 times
[buffer @ 0x7fd1e1c08e20] Error setting option pix_fmt to value -1.
[graph 0 input from stream 0:0 @ 0x7fd1e1c08f60] Error applying options to the filter.
Error opening filters!
result
I tried to set the parameter -pix_fmtor -analyzedurationand -probesize, as suggested by the error code, and this one , to no avail.
However, it ffmpeg -i pathToLocalMP4File -y -f mp4 -pix_fmt yuv420p -vcodec libx264 -vf scale=-1:720 -f mp4 localPathToResultFileworks fine in the terminal ...
Any idea?