I am merging some video files with FFmpeg and having an issue with my custom build. I'm using the following Java code for wrapping the ffmpeg command:
List<String> cmds = new ArrayList<>();
cmds.add("ffmpeg");
cmds.add("-i");
cmds.add("input1.mp4");
...
cmds.add("-map [outv]");
cmds.add("-map [a]");
...
cmds.add("output.mp4");
ProcessBuilder pb = new ProcessBuilder(cmds);
pb.directory(fileExec);
Process process = pb.start();
int exitVal = process.waitFor();
The command I am using is (abbreviated filter_complex
):
ffmpeg -i input1.mp4 -i input2.mp4 -filter_complex “... [bla1][bla2]overlay=main_w-overlay_w:main_h-overlay_h:format=yuv420[outv]” -c:v libx264 -preset ultrafast -b:v 45000k -aspect 1.7777778 -map [outv] -map [a] -c:a libfdk_aac -ac 2 -b:a 128k -t 24 output.mp4
I get the error:
Unrecognized option 'map [outv]'.
Am I missing a configuration option to include map? Where would I find this information of what options are required for the map command? Or is my ffmpeg just too old like lots of the other similar questions? 2015-02-25 is pretty recent!
Full command:
ffmpeg -y -i VID_20150609_154943_5583.mp4 -i VID_20150609_154943_24253.mp4 -i VID_20150609_154943_16083.mp4 -i stamp.png -f lavfi -i color=black -filter_complex " [0:v]scale=iw*min(1280/iw\,720/ih):ih*min(1280/iw\,720/ih),pad=1280:720:(ow-iw*min(ow/iw\,oh/ih))/2:(oh-ih*min(ow/iw\,oh/ih))/2,format=pix_fmts=yuva420p,fade=t=out:st=7.99:d=2:alpha=1,setpts=expr=PTS-STARTPTS[va0] ; [0:a]afade=t=out:st=7.99:d=2[a0] ; [1:v]scale=iw*min(1280/iw\,720/ih):ih*min(1280/iw\,720/ih),pad=1280:720:(ow-iw*min(ow/iw\,oh/ih))/2:(oh-ih*min(ow/iw\,oh/ih))/2,format=pix_fmts=yuva420p,fade=t=in:st=0:d=2:alpha=1,fade=t=out:st=15.98:d=2:alpha=1,setpts=expr=PTS-STARTPTS+7.99/TB[va1] ; [1:a]afade=t=in:st=0:d=2,afade=t=out:st=15.98:d=2[a1] ; aevalsrc=0:d=7.99[s1] ; [s1][a1]concat=n=2:v=0:a=1[ac1] ; [2:v]scale=iw*min(1280/iw\,720/ih):ih*min(1280/iw\,720/ih),pad=1280:720:(ow-iw*min(ow/iw\,oh/ih))/2:(oh-ih*min(ow/iw\,oh/ih))/2,format=pix_fmts=yuva420p,fade=t=in:st=0:d=2:alpha=1,setpts=expr=PTS-STARTPTS+15.98/TB[va2] ; [2:a]afade=t=in:st=0:d=2[a2] ; aevalsrc=0:d=15.98[s2] ; [s2][a2]concat=n=2:v=0:a=1[ac2] ; [4:v]scale=1280x720,trim=duration=23.97[over0] ; [a0][ac1][ac2]amix=inputs=3[a]; [over0][va0]overlay[over1];[over1][va1]overlay[over2];[over2][va2]overlay[over3] ; [over3][3:v]overlay=main_w-overlay_w:main_h-overlay_h:format=yuv420[outv] " -c:v libx264 -preset ultrafast -b:v 45000k -aspect 1.7777778 -map [outv] -map [a] -c:a libfdk_aac -ac 2 -b:a 128k -t 23.97 VID_20150609_155417.mp4
ffmpeg version git-2015-02-25-b0d3322 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.8 (GCC)
configuration: --arch=arm --cpu=cortex-a8 --target-os=linux --enable-runtime-cpudetect --enable-pic --disable-shared --enable-static --cross-prefix=/home/jon/Development/android-ndk-r10d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi- --enable-cross-compile --sysroot=/home/jon/Development/android-ndk-r10d/platforms/android-9/arch-arm/ --extra-cflags='-I../x264 -mfloat-abi=softfp -mfpu=neon -fPIE -pie' --extra-ldflags='-L../x264 -fPIE -pie' --enable-version3 --enable-gpl --disable-doc --enable-yasm --disable-decoders --enable-decoder='mpeg4,aac,h264,mpegvideo,mpeg1video,mpeg2video,png,mjpeg' --disable-encoders --enable-encoder='mpeg4,aac,h264,libx264,mpeg1video,mpeg2video,png' --disable-parsers --enable-parser='aac,mpeg4video,ac3,h261,h264,vc1,mpegvideo' --disable-demuxers --enable-demuxer='aac,h264,mpegvideo,m4v,mov,vc1,mp4,concat,image2' --disable-muxers --enable-muxer='h264,mpeg1video,mpeg2video,m4v,mov,vc1,md5,mp4' --enable-protocols --enable-indev='v4l,v4l2' --disable-filters --enable-filter='aresample,scale,movie,overlay' --enable-avfilter --disable-indevs --enable-indev=lavfi --disable-outdevs --enable-hwaccels --enable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --disable-symver --enable-network --enable-libx264 --enable-zlib
libavutil 54. 19.100 / 54. 19.100
libavcodec 56. 26.100 / 56. 26.100
libavformat 56. 23.105 / 56. 23.105
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 11.101 / 5. 11.101
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Unrecognized option 'map [outv]'.
This question is not really a problem with ffmpeg, but a miss usage of the Java function ProcessBuilder. When providing ProcessBuilder with a list of string arguments, I was giving
['ffmpeg, ..., '-map [outv]', ...]
. This instead should be['ffmpeg, ..., '-map', '[outv]', ...]
because ProcessBuilder treats each list item as an argument. Hence ffmpeg not recognising the argument'map [outv]'
.Thanks to @slhck for helping me figure this out.