<p>You most likely can't.  45 seconds is NOT a long time for encoding a video on Android.  You aren't just putting one file at the end of another, you are encoding a new video that includes the contents of both videos played one after the other.  This involves transcoding the entire video to create a new one and that takes time.  45 seconds is actually pretty fast depending on the length of the two clips you are combining.</p>

<p>If the two clips have similar encoding settings, it might be possible to use some kind of container format that supports chaining multiple files one after the other, but it would end up playing more like a playlist than a continuous video then.</p>

CC BY-SA 3.0
2017-11-22T08:06:46.970Z
In container mp4 you can join videos without re-encoding.
bukkojot
CC BY-SA 4.0
2018-07-23T04:45:15.110Z
@bukkojot can u please explain in detail !
Akash Dubey
CC BY-SA 3.0
2017-05-31T16:14:38.927Z
2017-05-31T16:14:38.927Z
AJ Henderson
<p>I am merging two videos using ffmpeg in android but it takes 45secs to merge. below is my command</p>

<pre><code>complexCommand = new String[]{"-y", "-i", file1.toString(), "-i", file2.toString(), "-strict", "experimental", "-filter_complex",
                "[0:v]scale=480x640,setsar=1:1[v0];[1:v]scale=480x640,setsar=1:1[v1];[v0][0:a][v1][1:a] concat=n=2:v=1:a=1",
                "-ab", "48000", "-ac", "2", "-ar", "22050", "-s", "480x640", "-vcodec", "libx264","-crf","27","-q","4","-preset", "ultrafast", rootPath + "/output.mp4"};
</code></pre>

<p>I have included ffmpeg library to my project by adding below line into Gradle-</p>

<pre><code> compile 'com.writingminds:FFmpegAndroid:0.3.2'
</code></pre>

<p>Below is my log </p>

