I am unable to concat two videos using FFMPEG. The command fails on the two special videos.
Video 1: First video is generated from the image using the following command:
ffmpeg -loop 1 -i 20150608_162807.jpg -c:v libx264 -t 3 -pix_fmt yuv420p out.mp4
I tried to concat the above video but it did not work so, I thought to add an audio to check if it will work.
ffmpeg -f lavfi -i aevalsrc=0 -i out.mp4 -shortest -c:v copy -c:a aac -strict experimental silent.mp4
but even with that it did not work.
Video 2: Second video is captured from the device camera.
Both of these videos can be downloaded from 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%
Update 1: The concat protocol doesn't work with mp4s. So, I tried the other approaches.
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
but still it didn't work.
Update 2: I have also used concat demuxer approach but it did not work as well.
I haven't tried the concat protocol, but I used the concat demuxer as follows to concatenate multiple MPEG4 videos:
fmpeg.exe -y -f concat -i filenames.txt -an -c:v copy output.mp4
If I remember correctly -an is for no audio.
And
filenames.txt
looks like this:This answer was helpful: https://stackoverflow.com/a/11175851/4742780