combine multiple mp4 videos and images - python-3.x

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.

Related

RTMP_ReadPacket, failed to read RTMP packet header rtmp://a.rtmp.youtube.com/live2: Unknown error occurred

Here is the script I am trying to run, I believe the issue is in here:
#!/bin/bash
GIF=/home/stream1/85012216.gif
STREAM_KEY=thisisasecret
URL=rtmp://a.rtmp.youtube.com/live2
FPS=30
KEYINT=$(expr $FPS \* 3)
$FFMPEG -f alsa -ac 2 -i hw:Loopback,1,0 -fflags +genpts -r $FPS -i $GIF \
-vcodec libx264 -x264opts keyint=$KEYINT:min-keyint=$KEYINT:scenecut=-1 -b:v 1000k \
-preset veryfast -pix_fmt yuv420p -s 854x480 \
-c:a libfdk_aac -b:a 96k -ar 44100 \
-f flv $URL
The error:
ffmpeg version N-92337-g8e50215b5e Copyright (c) 2000-2018 the FFmpeg
developers built with gcc 7 (Ubuntu 7.3.0-27ubuntu1~18.04)
configuration: --enable-shared --enable-gpl --enable-nonfree
--enable-pthreads --enable-postproc --enable-libtheora --enable-version3 --enable-libx264 --enable-libfdk-aac --disable-stripping --disable-encoder=libschroedinger --enable-librtmp --enable-gnutls --enable-avfilter --enable-libfreetype --disable-decoder=amrnb --enable-fontconfig --disable-mips32r2 --disable-mipsdspr2 --disable-htmlpages --disable-podpages --disable-altivec --enable-libass --enable-omx --enable-omx-rpi libavutil 56. 23.100 / 56. 23.100 libavcodec 58. 36.100 /
58. 36.100 libavformat 58. 21.100 / 58. 21.100 libavdevice 58. 6.100 / 58. 6.100 libavfilter 7. 43.100 / 7. 43.100 libswscale 5. 4.100 / 5. 4.100 libswresample 3. 4.100 /
3. 4.100 libpostproc 55. 4.100 / 55. 4.100 Guessed Channel Layout for Input Stream #0.0 : stereo Input #0, alsa, from
'hw:Loopback,1,0': Duration: N/A, start: 1541258646.286883, bitrate:
1536 kb/s
Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s Input #1, gif, from '/home/stream1/85012216.gif': Duration: N/A,
bitrate: N/A
Stream #1:0: Video: gif, bgra, 500x281, 16.67 fps, 16.67 tbr, 100 tbn, 100 tbc RTMP_ReadPacket, failed to read RTMP packet header
rtmp://a.rtmp.youtube.com/live2: Unknown error occurred
System details:
Distributor ID: Ubuntu
Description: Ubuntu 18.04.1 LTS
Release: 18.04
Codename: bionic
-f flv $URL should be -f flv $URL/$STREAM_KEY

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

nodejs FFMPEG argument issues

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)'

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