<pre><code>       18:50.630 13704-13704/pkgD/FFmpeg: Build.CPU_ABI : armeabi-v7a
    18:50.650 13704-13704/pkgI/FFmpeg: Loading FFmpeg for armv7 CPU
    18:50.660 13704-13704/pkgD/Start: merge started
    18:50.970 13704-16532/pkgD/FFmpeg: Running publishing updates method
    18:51.000 13704-13704/pkgD/progress: ffmpeg version n3.0.1 Copyright (c) 2000-2016 the FFmpeg developers
    18:51.030 13704-13704/pkgD/ViewRootImpl: #1 mView = com.android.internal.policy.PhoneWindow$DecorView{b3c7246 V.E...... R.....I. 0,0-0,0}
    18:51.040 13704-13704/pkgD/progress:   built with gcc 4.8 (GCC)
    18:51.040 13704-13704/pkgD/progress:   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=
    18:51.040 13704-13704/pkgD/progress:   libavutil      55. 17.103 / 55. 17.103
    18:51.040 13704-13704/pkgD/progress:   libavcodec     57. 24.102 / 57. 24.102
    18:51.040 13704-13704/pkgD/progress:   libavformat    57. 25.100 / 57. 25.100
    18:51.040 13704-13704/pkgD/progress:   libavdevice    57.  0.101 / 57.  0.101
    18:51.040 13704-13704/pkgD/progress:   libavfilter     6. 31.100 /  6. 31.100
    18:51.040 13704-13704/pkgD/progress:   libswscale      4.  0.100 /  4.  0.100
    18:51.040 13704-13704/pkgD/progress:   libswresample   2.  0.101 /  2.  0.101
    18:51.040 13704-13704/pkgD/progress:   libpostproc    54.  0.100 / 54.  0.100
    18:51.090 13704-13704/pkgD/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1
    18:51.950 13704-13704/pkgD/progress: Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/MP4_20170519_121822.mp4':
    18:51.950 13704-13704/pkgD/progress:   Metadata:
    18:51.950 13704-13704/pkgD/progress:     major_brand     : iso6
    18:51.950 13704-13704/pkgD/progress:     minor_version   : 1
    18:51.950 13704-13704/pkgD/progress:     compatible_brands: mp42iso6avc1isom
    18:51.950 13704-13704/pkgD/progress:     creation_time   : 2017-    05-19 06:48:22
    18:51.950 13704-13704/pkgD/progress:   Duration: 00:00:04.00, start: 0.000000, bitrate: 17175 kb/s
    18:51.950 13704-13704/pkgD/progress:     Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 16914 kb/s, 30 fps, 30 tbr, 90k tbn, 180k tbc (default)
    18:51.950 13704-13704/pkgD/progress:     Metadata:
    18:51.950 13704-13704/pkgD/progress:       rotate          : 90
    18:51.950 13704-13704/pkgD/progress:       creation_time   : 2017-05-16 08:17:54
    18:51.950 13704-13704/pkgD/progress:     Side data:
    18:51.950 13704-13704/pkgD/progress:       displaymatrix: rotation of -90.00 degrees
    18:51.950 13704-13704/pkgD/progress:     Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 256 kb/s (default)
    18:51.950 13704-13704/pkgD/progress:     Metadata:
    18:51.950 13704-13704/pkgD/progress:       creation_time   : 2017-05-16 08:17:54
    18:52.830 13704-13704/pkgD/progress: Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/MP4_20170519_121834.mp4':
    18:52.830 13704-13704/pkgD/progress:   Metadata:
    18:52.830 13704-13704/pkgD/progress:     major_brand     : iso6
    18:52.830 13704-13704/pkgD/progress:     minor_version   : 1
    18:52.830 13704-13704/pkgD/progress:     compatible_brands: mp42iso6avc1isom
    18:52.830 13704-13704/pkgD/progress:     creation_time   : 2017-    05-19 06:48:34
    18:52.830 13704-13704/pkgD/progress:   Duration: 00:00:05.00, start: 0.000000, bitrate: 17272 kb/s
    18:52.830 13704-13704/pkgD/progress:     Stream #1:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 17010 kb/s, 30.01 fps, 30 tbr, 90k tbn, 180k tbc (default)
    18:52.830 13704-13704/pkgD/progress:     Metadata:
    18:52.830 13704-13704/pkgD/progress:       rotate          : 90
    18:52.830 13704-13704/pkgD/progress:       creation_time   : 2017-05-16 08:11:38
    18:52.830 13704-13704/pkgD/progress:     Side data:
    18:52.830 13704-13704/pkgD/progress:       displaymatrix: rotation of -90.00 degrees
    18:52.830 13704-13704/pkgD/progress:     Stream #1:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 255 kb/s (default)
    18:52.830 13704-13704/pkgD/progress:     Metadata:
    18:52.830 13704-13704/pkgD/progress:       creation_time   : 2017-05-16 08:11:38
    18:52.830 13704-13704/pkgD/progress: [Parsed_setsar_1 @ 0xb8599380] num:den syntax is deprecated, please use num/den or named options instead
    18:52.830 13704-13704/pkgD/progress: [Parsed_setsar_3 @ 0xb8626470] num:den syntax is deprecated, please use num/den or named options instead
    18:52.830 13704-13704/pkgD/progress: Codec AVOption preset (Set the encoding preset (cf. x264 --fullhelp)) specified for output file #0 (/storage/emulated/0/output.mp4) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
    18:52.850 13704-13704/pkgD/progress: [Parsed_setsar_1 @ 0xb85cece0] num:den syntax is deprecated, please use num/den or named options instead
    18:52.850 13704-13704/pkgD/progress: [Parsed_setsar_3 @ 0xb861fa70] num:den syntax is deprecated, please use num/den or named options instead
    18:53.050 13704-13704/pkgD/progress: [aac @ 0xb85ce8f0] Too many bits 95062.494331 &gt; 12288 per frame requested, clamping to max
    18:53.100 13704-13704/pkgD/progress: Output #0, mp4, to '/storage/emulated/0/output.mp4':
    18:53.100 13704-13704/pkgD/progress:   Metadata:
    18:53.100 13704-13704/pkgD/progress:     major_brand     : iso6
    18:53.100 13704-13704/pkgD/progress:     minor_version   : 1
    18:53.100 13704-13704/pkgD/progress:     compatible_brands: mp42iso6avc1isom
    18:53.100 13704-13704/pkgD/progress:     encoder         : Lavf57.25.100
    18:53.100 13704-13704/pkgD/progress:     Stream #0:0: Video: mpeg4 ( [0][0][0] / 0x0020), yuv420p, 480x360 [SAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 24 fps, 12288 tbn, 24 tbc (default)
    18:53.100 13704-13704/pkgD/progress:     Metadata:
    18:53.100 13704-13704/pkgD/progress:       encoder         : Lavc57.24.102 mpeg4
    18:53.100 13704-13704/pkgD/progress:     Side data:
    18:53.100 13704-13704/pkgD/progress:       unknown side data type 10 (24 bytes)
    18:53.100 13704-13704/pkgD/progress:     Stream #0:1: Audio: aac (LC) ([64][0][0][0] / 0x0040), 22050 Hz, stereo, fltp, 264 kb/s (default)
    18:53.100 13704-13704/pkgD/progress:     Metadata:
    18:53.120 13704-13704/pkgD/progress:       encoder         : Lavc57.24.102 aac
    18:53.120 13704-13704/pkgD/progress: Stream mapping:
    18:53.120 13704-13704/pkgD/progress:   Stream #0:0 (h264) -&gt; scale
    18:53.120 13704-13704/pkgD/progress:   Stream #0:1 (aac) -&gt; concat:in0:a0
    18:53.120 13704-13704/pkgD/progress:   Stream #1:0 (h264) -&gt; scale
    18:53.120 13704-13704/pkgD/progress:   Stream #1:1 (aac) -&gt; concat:in1:a0
    18:53.120 13704-13704/pkgD/progress:   concat:out:v0 -&gt; Stream #0:0 (mpeg4)
    18:53.120 13704-13704/pkgD/progress:   concat:out:a0 -&gt; Stream #0:1 (aac)
    18:53.120 13704-13704/pkgD/progress: Press [q] to stop, [?] for help
    18:53.870 13704-13704/pkgD/progress: frame=    3 fps=0.0 q=2.0 size=       0kB time=00:00:00.12 bitrate=   2.8kbits/s speed=0.203x    
    18:54.100 13704-13704/pkgD/progress: Past duration 0.754143 too large
    18:54.800 13704-13704/pkgD/progress: frame=    7 fps=5.9 q=7.9 size=       0kB time=00:00:00.29 bitrate=   1.2kbits/s speed=0.247x    
    18:54.950 13704-13704/pkgD/progress: frame=    8 fps=4.7 q=8.8 size=       0kB time=00:00:00.33 bitrate=   1.1kbits/s speed=0.198x    
    18:55.420 13704-13704/pkgD/progress: frame=   11 fps=5.0 q=11.0 size=       0kB time=00:00:00.45 bitrate=   0.8kbits/s dup=0 drop=1 speed=0.209x    
    18:56.040 13704-13704/pkgD/progress: frame=   15 fps=5.4 q=11.6 size=       0kB time=00:00:00.62 bitrate=   0.6kbits/s dup=0 drop=2 speed=0.224x    
    18:56.630 13704-13704/pkgD/progress: frame=   19 fps=5.6 q=13.2 size=       0kB time=00:00:00.79 bitrate=   0.4kbits/s dup=0 drop=3 speed=0.232x    
    18:57.130 13704-13704/pkgD/progress: frame=   22 fps=5.5 q=14.0 size=       0kB time=00:00:00.91 bitrate=   0.4kbits/s dup=0 drop=3 speed=0.228x    
    18:57.630 13704-13704/pkgD/progress: frame=   26 fps=5.7 q=16.2 size=       0kB time=00:00:01.08 bitrate=   0.5kbits/s dup=0 drop=4 speed=0.239x    
    18:58.180 13704-13704/pkgD/progress: frame=   29 fps=5.7 q=14.7 size=      48kB time=00:00:01.20 bitrate= 323.3kbits/s dup=0 drop=5 speed=0.238x    
    19:59.840 13704-13704/pkgD/progress: frame=  179 fps=2.7 q=20.7 size=     396kB time=00:00:08.40 bitrate= 386.2kbits/s dup=0 drop=43 speed=0.126x    
    20:00.270 13704-13704/pkgD/progress: frame=  181 fps=2.7 q=16.3 size=     405kB time=00:00:08.45 bitrate= 392.4kbits/s dup=0 drop=43 speed=0.126x    
    20:00.920 13704-13704/pkgD/progress: frame=  182 fps=2.7 q=20.6 size=     407kB time=00:00:08.54 bitrate= 389.6kbits/s dup=0 drop=43 speed=0.126x    
    20:01.340 13704-13704/pkgD/progress: frame=  183 fps=2.7 q=21.6 size=     408kB time=00:00:08.59 bitrate= 388.7kbits/s dup=0 drop=44 speed=0.126x    
    20:02.390 13704-13704/pkgD/progress: frame=  186 fps=2.7 q=23.2 size=     412kB time=00:00:08.68 bitrate= 388.3kbits/s dup=0 drop=44 speed=0.126x    
    20:02.810 13704-13704/pkgD/progress: frame=  187 fps=2.7 q=23.0 size=     413kB time=00:00:08.73 bitrate= 387.7kbits/s dup=0 drop=45 speed=0.125x    
    20:03.850 13704-13704/pkgD/progress: frame=  190 fps=2.7 q=22.5 size=     417kB time=00:00:08.82 bitrate= 387.4kbits/s dup=0 drop=45 speed=0.126x    
    20:04.220 13704-13704/pkgD/progress: frame=  190 fps=2.7 q=22.5 size=     417kB time=00:00:08.87 bitrate= 385.3kbits/s dup=0 drop=45 speed=0.125x    
    20:04.720 13704-13704/pkgD/progress: frame=  194 fps=2.7 q=20.4 size=     429kB time=00:00:08.87 bitrate= 395.8kbits/s dup=0 drop=46 speed=0.124x    
    20:05.340 13704-13704/pkgD/progress: frame=  198 fps=2.7 q=19.8 size=     434kB time=00:00:08.87 bitrate= 400.5kbits/s dup=0 drop=47 speed=0.123x    
    20:05.840 13704-13704/pkgD/progress: frame=  201 fps=2.8 q=21.8 size=     438kB time=00:00:08.87 bitrate= 404.3kbits/s dup=0 drop=48 speed=0.122x    
    20:06.450 13704-13704/pkgD/progress: frame=  205 fps=2.8 q=15.7 size=     449kB time=00:00:08.87 bitrate= 414.3kbits/s dup=0 drop=49 speed=0.121x    
    20:06.970 13704-13704/pkgD/progress: frame=  208 fps=2.8 q=18.2 size=     452kB time=00:00:08.87 bitrate= 417.3kbits/s dup=0 drop=50 speed=0.12x    
    20:07.570 13704-13704/pkgD/progress: frame=  212 fps=2.9 q=17.8 size=     457kB time=00:00:08.87 bitrate= 422.2kbits/s dup=0 drop=51 speed=0.119x    
    20:08.070 13704-13704/pkgD/progress: frame=  215 fps=2.9 q=18.9 size=     458kB time=00:00:08.95 bitrate= 419.0kbits/s dup=0 drop=52 speed=0.12x    
    20:08.570 13704-13704/pkgD/progress: frame=  218 fps=2.9 q=19.8 size=     459kB time=00:00:09.08 bitrate= 414.3kbits/s dup=0 drop=52 speed=0.12x    
    20:08.960 13704-13704/pkgD/progress: frame=  218 fps=2.9 q=19.8 Lsize=     475kB time=00:00:09.08 bitrate= 428.7kbits/s dup=0 drop=52 speed=0.12x    
    20:08.960 13704-13704/pkgD/progress: video:361kB audio:109kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.077294%
    20:08.990 13704-13704/pkgD/progress: [aac @ 0xb85ce8f0] Qavg: 65536.000
    20:08.990 13704-13704/pkgD/Success: 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/MP4_20170519_121822.mp4':
                                                                  Metadata:
                                                                    major_brand     : iso6
                                                                    minor_version   : 1
                                                                    compatible_brands: mp42iso6avc1isom
                                                                    creation_time   : 2017-    05-19 06:48:22
                                                                  Duration: 00:00:04.00, start: 0.000000, bitrate: 17175 kb/s
                                                                    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 16914 kb/s, 30 fps, 30 tbr, 90k tbn, 180k tbc (default)
                                                                    Metadata:
                                                                      rotate          : 90
                                                                      creation_time   : 2017-05-16 08:17:54
                                                                    Side data:
                                                                      displaymatrix: rotation of -90.00 degrees
                                                                    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 256 kb/s (default)
                                                                    Metadata:
                                                                      creation_time   : 2017-05-16 08:17:54
                                                                Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/MP4_20170519_121834.mp4':
                                                                  Metadata:
                                                                    major_brand     : iso6
                                                                    minor_version   : 1
                                                                    compatible_brands: mp42iso6avc1isom
                                                                    creation_time   : 2017-    05-19 06:48:34
                                                                  Duration: 00:00:05.00, start: 0.000000, bitrate: 17272 kb/s
                                                                    Stream #1:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 17010 kb/s, 30.01 fps, 30 tbr, 90k tbn, 180k tbc (default)
                                                                    Metadata:
                                                                      rotate          : 90
                                                                      creation_time   : 2017-05-16 08:11:38
                                                                    Side data:
                                                                      displaymatrix: rotation of -90.00 degrees
                                                                    Stream #1:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 255 kb/s (default)
                                                                    Metadata:
                                                                      creation_time   : 2017-05-16 08:11:38
                                                                [Parsed_setsar_1 @ 0xb8599380] num:den syntax is deprecated, please use num/den or named options instead
                                                                [Parsed_setsar_3 @ 0xb8626470] num:den syntax is deprecated, please use num/den or named options instead
                                                                Codec AVOption preset (Set the encoding preset (cf. x264 --fullhelp)) specified for output file #0 (/storage/emulated/0/output.mp4) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
                                                                [Parsed_setsar_1 @ 0xb85cece0] num:den syntax is deprecated, please use num/den or named options instead
                                                                [Parsed_setsar_3 @ 0xb861fa70] num:den syntax is deprecated, please use num/den or named options instead
                                                                [aac @ 0xb85ce8f0] Too many bits 95062.494331 &gt; 12288 per frame requested, clamping to max
                                                                Output #0, mp4, to '/storage/emulated/0/output.mp4':
                                                                  Metadata:
                                                                    major_brand     : iso6
                                                                    minor_version   : 1
                                                                    compatible_brands: mp42iso6avc1isom
                                                                    encoder         : Lavf57.25.100
                                                                    Stream #0:0: Video: mpeg4 ( [0][0][0] / 0x00
    20:09.020 13704-13704/pkgI/ExoPlayerImpl: Init ExoPlayerLib/2.4.0 [j5lte, SM-J500F, samsung, 23]
    20:09.020 13704-16462/pkgI/ACodec: [OMX.qcom.video.decoder.avc] Now Executing-&gt;Idle
    20:09.050 13704-16462/pkgI/ACodec: [OMX.qcom.video.decoder.avc] Now Idle-&gt;Loaded
    20:09.050 13704-16462/pkgI/ACodec: [OMX.qcom.video.decoder.avc] Now Loaded
    20:09.050 13704-16462/pkgI/ACodec:  [OMX.qcom.video.decoder.avc] Now kWhatShutdownCompleted event : 7115
    20:09.050 13704-16461/pkgI/MediaCodec: Codec shutdown complete
    20:09.060 13704-16462/pkgI/ACodec:  [OMX.qcom.video.decoder.avc] Now uninitialized
    20:09.060 13704-16462/pkgI/ACodec:  [] Now kWhatShutdownCompleted event : 7115
    20:09.060 13704-16461/pkgI/MediaCodec: Codec shutdown complete
    20:09.080 13704-13704/pkgD/finish: merge finish
    20:09.110 13704-13704/pkgD/ViewRootImpl: #3 mView = null
    20:09.120 13704-13704/pkgD/ViewRootImpl: #1 mView = android.widget.LinearLayout{9229915 V.E...... ......I. 0,0-0,0 #10203a4 android:id/toast_layout_root}
    20:09.130 13704-13704/pkgE/ViewRootImpl: sendUserActionEvent() mView == null
    20:09.160 13704-20543/pkgW/VideoCapabilities: Unrecognized profile/level 32768/2 for video/mp4v-es
    20:09.170 13704-20543/pkgI/ACodec:  [] Now uninitialized
    20:09.170 13704-13704/pkgD/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1
    20:09.180 13704-20548/pkgI/ACodec: [] onAllocateComponent
    20:09.180 13704-20548/pkgI/OMXClient: Using client-side OMX mux.
    20:09.190 13704-20548/pkgI/ACodec: [OMX.qcom.video.decoder.mpeg4] Now Loaded
    20:09.190 13704-20547/pkgI/MediaCodec: [OMX.qcom.video.decoder.mpeg4] setting surface generation to 14032902
    20:09.210 13704-20548/pkgI/ACodec: [OMX.qcom.video.decoder.mpeg4] OMX_QCOM_FramePacking_Arbitrary is setting
    20:09.210 13704-20548/pkgI/ACodec: [OMX.qcom.video.decoder.mpeg4] Now Loaded-&gt;Idle
    20:09.220 13704-20548/pkgD/SurfaceUtils: set up nativeWindow 0xb7a04d30 for 480x360, color 0x7fa30c04, rotation 0, usage 0x42002900
    20:09.230 13704-20548/pkgI/ACodec: [OMX.qcom.video.decoder.mpeg4] configureOutputBuffersFromNativeWindow setBufferCount : 10, minUndequeuedBuffers : 4
    20:09.230 13704-20548/pkgI/ACodec: [OMX.qcom.video.decoder.mpeg4] Now Idle-&gt;Executing
    20:09.230 13704-20548/pkgI/ACodec: [OMX.qcom.video.decoder.mpeg4] Now Executing
    20:09.230 13704-20543/pkgI/ACodec:  [] Now uninitialized
    20:09.230 13704-20552/pkgI/ACodec: [] onAllocateComponent
    20:09.240 13704-20552/pkgI/OMXClient: Using client-side OMX mux.
    20:09.240 13704-20552/pkgI/ACodec: [OMX.SEC.aac.dec] Now Loaded
    20:09.240 13704-20552/pkgI/ACodec: [OMX.SEC.aac.dec] Now Loaded-&gt;Idle
    20:09.250 13704-20552/pkgI/ACodec: [OMX.SEC.aac.dec] Now Idle-&gt;Executing
    20:09.260 13704-20552/pkgI/ACodec: [OMX.SEC.aac.dec] Now Executing
    20:12.520 13704-13704/pkgD/ViewRootImpl: #3 mView = null
