FFMPEG concat视频

时间:2015-06-09 09:30:10

标签: android ffmpeg video-processing video-editing

我无法使用FFMPEG连接两个视频。该命令在两个特殊视频上失败。

视频1: 使用以下命令从图像生成第一个视频:

ffmpeg -loop 1 -i 20150608_162807.jpg -c:v libx264 -t 3 -pix_fmt yuv420p out.mp4

我试图连接上面的视频,但它不起作用,我想添加一个音频来检查它是否会起作用。

ffmpeg -f lavfi -i aevalsrc=0 -i out.mp4 -shortest -c:v copy -c:a aac -strict experimental silent.mp4

但即便如此,它也无效。

视频2: 第二个视频是从设备摄像头捕获的。

这两个视频都可以从here下载。

06-09 11:05:56.238  29771-30715/﹕ ffmpeg -i concat:/storage/emulated/0/DCIM/Camera/20150603_142209.mp4|/storage/emulated/0/DCIM/Camera/silent.mp4 -c copy /storage/emulated/0/DCIM/test/MIU-2015-06-09 11-05-56.mp4
06-09 11:05:56.268  29771-30739/﹕ WARNING: linker: ffmpeg has text relocations. This is wasting memory and prevents security hardening. Please fix.
06-09 11:05:56.278  29771-30739/﹕ ffmpeg version n2.4.2 Copyright (c) 2000-2014 the FFmpeg developers
06-09 11:05:56.278  29771-30739/﹕ built on Apr  8 2015 11:29:21 with gcc 4.8 (GCC)
06-09 11:05:56.278  29771-30739/﹕ configuration: --target-os=linux --cross-prefix=/ilovevideo/jobs/ffmpeg-android-build-publisher/workspace/ffmpeg-android/toolchain-android/bin/arm-linux-androideabi- --arch=arm --cpu=cortex-a8 --enable-runtime-cpudetect --sysroot=/ilovevideo/jobs/ffmpeg-android-build-publisher/workspace/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 --enable-libass --enable-libfreetype --enable-libfribidi --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=/ilovevideo/jobs/ffmpeg-android-build-publisher/workspace/ffmpeg-android/ffmpeg-pkg-config --prefix=/ilovevideo/jobs/ffmpeg-android-build-publisher/workspace/ffmpeg-android/build/armeabi-v7a --extra-cflags='-I/ilovevideo/jobs/ffmpeg-android-build-publisher/workspace/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all' --extra-ldflags='-L/ilovevideo/jobs/ffmpeg-android-build-publisher/workspace/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-libs='-lpng -lexpat -lm' --extra-cxxflags=
06-09 11:05:56.278  29771-30739/﹕ libavutil      54.  7.100 / 54.  7.100
06-09 11:05:56.278  29771-30739/﹕ libavcodec     56.  1.100 / 56.  1.100
06-09 11:05:56.288  29771-30739/﹕ libavformat    56.  4.101 / 56.  4.101
06-09 11:05:56.288  29771-30739/﹕ libavdevice    56.  0.100 / 56.  0.100
06-09 11:05:56.288  29771-30739/﹕ libavfilter     5.  1.100 /  5.  1.100
06-09 11:05:56.288  29771-30739/﹕ libswscale      3.  0.100 /  3.  0.100
06-09 11:05:56.288  29771-30739/﹕ libswresample   1.  1.100 /  1.  1.100
06-09 11:05:56.288  29771-30739/﹕ libpostproc    53.  0.100 / 53.  0.100
06-09 11:05:56.308  29771-30739/﹕ [mov,mp4,m4a,3gp,3g2,mj2 @ 0xb5e5a400] Found duplicated MOOV Atom. Skipped it
06-09 11:05:56.398  29771-30739/﹕ Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'concat:/storage/emulated/0/DCIM/Camera/20150603_142209.mp4|/storage/emulated/0/DCIM/Camera/silent.mp4':
06-09 11:05:56.398  29771-30739/﹕ Metadata:
06-09 11:05:56.398  29771-30739/﹕ creation_time   : 2015-06-03 12:22:15
06-09 11:05:56.398  29771-30739/﹕ major_brand     : isom
06-09 11:05:56.398  29771-30739/﹕ minor_version   : 512
06-09 11:05:56.398  29771-30739/﹕ compatible_brands: isomiso2avc1mp41
06-09 11:05:56.398  29771-30739/﹕ Duration: 00:00:04.80, start: 0.000000, bitrate: 13040 kb/s
06-09 11:05:56.398  29771-30739/﹕ Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p, 1280x720, 12008 kb/s, 29.88 fps, 29.92 tbr, 90k tbn, 180k tbc (default)
06-09 11:05:56.398  29771-30739/﹕ Metadata:
06-09 11:05:56.398  29771-30739/﹕ creation_time   : 2015-06-03 12:22:15
06-09 11:05:56.398  29771-30739/﹕ handler_name    : VideoHandle
06-09 11:05:56.408  29771-30739/﹕ Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 256 kb/s (default)
06-09 11:05:56.408  29771-30739/﹕ Metadata:
06-09 11:05:56.408  29771-30739/﹕ creation_time   : 2015-06-03 12:22:15
06-09 11:05:56.408  29771-30739/﹕ handler_name    : SoundHandle
06-09 11:05:56.408  29771-30739/﹕ Output #0, mp4, to '/storage/emulated/0/DCIM/iLoveVideo/MIU-2015-06-09 11-05-56.mp4':
06-09 11:05:56.408  29771-30739/﹕ Metadata:
06-09 11:05:56.408  29771-30739/﹕ compatible_brands: isomiso2avc1mp41
06-09 11:05:56.408  29771-30739/﹕ major_brand     : isom
06-09 11:05:56.408  29771-30739/﹕ minor_version   : 512
06-09 11:05:56.408  29771-30739/﹕ encoder         : Lavf56.4.101
06-09 11:05:56.418  29771-30739/﹕ Stream #0:0(eng): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 1280x720, q=2-31, 12008 kb/s, 29.88 fps, 90k tbn, 90k tbc (default)
06-09 11:05:56.418  29771-30739/﹕ Metadata:
06-09 11:05:56.418  29771-30739/﹕ creation_time   : 2015-06-03 12:22:15
06-09 11:05:56.418  29771-30739/﹕ handler_name    : VideoHandle
06-09 11:05:56.418  29771-30739/﹕ Stream #0:1(eng): Audio: aac ([64][0][0][0] / 0x0040), 48000 Hz, stereo, 256 kb/s (default)
06-09 11:05:56.418  29771-30739/﹕ Metadata:
06-09 11:05:56.418  29771-30739/﹕ creation_time   : 2015-06-03 12:22:15
06-09 11:05:56.418  29771-30739/﹕ handler_name    : SoundHandle
06-09 11:05:56.418  29771-30739/﹕ Stream mapping:
06-09 11:05:56.418  29771-30739/﹕ Stream #0:0 -> #0:0 (copy)
06-09 11:05:56.418  29771-30739/﹕ Stream #0:1 -> #0:1 (copy)
06-09 11:05:56.418  29771-30739/﹕ Press [q] to stop, [?] for help
06-09 11:05:56.548  29771-30739/﹕ frame=  142 fps=0.0 q=-1.0 Lsize=    7121kB time=00:00:04.80 bitrate=12153.1kbits/s
06-09 11:05:56.558  29771-30739/﹕ video:6965kB audio:150kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.078725%

更新1: concat协议不适用于mp4s。所以,我尝试了其他方法。

ffmpeg -i input1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate1.ts
ffmpeg -i input2.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate2.ts 
ffmpeg -i "concat:intermediate1.ts|intermediate2.ts" -c copy -bsf:a aac_adtstoasc output.mp4

但它仍无效。

更新2: 我也使用了concat demuxer方法,但它没有用。

1 个答案:

答案 0 :(得分:0)

我没有尝试过concat 协议,但我使用了concat demuxer 来连接多个MPEG4视频:

fmpeg.exe -y -f concat -i filenames.txt -an -c:v copy output.mp4

如果我没记错的话 - 是没有音频。

filenames.txt看起来像这样:

file movie1.mp4
file movie2.mp4

这个答案很有帮助:https://stackoverflow.com/a/11175851/4742780