nodejs FFMPEG argument issues - node.js

When I put the following command in the command line FFMPEG works completely correct and mute's the sections of the video as expected.
C:\>ffmpeg -y -i C:/Users/ADMINI~1/AppData/Local/Temp/2/0400028520160811144100001i100.mp4 -af "volume=enable='between(t,1,3)':volume=0, volume=enable='between(t,10,12)':volume=0, volume=enable='between(t,4,6)':volume=0, volume=enable='between(t,7,9)':volume=0" -c:v copy -movflags +faststart c:\temp\31e7ac4063d111e6bdc67f1f7f7b55d3.mp4
ffmpeg version N-79651-ge1c2048 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.9.3 (GCC)
configuration: --prefix=/usr/local/x86_64-w64-mingw32 --enable-gpl --enable-nonfree --enable-libx264 --enable-libfdk_aac --enable-static --enable-runtime-cpudetect --enable-w32threads --disable-shared --disable-ffplay --disable-ffserver --arch=x86_64 --extra-cflags=-I/local/x86_64-w64-mingw32/include --extra-ldflags='-L/local/x86_64-w64-mingw32/lib -static'
libavutil 55. 22.101 / 55. 22.101
libavcodec 57. 38.100 / 57. 38.100
libavformat 57. 34.103 / 57. 34.103
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 44.100 / 6. 44.100
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:/Users/ADMINI~1/AppData/Local/Temp/2/0400028520160811144100001i100.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.34.103
Duration: 00:00:12.78, start: 0.000000, bitrate: 4074 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720, 4006 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 64 kb/s (default)
Metadata:
handler_name : SoundHandler
[mp4 # 03a8e5e0] Using AVStream.codec to pass codec parameters to muxers is deprecated, use AVStream.codecpar instead.
Last message repeated 1 times
Output #0, mp4, to 'c:\temp\31e7ac4063d111e6bdc67f1f7f7b55d3-AudRedact.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.34.103
Stream #0:0(und): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 1280x720, q=2-31, 4006 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) ([64][0][0][0] / 0x0040), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
encoder : Lavc57.38.100 aac
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[mp4 # 03a8e5e0] Starting second pass: moving the moov atom to the beginning of the file24.3x
frame= 383 fps=0.0 q=-1.0 Lsize= 6325kB time=00:00:12.73 bitrate=4068.3kbits/s speed=24.7x
video:6244kB audio:69kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.191899%
[aac # 03776160] Qavg: 51080.756
However if I build the same in node programatically:
function redactAudio(tempFilePath, arrPairs, cb){
// ffmpeg -loglevel fatal -y -i video.mp4 -af "volume=enable='between(t,5,10)':volume=0, volume=enable='between(t,15,20)':volume=0" -c:v copy -movflags +faststart output.mp4
var tempBuff = Buffer.alloc(16);
jsuuid.v1(null, tempBuff, 0);
var outFileName = tempBuff.toString('hex') + path2.extname(tempFilePath);
var volStr = '"';
for (var i = 0; i < arrPairs.length; i++) {
volStr += "volume=enable='between(t," + arrPairs[i].start + "," + arrPairs[i].end + ")':volume=0";
if (i !== arrPairs.length - 1) {
volStr += ", ";
} else {
volStr += '"';
}
}
child_process.execFile(
'ffmpeg',
[
/*'-loglevel', 'fatal',*/
'-y', '-i', tempFilePath,
'-af', volStr,
'-c:v', 'copy',
'-movflags', '+faststart', outFileName
],
{
cwd: tempDir,
maxBuffer: Infinity
},
function(err, stdout, stderr) {
if (err) {
console.error(clc.magentaBright(clc.whiteBright('FFMPEG - ERROR OCC: ', path2.basename(tempFilePath), ' : ', stderr, '\n')));
return cb(err, 'FFMpeg Failed: ' + JSON.stringify({ stdout: stdout, stderr: stderr} ));
} else {
console.log(clc.magentaBright(clc.whiteBright('FFMPEG - Finished: ', path2.basename(tempFilePath), '\n')));
return cb(null, outFileName);
}
}
);
}
Please Help me understand what is going on because I get the following error every time when run from node.
FFMPEG - ERROR OCC: 0400028520160811144100001i100.mp4 : ffmpeg version N-79651-ge1c2048 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.9.3 (GCC)
configuration: --prefix=/usr/local/x86_64-w64-mingw32 --enable-gpl --enable-nonfree --enable-libx264 --enable-libfdk_aac --enable-static --enable-runtime-cpudetect --enable-w32threads --disable-shared --disable-ffplay --disable-ffserver --arch=x86_64 --extra-cflags=-I/local/x86_64-w64-mingw32/include --extra-ldflags='-L/local/x86_64-w64-mingw32/lib -static'
libavutil 55. 22.101 / 55. 22.101
libavcodec 57. 38.100 / 57. 38.100
libavformat 57. 34.103 / 57. 34.103
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 44.100 / 6. 44.100
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:/Users/ADMINI~1/AppData/Local/Temp/2/0400028520160811144100001i100.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.34.103
Duration: 00:00:12.78, start: 0.000000, bitrate: 4074 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720, 4006 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 64 kb/s (default)
Metadata:
handler_name : SoundHandler
[AVFilterGraph # 00381600] No such filter: '"volume'
Error opening filters!
0400028520160811144100001i100.mp4
{ Error: Command failed: ffmpeg -y -i C:/Users/ADMINI~1/AppData/Local/Temp/2/0400028520160811144100001i100.mp4 -af "volume=enable='between(t,1,3)':volume=0, volume=enable='between(t,10,12)':volume=0, volume=enable='between(t,4,6)':volume=0, volume=enable='between(t,7,9)':volume=0" -c:v copy -movflags +faststart ea1eae2063d211e6bbf2af16c2e9be57.mp4
ffmpeg version N-79651-ge1c2048 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.9.3 (GCC)
configuration: --prefix=/usr/local/x86_64-w64-mingw32 --enable-gpl --enable-nonfree --enable-libx264 --enable-libfdk_aac --enable-static --enable-runtime-cpudetect --enable-w32threads --disable-shared --disable-ffplay --disable-ffserver --arch=x86_64 --extra-cflags=-I/local/x86_64-w64-mingw32/include --extra-ldflags='-L/local/x86_64-w64-mingw32/lib -static'
libavutil 55. 22.101 / 55. 22.101
libavcodec 57. 38.100 / 57. 38.100
libavformat 57. 34.103 / 57. 34.103
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 44.100 / 6. 44.100
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:/Users/ADMINI~1/AppData/Local/Temp/2/0400028520160811144100001i100.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.34.103
Duration: 00:00:12.78, start: 0.000000, bitrate: 4074 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720, 4006 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 64 kb/s (default)
Metadata:
handler_name : SoundHandler
[AVFilterGraph # 00381600] No such filter: '"volume'
Error opening filters!
at ChildProcess.exithandler (child_process.js:202:12)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:850:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)
killed: false,
code: 1,
signal: null,
cmd: 'ffmpeg -y -i C:/Users/ADMINI~1/AppData/Local/Temp/2/0400028520160811144100001i100.mp4 -af "volume=enable=\'between(t,1,3)\':volume=0, volume=enable=\'between(t,10,12)\':volume=0, volume=enable=\'between(t,4,6)\':volume=0, volume=enable=\'between(t,7,9)\':volume=0" -c:v copy -movflags +faststart ea1eae2063d211e6bbf2af16c2e9be57.mp4' }
Best I can think is it has something to do with the \' in volStr but I don't know how to create it any other way.
after #Mulvya comment I changed my for loop to
var volStr = '';
for (var i = 0; i < arrPairs.length; i++) {
volStr += "volume=enable='between(t," + arrPairs[i].start + "," + arrPairs[i].end + ")':volume=0";
if (i !== arrPairs.length - 1) {
volStr += ",";
}
}
getting rid of the space between each grouping and it worked beautifully.

Can't debug what's happening with the nodeJS string formation, but No such filter: '"volume' suggests the closing quote isn't being added.
You have two workarounds. Get rid of the whitespaces within the -af string. Or you can make do with one volume filter.
volume=0:enable='between(t,1,3)+between(t,4,6)+between(t,7,9)+between(t,10,12)'

Related

combine multiple mp4 videos and images

so I have a folder of images, 1/20 named *.png and a folder of mp4's named *.mp4.
I want to create a video in this order:
1.png for 3 sec
1.mp4
2.png for 3 sec
3.mp4
etc
Is there a way I can display each png for 3 seconds and then show the respective mp4 using ffmpeg? I know I can convert each picture to a 3 second video invididually using this command and the framerate differences will be a problem (1/3 vs 60), but I'm not very experienced with command line video editing:
ffmpeg -r 1/3 -i 1.png -vcodec mpeg4 1_intro.mp4
ffprobe output:
ffprobe version 4.0 Copyright (c) 2007-2018 the FFmpeg developers
built with Apple LLVM version 9.1.0 (clang-902.0.39.1)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.0 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma
libavutil 56. 14.100 / 56. 14.100
libavcodec 58. 18.100 / 58. 18.100
libavformat 58. 12.100 / 58. 12.100
libavdevice 58. 3.100 / 58. 3.100
libavfilter 7. 16.100 / 7. 16.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 1.100 / 5. 1.100
libswresample 3. 1.100 / 3. 1.100
libpostproc 55. 1.100 / 55. 1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '1.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.71.100
Duration: 00:00:32.69, start: 0.000000, bitrate: 7039 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, bt709/unknown/unknown), 1920x1080 [SAR 1:1 DAR 16:9], 7004 kb/s, 60 fps, 60 tbr, 90k tbn, 120 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 43 kb/s (default)
Metadata:
handler_name : SoundHandler
output of out.mp4
ffprobe version 4.0 Copyright (c) 2007-2018 the FFmpeg developers
built with Apple LLVM version 9.1.0 (clang-902.0.39.1)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.0 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma
libavutil 56. 14.100 / 56. 14.100
libavcodec 58. 18.100 / 58. 18.100
libavformat 58. 12.100 / 58. 12.100
libavdevice 58. 3.100 / 58. 3.100
libavfilter 7. 16.100 / 7. 16.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 1.100 / 5. 1.100
libswresample 3. 1.100 / 3. 1.100
libpostproc 55. 1.100 / 55. 1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'out.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.12.100
Duration: 00:10:19.13, start: 0.000000, bitrate: 5689 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 2560x1440 [SAR 1:1 DAR 16:9], 5565 kb/s, 53.91 fps, 60 tbr, 90k tbn, 120 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 114 kb/s (default)
Metadata:
handler_name : SoundHandler
For each image, run
ffmpeg -i image -f lavfi -i anullsrc -r 60 -pix_fmt yuv420p -ac 2 -ar 44100 -video_track_timescale 90k -t 3 image.mp4
Then create a text file,
file img1.mp4
file 1.mp4
file img2.mp4
file 2.mp4
...etc
and run
ffmpeg -f concat -i list.txt -c copy out.mp4
This whole process assumes that the MP4s have the same properties, like resolution..etc.

Concatenate audio with image and video using ffmpeg

I have 1 image, 1 audio file and 1 video. I would like to merge all of them to make a video which will
show the image and play audio file for the first 10s
play the video file
here is what I was trying to do so far.
ffmpeg \
-loop 1 -framerate 24 -t 10 -i item1.jpg \
-i "https://audio-ssl.itunes.apple.com/apple-assets-us-std-000001/Music/66/58/f7/mzi.eoocfriy.aac.p.m4a" \
-i item4.mp4 \
-filter_complex \
"[0]scale=432:432,setdar=1[img1]; \
[1]volume=1[aud1]; \
[2]scale=432:432,setdar=1[vid1]; \
[img1][aud1][vid1] concat=n=3:v=1:a=1" \
outputfile.mp4
I got the error:
[Parsed_setdar_4 # 0x3063780] Media type mismatch between the
'Parsed_setdar_4' filter output pad 0 (video) and the
'Parsed_concat_6' filter input pad 1 (audio) [AVFilterGraph #
0x30479a0] Cannot create the link setdar:0 -> concat:1 Error
initializing complex filters. Invalid argument
I tried to googled but still cannot figure out what I am doing wrong?
Updated:
I ran the following command:
ffmpeg \
-loop 1 -framerate 24 -t 10 -i item1.jpg \
-t 10 -i "https://audio-ssl.itunes.apple.com/apple-assets-us-std-000001/Music/66/58/f7/mzi.eoocfriy.aac.p.m4a" \
-i item4.mp4 \
-f lavfi -t 1 -i anullsrc \
-filter_complex \
"[0]scale=432:432,setsar=1[img1]; \
[2]scale=432:432,setsar=1[vid1]; \
[img1][1][vid1][3] concat=n=2:v=1:a=1" \
outputfile.mp4
and got the following error:
ffmpeg version 3.3.3 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --mandir=/usr/share/man --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libfreetype --enable-gnutls --disable-ffserver --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libtheora --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvidstab --enable-libwavpack --enable-nvenc --enable-libzimg
libavutil 55. 58.100 / 55. 58.100
libavcodec 57. 89.100 / 57. 89.100
libavformat 57. 71.100 / 57. 71.100
libavdevice 57. 6.100 / 57. 6.100
libavfilter 6. 82.100 / 6. 82.100
libavresample 3. 5. 0 / 3. 5. 0
libswscale 4. 6.100 / 4. 6.100
libswresample 2. 7.100 / 2. 7.100
libpostproc 54. 5.100 / 54. 5.100
Input #0, image2, from 'item1.jpg':
Duration: 00:00:00.04, start: 0.000000, bitrate: 8365 kb/s
Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 432x432 [SAR 1:1 DAR 1:1], 24 fps, 24 tbr, 24 tbn, 24 tbc
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'https://audio-ssl.itunes.apple.com/apple-assets-us-std-000001/Music/66/58/f7/mzi.eoocfriy.aac.p.m4a':
Metadata:
major_brand : M4A
minor_version : 0
compatible_brands: M4A mp42isom
creation_time : 1983-06-16T23:20:44.000000Z
iTunSMPB : 00000000 00000840 00000000 00000000001423C0 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
Duration: 00:00:29.98, start: 0.047891, bitrate: 285 kb/s
Stream #1:0(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 271 kb/s (default)
Metadata:
creation_time : 1983-06-16T23:20:44.000000Z
Input #2, mov,mp4,m4a,3gp,3g2,mj2, from 'item4.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
creation_time : 1970-01-01T00:00:00.000000Z
encoder : Lavf53.24.2
Duration: 00:00:13.70, start: 0.000000, bitrate: 615 kb/s
Stream #2:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 320x240 [SAR 1:1 DAR 4:3], 229 kb/s, 15 fps, 15 tbr, 15360 tbn, 30 tbc (default)
Metadata:
creation_time : 1970-01-01T00:00:00.000000Z
handler_name : VideoHandler
Stream #2:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 382 kb/s (default)
Metadata:
creation_time : 1970-01-01T00:00:00.000000Z
handler_name : SoundHandler
Input #3, lavfi, from 'anullsrc':
Duration: N/A, start: 0.000000, bitrate: 705 kb/s
Stream #3:0: Audio: pcm_u8, 44100 Hz, stereo, u8, 705 kb/s
[AVFilterGraph # 0x3955e20] No such filter: ' '
Error initializing complex filters.
Invalid argument
When concatting paired streams, for each segment, the concat filter expects a corresponding pair of inputs. So, if you are concatting 1 video and 2 audio streams, each segment input should be [v][a][a].
So, in this case, a dummy audio is required to pair with the 2nd video.
ffmpeg \
-loop 1 -framerate 24 -t 10 -i item1.jpg \
-t 10 -i "https://audio-ssl.itunes.apple.com/apple-assets-us-std-000001/Music/66/58/f7/mzi.eoocfriy.aac.p.m4a" \
-i item4.mp4 \
-f lavfi -t 1 -i anullsrc \
-filter_complex \
"[0]scale=432:432,setsar=1[img1]; \
[2]scale=432:432,setsar=1[vid1]; \
[img1][1][vid1][3] concat=n=2:v=1:a=1" \
outputfile.mp4
The anullsrc provides the dummy audio.
The intro audio has to be limited to the image duration, since the concat filter uses the duration of the longer stream in each segment.
Use setsar not setdar since SAR is the actual parameter that is changed and it's possible that after reduction to a rational number, the SARs may not match.
n in concat should be 2 since it specifies the number of paired segments, not total number of inputs.

MP4Box / FFMPEG concat loses audio after first clip

So I am certainly no expert when it comes to either of these tools, but I have a web-based project that's executing commands on an Amazon Linux server to concatenate two video files that are uploaded.
Both files are converted to mp4s first using FFMPEG, and those play perfectly in a browser after conversion:
ffmpeg -i file1.mpg -c:v libx264 -crf 22 -c:a aac -strict -2 -movflags faststart file2.mp4
Then, I attempt to combine these two resulting mp4s into a single mp4. I tried using FFMPEG to do this but to no avail. Switching to try MP4Box got me much closer: the videos are concatenated together, but the audio stops playing at the end of the first clip, and the second clip is silent.
MP4Box -force-cat -keepsys -add file.mp4 -cat file2.mp4 out.mp4
I've tried varying versions of the above command with no better results. Any input is greatly appreciated.
EDIT: info on .mp4 files using
ffmpeg -i file1.mp4 -i file2.mp4
ffmpeg -i 1510189259715DogRunsintoGlassDoor_315a03a8e20acfc.mp4 -i
1510189273549NewhouseMoonMoonneverseenstairsbeforefunnydog_285a03a8e6aab25.mp4
ffmpeg version N-61041-g52a2138 Copyright (c) 2000-2014 the FFmpeg
developers
built on Mar 2 2014 05:45:04 with gcc 4.6 (Debian 4.6.3-1)
configuration: --prefix=/root/ffmpeg-static/64bit
--extra-cflags='-I/root/ffmpeg-static/64bit/include -static' --extra-ldflags='-L/root/ffmpeg-static/64bit/lib -static' --extra-libs='-lxml2 -lexpat -lfreetype' --enable-static --disable-shared --disable-ffserver --disable-doc --enable-bzlib --enable-zlib --enable-postproc --enable-runtime-cpudetect --enable-libx264 --enable-gpl --enable-libtheora --enable-libvorbis --enable-libmp3lame --enable-gray --enable-libass --enable-libfreetype --enable-libopenjpeg --enable-libspeex --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-version3 --enable-libvpx
libavutil 52. 66.100 / 52. 66.100
libavcodec 55. 52.102 / 55. 52.102
libavformat 55. 33.100 / 55. 33.100
libavdevice 55. 10.100 / 55. 10.100
libavfilter 4. 2.100 / 4. 2.100
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 18.100 / 0. 18.100
libpostproc 52. 3.100 / 52. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from
'1510189259715DogRunsintoGlassDoor_315a03a8e20acfc.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf55.33.100
Duration: 00:00:04.92, start: 0.023220, bitrate: 634 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
360x360 [SAR 1:1 DAR 1:1], 501 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc
(default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono,
fltp, 132 kb/s (default)
Metadata:
handler_name : SoundHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from
'1510189273549NewhouseMoonMoonneverseenstairsbeforefunnydog_285a03a8e6aab25.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf55.33.100
Duration: 00:00:18.79, start: 0.023220, bitrate: 455 kb/s
Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
362x360 [SAR 1:1 DAR 181:180], 320 kb/s, 29.94 fps, 29.94 tbr, 11976
tbn, 59.88 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #1:1(eng): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo,
fltp, 129 kb/s (default)
Metadata:
handler_name : SoundHandler
At least one output file must be specified

ffmpeg : Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

I'm experiencing troubles running ffmpeg on my synology. I'm trying to convert .avi video to mp4.
Here is the command :
ffmpeg -i vid20160623.avi -acodec libfaac -b:a 128k -vcodec mpeg4 -b:v 1200k -flags +aic+mv4 -f mp4 vid20160623.mp4
And the logs :
ffmpeg version 2.7.1 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.9.3 (crosstool-NG 1.20.0) 20150311 (prerelease)
configuration: --prefix=/usr --incdir='${prefix}/include/ffmpeg' --arch=arm --target-os=linux --cross-prefix=/usr/local/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi- --enable-cross-compile --enable-optimizations --enable-pic --enable-gpl --enable-shared --disable-static --enable-version3 --enable-nonfree --enable-libfaac --enable-encoders --enable-pthreads --disable-bzlib --disable-protocol=rtp --disable-muxer=image2 --disable-muxer=image2pipe --disable-swscale-alpha --disable-ffserver --disable-ffplay --disable-devices --disable-bzlib --disable-altivec --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libmp3lame --disable-vaapi --disable-decoder=amrnb --disable-encoder=zmbv --disable-encoder=dca --disable-encoder=ac3 --disable-encoder=ac3_fixed --disable-encoder=eac3 --disable-decoder=dca --disable-decoder=eac3 --disable-decoder=truehd --cc=/usr/local/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-ccache-gcc
libavutil 54. 27.100 / 54. 27.100
libavcodec 56. 41.100 / 56. 41.100
libavformat 56. 36.100 / 56. 36.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 16.101 / 5. 16.101
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.100 / 1. 2.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, avi, from 'vid20160623.avi':
Metadata:
encoder : MEncoder git-ab94fc6-4.4.3
Duration: 00:20:18.07, start: 0.000000, bitrate: 1197 kb/s
Stream #0:0: Video: mpeg4 (Advanced Simple Profile) (XVID / 0x44495658), yuv420p, 624x352 [SAR 1:1 DAR 39:22], 1056 kb/s, 25 fps, 23.98 tbr, 25 tbn, 23.98 tbc
Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, s16p, 128 kb/s
Output #0, mp4, to vid20160623.mp4':
Metadata:
encoder : MEncoder git-ab94fc6-4.4.3
Stream #0:0: Video: mpeg4, none, q=2-31, 128 kb/s, SAR 351:352 DAR 0:0, 23.98 fps
Metadata:
encoder : Lavc56.41.100 mpeg4
Stream #0:1: Audio: aac, 0 channels, 128 kb/s
Metadata:
encoder : Lavc56.41.100 libfaac
Stream mapping:
Stream #0:0 -> #0:0 (mpeg4 (native) -> mpeg4 (native))
Stream #0:1 -> #0:1 (mp3 (native) -> aac (libfaac))
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
I tried to reduce b:a and b:v but it did not work.
Any help will be welcome.
Looks like the encoder is not recognizing the resolution of the output stream. Also, the codec frame rate is different than the actual frame rate. Try,
ffmpeg -i vid20160623.avi -acodec libfaac -b:a 128k -vf "scale=624:352,setsar=1" -vcodec mpeg4 -r 25 -b:v 1200k -flags +aic+mv4 -f mp4 vid20160623.mp4
Maybe a late answer but as I looked for a while for the same reason...
The issue is not in your command line but in FFmpeg version itself!
You asked for 1200k bit rate but we can see in output->Stream 0:0, it would try 128kb/s!
I have just used same command line with FFMpeg 2.8.11 and it works like a charm!

"Amix" and "adelay" combined leads to "Error while filtering: Cannot allocate memory"

I was trying to add to audio clips together (using amix) while delaying one of them (with adelay). I used the following command
ffmpeg -i org/onclassical_demo_luisi_chopin_scherzo_2_31_small-version_ii-ending.wav \
-i org/all_u_had_2_say.wav -filter_complex \
"[1]adelay=1000[del1];[0][del1]amix" out.wav
and get the following output
ffmpeg version N-77387-g9d38f06 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04)
configuration: --enable-libmp3lame --enable-gpl --enable-libx264 --enable-libx265
libavutil 55. 11.100 / 55. 11.100
libavcodec 57. 18.100 / 57. 18.100
libavformat 57. 20.100 / 57. 20.100
libavdevice 57. 0.100 / 57. 0.100
libavfilter 6. 21.100 / 6. 21.100
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, wav, from 'org/onclassical_demo_luisi_chopin_scherzo_2_31_small-version_ii-ending.wav':
Duration: 00:02:18.26, bitrate: 1411 kb/s
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 2 channels, s16, 1411 kb/s
Guessed Channel Layout for Input Stream #1.0 : mono
Input #1, wav, from 'org/all_u_had_2_say.wav':
Duration: 00:00:03.85, bitrate: 88 kb/s
Stream #1:0: Audio: pcm_u8 ([1][0][0][0] / 0x0001), 11025 Hz, 1 channels, u8, 88 kb/s
Output #0, wav, to 'out.wav':
Metadata:
ISFT : Lavf57.20.100
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 11025 Hz, mono, s16, 176 kb/s (default)
Metadata:
encoder : Lavc57.18.100 pcm_s16le
Stream mapping:
Stream #0:0 (pcm_s16le) -> amix:input0
Stream #1:0 (pcm_u8) -> adelay
amix -> Stream #0:0 (pcm_s16le)
Press [q] to stop, [?] for help
Error while filtering: Cannot allocate memory
size= 83kB time=00:00:03.85 bitrate= 176.6kbits/s speed= 213x
video:0kB audio:83kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.091808%
Maybe there is some incompatibility between the streams (pcm_s16le, 44100 Hz, 2 channels vs. pcm_u8, 11025 Hz, 1 channel) that need to be handled first, but running only amix works so that doesn't actually seem to be the case.
Try new build. Or the command below with the current one:
ffmpeg -i org/onclassical_demo_luisi_chopin_scherzo_2_31_small-version_ii-ending.wav \
-i org/all_u_had_2_say.wav -filter_complex \
"[0]aresample=48000,aformat=fltp[a];
[1]aresample=48000,aformat=fltp,asetpts=PTS+(1.000/TB)[del1]; \
[a][del1]amix" out.wav

Resources