</code></pre>

<p>How can I make this go faster?</p>

CC BY-SA 3.0
2017-05-22T07:03:50.383Z
What is your question?
NoahL
CC BY-SA 3.0
2017-05-22T07:04:57.697Z
How to reduce time taken for merging videos
Akash Dubey
CC BY-SA 3.0
2017-05-22T08:16:57.963Z
Do you have to use `mpeg4` as vcodec?
Gyan
CC BY-SA 3.0
2017-05-22T09:02:41.873Z
no not necessary
Akash Dubey
CC BY-SA 3.0
2017-07-28T10:15:32.700Z
Is there any other options like I can compromise on Quality of video!
I have tried to do that by reducing the value of scale but It decreases the video preview display!!
Akash Dubey
<ffmpeg><video-editor><android>
How can I merge videos more quickly with ffmpeg on Android?
Akash Dubey
# How can I merge videos more quickly with ffmpeg on Android?

(Asked by: username_0 on 2017-05-22)

I am merging two videos using ffmpeg in android but it takes 45secs to merge. below is my command
complexCommand = new String[]{"-y", "-i", file1.toString(), "-i", file2.toString(), "-strict", "experimental", "-filter_complex",
                "[0:v]scale=480x640,setsar=1:1[v0];[1:v]scale=480x640,setsar=1:1[v1];[v0][0:a][v1][1:a] concat=n=2:v=1:a=1",
                "-ab", "48000", "-ac", "2", "-ar", "22050", "-s", "480x640", "-vcodec", "libx264","-crf","27","-q","4","-preset", "ultrafast", rootPath + "/output.mp4"};

