我正在使用FFmpeg合并一些视频文件,并且我的自定义版本出现问题。我使用以下Java代码来包装ffmpeg命令:
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();
我使用的命令是(缩写为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
我收到错误:
Unrecognized option 'map [outv]'.
我是否缺少包含地图的配置选项?我在哪里可以找到map命令需要哪些选项的信息?或者我的ffmpeg是否像许多其他类似的问题一样过时了? 2015-02-25是最近的!
完整命令:
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]'.
答案 0 :(得分:5)
这个问题对于ffmpeg来说并不是一个问题,但是缺少Java函数ProcessBuilder的用法。在为ProcessBuilder提供字符串参数列表时,我给了['ffmpeg, ..., '-map [outv]', ...]
。这应该是['ffmpeg, ..., '-map', '[outv]', ...]
,因为ProcessBuilder将每个列表项视为参数。因此,ffmpeg无法识别参数'map [outv]'
。
感谢@slhck帮助我解决这个问题。