我正在使用this库将ffmpeg集成到我的Android应用程序中。
我能够使用图书馆成功裁剪视频,但现在我需要连接两个分辨率完全相同的视频。
我使用的ffmpeg命令是
-i input1.mp4 -i input2.mp4 -filter_complex concat=n=2:v=1:a=1 -f MP4 out.mp4
我在这2个视频上运行该命令时出现上述错误
ffmpeg version n3.0.1 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.8 (GCC)
configuration: --target-os=linux --cross-prefix=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/bin/arm-linux-androideabi- --arch=arm --cpu=cortex-a8 --enable-runtime-cpudetect --sysroot=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-fontconfig --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-ffprobe --enable-gpl --enable-yasm --disable-doc --disable-shared --enable-static --pkg-config=/home/vagrant/SourceCode/ffmpeg-android/ffmpeg-pkg-config --prefix=/home/vagrant/SourceCode/ffmpeg-android/build/armeabi-v7a --extra-cflags='-I/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all' --extra-ldflags='-L/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-libs='-lpng -lexpat -lm' --extra-cxxflags=
libavutil 55. 17.103 / 55. 17.103
libavcodec 57. 24.102 / 57. 24.102
libavformat 57. 25.100 / 57. 25.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 31.100 / 6. 31.100
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/DCIM/CameraDemo/1.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2016-09-02 10:17:23
com.android.version: 7.0
Duration: 00:00:04.46, start: 0.000000, bitrate: 6078 kb/s
Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuvj420p(pc, bt470bg/bt470bg/smpte170m), 720x480, 6010 kb/s, SAR 1:1 DAR 3:2, 30 fps, 30 tbr, 90k tbn, 180k tbc (default)
Metadata:
rotate : 270
creation_time : 2016-09-02 10:17:23
handler_name : VideoHandle
Side data:
displaymatrix: rotation of 90.00 degrees
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 96 kb/s (default)
Metadata:
creation_time : 2016-09-02 10:17:23
handler_name : SoundHandle
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/DCIM/CameraDemo/1.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2016-09-02 10:17:23
com.android.version: 7.0
Duration: 00:00:04.46, start: 0.000000, bitrate: 6078 kb/s
Stream #1:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuvj420p(pc, bt470bg/bt470bg/smpte170m), 720x480, 6010 kb/s, SAR 1:1 DAR 3:2, 30 fps, 30 tbr, 90k tbn, 180k tbc (default)
Metadata:
rotate : 270
creation_time : 2016-09-02 10:17:23
handler_name : VideoHandle
Side data:
displaymatrix: rotation of 90.00 degrees
Stream #1:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 96 kb/s (default)
Metadata:
creation_time : 2016-09-02 10:17:23
handler_name : SoundHandle
Cannot find a matching stream for unlabeled input pad 4 on filter Parsed_concat_0
编辑1:修正n = 3到n = 2将错误消息更改为 过滤器concat:out:v0具有未连接的输出
答案 0 :(得分:2)
n
值错误。你只有两个输入。
-i input1.mp4 -i input2.mp4 -filter_complex concat=n=2:v=1:a=1 -f MP4 out.mp4
另外,如果ffmpeg抱怨映射,请使用
-filter_complex "[0:v][0:a][1:v][1:a]concat=n=2:v=1:a=1[v][a]" -map [v] -map [a] out.mp4