您好,使用以下命令将两个视频合并到一个文件中。
String[] complexCommand = {"-i", yourRealPath, "-i", compare_moviePath, "-filter_complex", "[0:v]setpts=PTS-STARTPTS, " +
"scale=480x360[top];[1:v]setpts=PTS-STARTPTS, scale=480x360,format=yuva420p,colorchannelmixer=aa=0.5[bottom];" +
"[top][bottom]overlay=shortest=1", "-acodec", "-c:a", "aac", "-vcodec", "libx264", filePath};
当我在cmd中输入此代码时,得到以下行:
ffmpeg version 3.3.2 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 4.9.x (GCC) 20150123 (prerelease)
configuration: --prefix=/home/yash/ffmpeg-binary-android-master/build_scripts/build_dir --target-os=linux --arch=arm64 --cross-prefix=/home/yash/android-ndk-r15c/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android- --enable-cross-compile --sysroot=/home/yash/android-ndk-r15c/platforms/android-21/arch-arm64/ --pkg-config=/usr/bin/pkg-config --pkg-config-flags=--static --enable-pic --enable-small --enable-gpl --enable-nonfree --disable-shared --enable-static --enable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --enable-libmp3lame --enable-libx264 --enable-bsf=aac_adtstoasc --enable-openssl --enable-libfreetype --enable-libfontconfig --enable-pthreads --enable-zlib --disable-doc
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
libswscale 4. 6.100 / 4. 6.100
libswresample 2. 7.100 / 2. 7.100
libpostproc 54. 5.100 / 54. 5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/v1golf/Android/data/com.v1.v1golf2/files/VID_20191004_163521.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.71.100
Duration: 00:00:05.76, start: 0.000000, bitrate: 4915 kb/s
Stream #0:0(eng): Video: h264 (avc1 / 0x31637661), yuv420p, 768x1024 [SAR 1:1 DAR 3:4], 4963 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 8000 Hz, mono, fltp, 25 kb/s (default)
Metadata:
handler_name : SoundHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/v1golf/Android/data/com.v1.v1golf2/files/1908151648466PEV-260690.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.40.101
Duration: 00:00:07.23, start: 0.000000, bitrate: 21924 kb/s
Stream #1:0(und): Video: h264 (avc1 / 0x31637661), yuv420p, 1280x720, 21923 kb/s, 59.86 fps, 60 tbr, 15360 tbn, 120 tbc (default)
Metadata:
handler_name : VideoHandler
[NULL @ 0x76fde80e00] Unable to find a suitable output format for 'aac'
aac: Invalid argument
我不明白怎么了。有人可以帮我吗?
删除日志下面的-acodec
之后:-
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/v1golf/Android/data/com.v1.v1golf2/files/VID_20191004_163521.mp4':
Duration: 00:00:05.76, start: 0.000000, bitrate: 4915 kb/s
Stream #0:0(eng): Video: h264 (avc1 / 0x31637661), yuv420p, 768x1024 [SAR 1:1 DAR 3:4], 4963 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
handler_name : VideoHandler
Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 8000 Hz, mono, fltp, 25 kb/s (default)
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/v1golf/Android/data/com.v1.v1golf2/files/1908151648466PEV-260690.mp4':
compatible_brands: isomiso2avc1mp41
Duration: 00:00:07.23, start: 0.000000, bitrate: 21924 kb/s
Stream #1:0(und): Video: h264 (avc1 / 0x31637661), yuv420p, 1280x720, 21923 kb/s, 59.86 fps, 60 tbr, 15360 tbn, 120 tbc (default)
handler_name : VideoHandler
String[] complexCommand = {"-i", yourRealPath, "-i", compare_moviePath, "-filter_complex", "[0:v]setpts=PTS-STARTPTS, " +
"scale=480x360[top];[1:v]setpts=PTS-STARTPTS, scale=480x360,format=yuva420p,colorchannelmixer=aa=0.5[bottom];" +
"[top][bottom]overlay=shortest=1", "-acodec","copy", "-vcodec", "libx264", filePath};
尝试上面的代码