I have included ffmpeg library to my project by adding below line into Gradle-
 compile 'com.writingminds:FFmpegAndroid:0.3.2'

Below is my log 
       18:50.630 13704-13704/pkgD/FFmpeg: Build.CPU_ABI : armeabi-v7a
    18:50.650 13704-13704/pkgI/FFmpeg: Loading FFmpeg for armv7 CPU
    18:50.660 13704-13704/pkgD/Start: merge started
    18:50.970 13704-16532/pkgD/FFmpeg: Running publishing updates method
    18:51.000 13704-13704/pkgD/progress: ffmpeg version n3.0.1 Copyright (c) 2000-2016 the FFmpeg developers
    18:51.030 13704-13704/pkgD/ViewRootImpl: #1 mView = com.android.internal.policy.PhoneWindow$DecorView{b3c7246 V.E...... R.....I. 0,0-0,0}
    18:51.040 13704-13704/pkgD/progress:   built with gcc 4.8 (GCC)
    18:51.040 13704-13704/pkgD/progress:   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=
    18:51.040 13704-13704/pkgD/progress:   libavutil      55. 17.103 / 55. 17.103
    18:51.040 13704-13704/pkgD/progress:   libavcodec     57. 24.102 / 57. 24.102
    18:51.040 13704-13704/pkgD/progress:   libavformat    57. 25.100 / 57. 25.100
    18:51.040 13704-13704/pkgD/progress:   libavdevice    57.  0.101 / 57.  0.101
    18:51.040 13704-13704/pkgD/progress:   libavfilter     6. 31.100 /  6. 31.100
    18:51.040 13704-13704/pkgD/progress:   libswscale      4.  0.100 /  4.  0.100
    18:51.040 13704-13704/pkgD/progress:   libswresample   2.  0.101 /  2.  0.101
    18:51.040 13704-13704/pkgD/progress:   libpostproc    54.  0.100 / 54.  0.100
    18:51.090 13704-13704/pkgD/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1
    18:51.950 13704-13704/pkgD/progress: Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/MP4_20170519_121822.mp4':
    18:51.950 13704-13704/pkgD/progress:   Metadata:
    18:51.950 13704-13704/pkgD/progress:     major_brand     : iso6
    18:51.950 13704-13704/pkgD/progress:     minor_version   : 1
    18:51.950 13704-13704/pkgD/progress:     compatible_brands: mp42iso6avc1isom
    18:51.950 13704-13704/pkgD/progress:     creation_time   : 2017-    05-19 06:48:22
    18:51.950 13704-13704/pkgD/progress:   Duration: 00:00:04.00, start: 0.000000, bitrate: 17175 kb/s
    18:51.950 13704-13704/pkgD/progress:     Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 16914 kb/s, 30 fps, 30 tbr, 90k tbn, 180k tbc (default)
    18:51.950 13704-13704/pkgD/progress:     Metadata:
    18:51.950 13704-13704/pkgD/progress:       rotate          : 90
    18:51.950 13704-13704/pkgD/progress:       creation_time   : 2017-05-16 08:17:54
    18:51.950 13704-13704/pkgD/progress:     Side data:
    18:51.950 13704-13704/pkgD/progress:       displaymatrix: rotation of -90.00 degrees
    18:51.950 13704-13704/pkgD/progress:     Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 256 kb/s (default)
    18:51.950 13704-13704/pkgD/progress:     Metadata:
    18:51.950 13704-13704/pkgD/progress:       creation_time   : 2017-05-16 08:17:54
    18:52.830 13704-13704/pkgD/progress: Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/MP4_20170519_121834.mp4':
    18:52.830 13704-13704/pkgD/progress:   Metadata:
    18:52.830 13704-13704/pkgD/progress:     major_brand     : iso6
    18:52.830 13704-13704/pkgD/progress:     minor_version   : 1
    18:52.830 13704-13704/pkgD/progress:     compatible_brands: mp42iso6avc1isom
    18:52.830 13704-13704/pkgD/progress:     creation_time   : 2017-    05-19 06:48:34
    18:52.830 13704-13704/pkgD/progress:   Duration: 00:00:05.00, start: 0.000000, bitrate: 17272 kb/s
    18:52.830 13704-13704/pkgD/progress:     Stream #1:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 17010 kb/s, 30.01 fps, 30 tbr, 90k tbn, 180k tbc (default)
    18:52.830 13704-13704/pkgD/progress:     Metadata:
    18:52.830 13704-13704/pkgD/progress:       rotate          : 90
    18:52.830 13704-13704/pkgD/progress:       creation_time   : 2017-05-16 08:11:38
    18:52.830 13704-13704/pkgD/progress:     Side data:
    18:52.830 13704-13704/pkgD/progress:       displaymatrix: rotation of -90.00 degrees
    18:52.830 13704-13704/pkgD/progress:     Stream #1:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 255 kb/s (default)
    18:52.830 13704-13704/pkgD/progress:     Metadata:
    18:52.830 13704-13704/pkgD/progress:       creation_time   : 2017-05-16 08:11:38
    18:52.830 13704-13704/pkgD/progress: [Parsed_setsar_1 @ 0xb8599380] num:den syntax is deprecated, please use num/den or named options instead
    18:52.830 13704-13704/pkgD/progress: [Parsed_setsar_3 @ 0xb8626470] num:den syntax is deprecated, please use num/den or named options instead
    18:52.830 13704-13704/pkgD/progress: Codec AVOption preset (Set the encoding preset (cf. x264 --fullhelp)) specified for output file #0 (/storage/emulated/0/output.mp4) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
    18:52.850 13704-13704/pkgD/progress: [Parsed_setsar_1 @ 0xb85cece0] num:den syntax is deprecated, please use num/den or named options instead
    18:52.850 13704-13704/pkgD/progress: [Parsed_setsar_3 @ 0xb861fa70] num:den syntax is deprecated, please use num/den or named options instead
    18:53.050 13704-13704/pkgD/progress: [aac @ 0xb85ce8f0] Too many bits 95062.494331 > 12288 per frame requested, clamping to max
    18:53.100 13704-13704/pkgD/progress: Output #0, mp4, to '/storage/emulated/0/output.mp4':
    18:53.100 13704-13704/pkgD/progress:   Metadata:
    18:53.100 13704-13704/pkgD/progress:     major_brand     : iso6
    18:53.100 13704-13704/pkgD/progress:     minor_version   : 1
    18:53.100 13704-13704/pkgD/progress:     compatible_brands: mp42iso6avc1isom
    18:53.100 13704-13704/pkgD/progress:     encoder         : Lavf57.25.100
    18:53.100 13704-13704/pkgD/progress:     Stream #0:0: Video: mpeg4 ( [0][0][0] / 0x0020), yuv420p, 480x360 [SAR 1:1 DAR 4:3], q=2-31, 200 kb/s, 24 fps, 12288 tbn, 24 tbc (default)
    18:53.100 13704-13704/pkgD/progress:     Metadata:
    18:53.100 13704-13704/pkgD/progress:       encoder         : Lavc57.24.102 mpeg4
    18:53.100 13704-13704/pkgD/progress:     Side data:
    18:53.100 13704-13704/pkgD/progress:       unknown side data type 10 (24 bytes)
    18:53.100 13704-13704/pkgD/progress:     Stream #0:1: Audio: aac (LC) ([64][0][0][0] / 0x0040), 22050 Hz, stereo, fltp, 264 kb/s (default)
    18:53.100 13704-13704/pkgD/progress:     Metadata:
    18:53.120 13704-13704/pkgD/progress:       encoder         : Lavc57.24.102 aac
    18:53.120 13704-13704/pkgD/progress: Stream mapping:
    18:53.120 13704-13704/pkgD/progress:   Stream #0:0 (h264) -> scale
    18:53.120 13704-13704/pkgD/progress:   Stream #0:1 (aac) -> concat:in0:a0
    18:53.120 13704-13704/pkgD/progress:   Stream #1:0 (h264) -> scale
    18:53.120 13704-13704/pkgD/progress:   Stream #1:1 (aac) -> concat:in1:a0
    18:53.120 13704-13704/pkgD/progress:   concat:out:v0 -> Stream #0:0 (mpeg4)
    18:53.120 13704-13704/pkgD/progress:   concat:out:a0 -> Stream #0:1 (aac)
    18:53.120 13704-13704/pkgD/progress: Press [q] to stop, [?] for help
    18:53.870 13704-13704/pkgD/progress: frame=    3 fps=0.0 q=2.0 size=       0kB time=00:00:00.12 bitrate=   2.8kbits/s speed=0.203x    
    18:54.100 13704-13704/pkgD/progress: Past duration 0.754143 too large
    18:54.800 13704-13704/pkgD/progress: frame=    7 fps=5.9 q=7.9 size=       0kB time=00:00:00.29 bitrate=   1.2kbits/s speed=0.247x    
    18:54.950 13704-13704/pkgD/progress: frame=    8 fps=4.7 q=8.8 size=       0kB time=00:00:00.33 bitrate=   1.1kbits/s speed=0.198x    
    18:55.420 13704-13704/pkgD/progress: frame=   11 fps=5.0 q=11.0 size=       0kB time=00:00:00.45 bitrate=   0.8kbits/s dup=0 drop=1 speed=0.209x    
    18:56.040 13704-13704/pkgD/progress: frame=   15 fps=5.4 q=11.6 size=       0kB time=00:00:00.62 bitrate=   0.6kbits/s dup=0 drop=2 speed=0.224x    
    18:56.630 13704-13704/pkgD/progress: frame=   19 fps=5.6 q=13.2 size=       0kB time=00:00:00.79 bitrate=   0.4kbits/s dup=0 drop=3 speed=0.232x    
    18:57.130 13704-13704/pkgD/progress: frame=   22 fps=5.5 q=14.0 size=       0kB time=00:00:00.91 bitrate=   0.4kbits/s dup=0 drop=3 speed=0.228x    
    18:57.630 13704-13704/pkgD/progress: frame=   26 fps=5.7 q=16.2 size=       0kB time=00:00:01.08 bitrate=   0.5kbits/s dup=0 drop=4 speed=0.239x    
    18:58.180 13704-13704/pkgD/progress: frame=   29 fps=5.7 q=14.7 size=      48kB time=00:00:01.20 bitrate= 323.3kbits/s dup=0 drop=5 speed=0.238x    
    19:59.840 13704-13704/pkgD/progress: frame=  179 fps=2.7 q=20.7 size=     396kB time=00:00:08.40 bitrate= 386.2kbits/s dup=0 drop=43 speed=0.126x    
    20:00.270 13704-13704/pkgD/progress: frame=  181 fps=2.7 q=16.3 size=     405kB time=00:00:08.45 bitrate= 392.4kbits/s dup=0 drop=43 speed=0.126x    
    20:00.920 13704-13704/pkgD/progress: frame=  182 fps=2.7 q=20.6 size=     407kB time=00:00:08.54 bitrate= 389.6kbits/s dup=0 drop=43 speed=0.126x    
    20:01.340 13704-13704/pkgD/progress: frame=  183 fps=2.7 q=21.6 size=     408kB time=00:00:08.59 bitrate= 388.7kbits/s dup=0 drop=44 speed=0.126x    
    20:02.390 13704-13704/pkgD/progress: frame=  186 fps=2.7 q=23.2 size=     412kB time=00:00:08.68 bitrate= 388.3kbits/s dup=0 drop=44 speed=0.126x    
    20:02.810 13704-13704/pkgD/progress: frame=  187 fps=2.7 q=23.0 size=     413kB time=00:00:08.73 bitrate= 387.7kbits/s dup=0 drop=45 speed=0.125x    
    20:03.850 13704-13704/pkgD/progress: frame=  190 fps=2.7 q=22.5 size=     417kB time=00:00:08.82 bitrate= 387.4kbits/s dup=0 drop=45 speed=0.126x    
    20:04.220 13704-13704/pkgD/progress: frame=  190 fps=2.7 q=22.5 size=     417kB time=00:00:08.87 bitrate= 385.3kbits/s dup=0 drop=45 speed=0.125x    
    20:04.720 13704-13704/pkgD/progress: frame=  194 fps=2.7 q=20.4 size=     429kB time=00:00:08.87 bitrate= 395.8kbits/s dup=0 drop=46 speed=0.124x    
    20:05.340 13704-13704/pkgD/progress: frame=  198 fps=2.7 q=19.8 size=     434kB time=00:00:08.87 bitrate= 400.5kbits/s dup=0 drop=47 speed=0.123x    
    20:05.840 13704-13704/pkgD/progress: frame=  201 fps=2.8 q=21.8 size=     438kB time=00:00:08.87 bitrate= 404.3kbits/s dup=0 drop=48 speed=0.122x    
    20:06.450 13704-13704/pkgD/progress: frame=  205 fps=2.8 q=15.7 size=     449kB time=00:00:08.87 bitrate= 414.3kbits/s dup=0 drop=49 speed=0.121x    
    20:06.970 13704-13704/pkgD/progress: frame=  208 fps=2.8 q=18.2 size=     452kB time=00:00:08.87 bitrate= 417.3kbits/s dup=0 drop=50 speed=0.12x    
    20:07.570 13704-13704/pkgD/progress: frame=  212 fps=2.9 q=17.8 size=     457kB time=00:00:08.87 bitrate= 422.2kbits/s dup=0 drop=51 speed=0.119x    
    20:08.070 13704-13704/pkgD/progress: frame=  215 fps=2.9 q=18.9 size=     458kB time=00:00:08.95 bitrate= 419.0kbits/s dup=0 drop=52 speed=0.12x    
    20:08.570 13704-13704/pkgD/progress: frame=  218 fps=2.9 q=19.8 size=     459kB time=00:00:09.08 bitrate= 414.3kbits/s dup=0 drop=52 speed=0.12x    
    20:08.960 13704-13704/pkgD/progress: frame=  218 fps=2.9 q=19.8 Lsize=     475kB time=00:00:09.08 bitrate= 428.7kbits/s dup=0 drop=52 speed=0.12x    
    20:08.960 13704-13704/pkgD/progress: video:361kB audio:109kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.077294%
    20:08.990 13704-13704/pkgD/progress: [aac @ 0xb85ce8f0] Qavg: 65536.000
    20:08.990 13704-13704/pkgD/Success: 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/MP4_20170519_121822.mp4':
                                                                  Metadata:
                                                                    major_brand     : iso6
                                                                    minor_version   : 1
                                                                    compatible_brands: mp42iso6avc1isom
                                                                    creation_time   : 2017-    05-19 06:48:22
                                                                  Duration: 00:00:04.00, start: 0.000000, bitrate: 17175 kb/s
                                                                    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 16914 kb/s, 30 fps, 30 tbr, 90k tbn, 180k tbc (default)
                                                                    Metadata:
                                                                      rotate          : 90
                                                                      creation_time   : 2017-05-16 08:17:54
                                                                    Side data:
                                                                      displaymatrix: rotation of -90.00 degrees
                                                                    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 256 kb/s (default)
                                                                    Metadata:
                                                                      creation_time   : 2017-05-16 08:17:54
                                                                Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/MP4_20170519_121834.mp4':
                                                                  Metadata:
                                                                    major_brand     : iso6
                                                                    minor_version   : 1
                                                                    compatible_brands: mp42iso6avc1isom
                                                                    creation_time   : 2017-    05-19 06:48:34
                                                                  Duration: 00:00:05.00, start: 0.000000, bitrate: 17272 kb/s
                                                                    Stream #1:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 17010 kb/s, 30.01 fps, 30 tbr, 90k tbn, 180k tbc (default)
                                                                    Metadata:
                                                                      rotate          : 90
                                                                      creation_time   : 2017-05-16 08:11:38
                                                                    Side data:
                                                                      displaymatrix: rotation of -90.00 degrees
                                                                    Stream #1:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 255 kb/s (default)
                                                                    Metadata:
                                                                      creation_time   : 2017-05-16 08:11:38
                                                                [Parsed_setsar_1 @ 0xb8599380] num:den syntax is deprecated, please use num/den or named options instead
                                                                [Parsed_setsar_3 @ 0xb8626470] num:den syntax is deprecated, please use num/den or named options instead
                                                                Codec AVOption preset (Set the encoding preset (cf. x264 --fullhelp)) specified for output file #0 (/storage/emulated/0/output.mp4) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
                                                                [Parsed_setsar_1 @ 0xb85cece0] num:den syntax is deprecated, please use num/den or named options instead
                                                                [Parsed_setsar_3 @ 0xb861fa70] num:den syntax is deprecated, please use num/den or named options instead
                                                                [aac @ 0xb85ce8f0] Too many bits 95062.494331 > 12288 per frame requested, clamping to max
                                                                Output #0, mp4, to '/storage/emulated/0/output.mp4':
                                                                  Metadata:
                                                                    major_brand     : iso6
                                                                    minor_version   : 1
                                                                    compatible_brands: mp42iso6avc1isom
                                                                    encoder         : Lavf57.25.100
                                                                    Stream #0:0: Video: mpeg4 ( [0][0][0] / 0x00
    20:09.020 13704-13704/pkgI/ExoPlayerImpl: Init ExoPlayerLib/2.4.0 [j5lte, SM-J500F, samsung, 23]
    20:09.020 13704-16462/pkgI/ACodec: [OMX.qcom.video.decoder.avc] Now Executing->Idle
    20:09.050 13704-16462/pkgI/ACodec: [OMX.qcom.video.decoder.avc] Now Idle->Loaded
    20:09.050 13704-16462/pkgI/ACodec: [OMX.qcom.video.decoder.avc] Now Loaded
    20:09.050 13704-16462/pkgI/ACodec:  [OMX.qcom.video.decoder.avc] Now kWhatShutdownCompleted event : 7115
    20:09.050 13704-16461/pkgI/MediaCodec: Codec shutdown complete
    20:09.060 13704-16462/pkgI/ACodec:  [OMX.qcom.video.decoder.avc] Now uninitialized
    20:09.060 13704-16462/pkgI/ACodec:  [] Now kWhatShutdownCompleted event : 7115
    20:09.060 13704-16461/pkgI/MediaCodec: Codec shutdown complete
    20:09.080 13704-13704/pkgD/finish: merge finish
    20:09.110 13704-13704/pkgD/ViewRootImpl: #3 mView = null
    20:09.120 13704-13704/pkgD/ViewRootImpl: #1 mView = android.widget.LinearLayout{9229915 V.E...... ......I. 0,0-0,0 #10203a4 android:id/toast_layout_root}
    20:09.130 13704-13704/pkgE/ViewRootImpl: sendUserActionEvent() mView == null
    20:09.160 13704-20543/pkgW/VideoCapabilities: Unrecognized profile/level 32768/2 for video/mp4v-es
    20:09.170 13704-20543/pkgI/ACodec:  [] Now uninitialized
    20:09.170 13704-13704/pkgD/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1
    20:09.180 13704-20548/pkgI/ACodec: [] onAllocateComponent
    20:09.180 13704-20548/pkgI/OMXClient: Using client-side OMX mux.
    20:09.190 13704-20548/pkgI/ACodec: [OMX.qcom.video.decoder.mpeg4] Now Loaded
    20:09.190 13704-20547/pkgI/MediaCodec: [OMX.qcom.video.decoder.mpeg4] setting surface generation to 14032902
    20:09.210 13704-20548/pkgI/ACodec: [OMX.qcom.video.decoder.mpeg4] OMX_QCOM_FramePacking_Arbitrary is setting
    20:09.210 13704-20548/pkgI/ACodec: [OMX.qcom.video.decoder.mpeg4] Now Loaded->Idle
    20:09.220 13704-20548/pkgD/SurfaceUtils: set up nativeWindow 0xb7a04d30 for 480x360, color 0x7fa30c04, rotation 0, usage 0x42002900
    20:09.230 13704-20548/pkgI/ACodec: [OMX.qcom.video.decoder.mpeg4] configureOutputBuffersFromNativeWindow setBufferCount : 10, minUndequeuedBuffers : 4
    20:09.230 13704-20548/pkgI/ACodec: [OMX.qcom.video.decoder.mpeg4] Now Idle->Executing
    20:09.230 13704-20548/pkgI/ACodec: [OMX.qcom.video.decoder.mpeg4] Now Executing
    20:09.230 13704-20543/pkgI/ACodec:  [] Now uninitialized
    20:09.230 13704-20552/pkgI/ACodec: [] onAllocateComponent
    20:09.240 13704-20552/pkgI/OMXClient: Using client-side OMX mux.
    20:09.240 13704-20552/pkgI/ACodec: [OMX.SEC.aac.dec] Now Loaded
    20:09.240 13704-20552/pkgI/ACodec: [OMX.SEC.aac.dec] Now Loaded->Idle
    20:09.250 13704-20552/pkgI/ACodec: [OMX.SEC.aac.dec] Now Idle->Executing
    20:09.260 13704-20552/pkgI/ACodec: [OMX.SEC.aac.dec] Now Executing
    20:12.520 13704-13704/pkgD/ViewRootImpl: #3 mView = null

How can I make this go faster?

**Tags:** ffmpeg, video-editor, android

> **Comments:**
> **username_1**: What is your question?  
> **username_0**: How to reduce time taken for merging videos  
> **username_2**: Do you have to use `mpeg4` as vcodec?  
> **username_0**: no not necessary  
> **username_0**: Is there any other options like I can compromise on Quality of video! I have tried to do that by reducing the value of scale but It decreases the video preview display!!  

---

## 1 answers

### Answer by username_3 on 2017-05-31. Score: 1 | Accepted answer

You most likely can't. 45 seconds is NOT a long time for encoding a video on Android. You aren't just putting one file at the end of another, you are encoding a new video that includes the contents of both videos played one after the other. This involves transcoding the entire video to create a new one and that takes time. 45 seconds is actually pretty fast depending on the length of the two clips you are combining.

If the two clips have similar encoding settings, it might be possible to use some kind of container format that supports chaining multiple files one after the other, but it would end up playing more like a playlist than a continuous video then.

> **Comments:**
> **username_4**: In container mp4 you can join videos without re-encoding.  
> **username_0**: @username_4 can u please explain in detail !  

---

