ffmpeg seems to output a video with a wrong codec? - flutter

I´m using ffmpeg with flutter and I create a video from a lot of images. The problem: ffmpeg seems to not create a video with a right codec or something else.... please check my description below for concrete informations.
First the code parts:
Creating video from images
-r $settings_fps -i $tempPath/img%04d.jpg -vcodec libx264 -y -an -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" -shortest $tempPath/$videoFileName.mp4
Adding audio to the created video
-i ${finalSong.path} -i $videoPath -c:a aac -shortest $tempPath/$newVideoFileName.mp4
This is my video output from console on creating this video:
flutter: ffmpeg version git-2020-01-25-fd11dd500 Copyright (c) 2000-2020 the FFmpeg developers
built with Apple clang version 11.0.0 (clang-1100.0.33.17)
configuration: --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.2.sdk --prefix=/Users/taner/Projects/mobile-ffmpeg/prebuilt/ios-arm64-apple-darwin/ffmpeg --enable-version3 --arch=aarch64 --cpu=armv8 --target-os=darwin --ar=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar --cc=clang --cxx=clang++ --as='/Users/taner/Projects/mobile-ffmpeg/.tmp/gas-preprocessor.pl -arch aarch64 -- clang -arch arm64 -target aarch64-ios-darwin -march=armv8-a+crc+crypto -mcpu=generic -DMOBILE_FFMPEG_ARM64 -Wno-unused-function -Wno-deprecated-declarations -fstrict-aliasing -fembed-bitcode -DIOS -DMOBILE_FFMPEG_BUILD_DATE=20200125 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.2.sdk -Oz -miphoneos-version-min=12.1 -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.2.sdk/usr/include' --ranlib=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib --strip=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip --enable-neon --enable-cross-compile --enable-pic --enable-asm --enable-inline-asm --enable-optimizations --enable-swscale --enable-static --disable-shared --enable-small --disable-v4l2-m2m --disable-outdev=v4l2 --disable-outdev=fbdev --disable-indev=v4l2 --disable-indev=fbdev --disable-openssl --disable-xmm-clobber-test --disable-debug --disable-neon-clobber-test --disable-programs --disable-postproc --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-sndio --disable-schannel --disable-securetransport --disable-xlib --disable-cuda --disable-cuvid --disable-nvenc --disable-vaapi --disable-vdpau --disable-appkit --disable-alsa --disable-cuda --disable-cuvid --disable-nvenc --disable-vaapi --disable-vdpau --enable-gmp --enable-gnutls --enable-libx264 --enable-gpl --enable-libxvid --enable-gpl --enable-libx265 --enable-gpl --enable-libvidstab --enable-gpl --disable-sdl2 --enable-zlib --enable-audiotoolbox --enable-coreimage --enable-bzlib --enable-videotoolbox --enable-avfoundation --enable-iconv
libavutil 56. 38.100 / 56. 38.100
libavcodec 58. 65.102 / 58. 65.102
libavformat 58. 35.101 / 58. 35.101
libavdevice 58. 9.103 / 58. 9.103
libavfilter 7. 70.101 / 7. 70.101
libswscale 5. 6.100 / 5. 6.100
libswresample 3. 6.100 / 3. 6.100
Input #0, mp3, from '/var/mobile/Containers/Data/Application/AEEF7BB8-36F3-4ECD-824B-B294E9DF7294/Library/Caches/melodic_slow.mp3':
Metadata:
encoder : LAME 32bits version 3.99.5 (http://lame.sf.net)
TLEN : 134072
Duration: 00:02:14.11, start: 0.025057, bitrate: 320 kb/s
Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 320 kb/s
Metadata:
encoder : LAME3.99r
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '/var/mobile/Containers/Data/Application/AEEF7BB8-36F3-4ECD-824B-B294E9DF7294/Library/Caches/Memories_163dfbf0-f4cf-11ea-86c6-cd08c5621e56.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.35.101
Duration: 00:00:03.50, start: 0.000000, bitrate: 10069 kb/s
Stream #1:0(und): Video: h264 (avc1 / 0x31637661), yuvj422p(pc), 1920x1080 [SAR 1:1 DAR 16:9], 10065 kb/s, 24 fps, 24 tbr, 12288 tbn, 48 tbc (default)
Metadata:
handler_name : VideoHandler
Stream mapping:
Stream #1:0 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:0 -> #0:1 (mp3 (mp3float) -> aac (native))
Press [q] to stop, [?] for help
frame= 0 fps=0.0 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbits/s speed=N/A
sws_param option is deprecated and ignored
using SAR=1/1
using cpu capabilities: ARMv8 NEON
profile High 4:2:2, level 4.0, 4:2:2, 8-bit
264 - core 159 - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=9 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=24 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to '/var/mobile/Containers/Data/Application/AEEF7BB8-36F3-4ECD-824B-B294E9DF7294/Library/Caches/Memories_191007b0-f4cf-11ea-9024-c9fcef51db39.mp4':
Metadata:
TLEN : 134072
encoder : Lavf58.35.101
Stream #0:0(und): Video: h264 (libx264) (avc1 / 0x31637661), yuvj422p(pc, progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 24 fps, 12288 tbn, 24 tbc (default)
Metadata:
handler_name : VideoHandler
encoder : Lavc58.65.102 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
Stream #0:1: Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s
Metadata:
encoder : Lavc58.65.102 aac
frame= 47 fps=0.0 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
frame= 61 fps= 49 q=28.0 size= 256kB time=00:00:00.23 bitrate=9033.3kbits/s speed=0.187x
frame= 73 fps= 42 q=28.0 size= 512kB time=00:00:00.71 bitrate=5827.4kbits/s speed=0.411x
frame= 84 fps= 21 q=-1.0 Lsize= 3418kB time=00:00:03.50 bitrate=7986.4kbits/s speed=0.856x
video:3359kB audio:55kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.117042%
frame I:1 Avg QP:22.78 size:170700
frame P:22 Avg QP:23.95 size: 83595
frame B:61 Avg QP:28.22 size: 23428
consecutive B-frames: 2.4% 2.4% 0.0% 95.2%
mb I I16..4: 1.8% 97.3% 0.9%
mb P I16..4: 0.4% 13.4% 1.0% P16..4: 39.0% 21.7% 14.2% 0.0% 0.0% skip:10.3%
mb B I16..4: 0.1% 2.4% 0.2% B16..8: 27.0% 6.3% 2.1% direct: 2.4% skip:59.5% L0:39.3% L1:47.8% BI:12.9%
8x8 transform intra:91.6% inter:83.1%
coded y,uvDC,uvAC intra: 88.4% 97.3% 40.9% inter: 21.1% 26.6% 1.7%
i16 v,h,dc,p: 18% 27% 7% 48%
i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 18% 18% 16% 5% 8% 8% 9% 7% 9%
i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 18% 16% 13% 7% 11% 10% 10% 7% 8%
i8c dc,h,v,p: 41% 19% 28% 12%
Weighted P-Frames: Y:0.0% UV:0.0%
ref P L0: 53.9% 22.4% 18.3% 5.4%
ref B L0: 86.7% 9.9% 3.4%
ref B L1: 96.1% 3.9%
kb/s:7860.37
Qavg: 149.884
flutter: ffmpeg version git-2020-01-25-fd11dd500
flutter: Copyright (c) 2000-2020 the FFmpeg developers
flutter:
flutter: built with Apple clang version 11.0.0 (clang-1100.0.33.17)
flutter: configuration: --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.2.sdk --prefix=/Users/taner/Projects/mobile-ffmpeg/prebuilt/ios-arm64-apple-darwin/ffmpeg --enable-version3 --arch=aarch64 --cpu=armv8 --target-os=darwin --ar=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar --cc=clang --cxx=clang++ --as='/Users/taner/Projects/mobile-ffmpeg/.tmp/gas-preprocessor.pl -arch aarch64 -- clang -arch arm64 -target aarch64-ios-darwin -march=armv8-a+crc+crypto -mcpu=generic -DMOBILE_FFMPEG_ARM64 -Wno-unused-function -Wno-deprecated-declarations -fstrict-aliasing -fembed-bitcode -DIOS -DMOBILE_FFMPEG_BUILD_DATE=20200125 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.2.sdk -Oz -miphoneos-version-min=12.1 -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.2.sdk/usr/include' --ranlib=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib --strip=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip --enable-neon --enable-cross-compile --enable-pic --enable-asm --enable-inline-asm --enable-optimizations --enable-swscale --enable-static --disable-shared --enable-small --disable-v4l2-m2m --disable-outdev=v4l2 --disable-outdev=fbdev --disable-indev=v4l2 --disable-indev=fbdev --disable-openssl --disable-xmm-clobber-test --disable-debug --disable-neon-clobber-test --disable-programs --disable-postproc --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-sndio --disable-schannel --disable-securetransport --disable-xlib --disable-cuda --disable-cuvid --disable-nvenc --disable-vaapi --disable-vdpau --disable-appkit --disable-alsa --disable-cuda --disable-cuvid --disable-nvenc --disable-vaapi --disable-vdpau --enable-gmp --enable-gnutls --enable-libx264 --enable-gpl --enable-libxvid --enable-gpl --enable-libx265 --enable-gpl --enable-libvidstab --enable-gpl --disable-sdl2 --enable-zlib --enable-audiotoolbox --enable-coreimage --enable-bzlib --enable-videotoolbox --enable-avfoundation --enable-iconv
flutter: libavutil 56. 38.100 / 56. 38.100
flutter: libavcodec 58. 65.102 / 58. 65.102
flutter: libavformat 58. 35.101 / 58. 35.101
flutter: libavdevice 58. 9.103 / 58. 9.103
flutter: libavfilter 7. 70.101 / 7. 70.101
flutter: libswscale 5. 6.100 / 5. 6.100
flutter: libswresample 3. 6.100 / 3. 6.100
flutter: Input #0, image2, from '/var/mobile/Containers/Data/Application/AEEF7BB8-36F3-4ECD-824B-B294E9DF7294/Library/Caches/img%04d.jpg':
flutter: Duration:
flutter: 00:00:03.40
flutter: , start:
flutter: 0.000000
flutter: , bitrate:
flutter: N/A
flutter:
flutter: Stream #0:0
flutter: : Video: mjpeg, yuvj422p(pc, bt470bg/unknown/unknown), 1920x1080 [SAR 1:1 DAR 16:9]
flutter: ,
flutter: 25 fps,
flutter: 25 tbr,
flutter: 25 tbn,
flutter: 25 tbc
flutter:
flutter: Stream mapping:
flutter: Stream #0:0 -> #0:0
flutter: (mjpeg (native) -> h264 (libx264))
flutter:
flutter: Press [q] to stop, [?] for help
flutter: sws_param option is deprecated and ignored
flutter: using SAR=1/1
flutter: using cpu capabilities: ARMv8 NEON
flutter: profile High 4:2:2, level 4.0, 4:2:2, 8-bit
flutter: 264 - core 159 - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=9 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=24 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
flutter: Output #0, mp4, to '/var/mobile/Containers/Data/Application/AEEF7BB8-36F3-4ECD-824B-B294E9DF7294/Library/Caches/Memories_f578a1c0-f4d0-11ea-9e60-5b43394b2511.mp4':
flutter: Metadata:
flutter: encoder :
flutter: Lavf58.35.101
flutter:
flutter: Stream #0:0
flutter: : Video: h264 (libx264) (avc1 / 0x31637661), yuvj422p(pc), 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1
flutter: ,
flutter: 24 fps,
flutter: 12288 tbn,
flutter: 24 tbc
flutter:
flutter: Metadata:
flutter: encoder :
flutter: Lavc58.65.102 libx264
flutter:
flutter: Side data:
flutter:
flutter: cpb:
flutter: bitrate max/min/avg: 0/0/0 buffer size: 0
flutter: vbv_delay: N/A
flutter:
flutter: frame= 1 fps=0.0 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A speed=N/A
flutter: frame= 47 fps=0.0 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
flutter: frame= 60 fps= 53 q=28.0 size= 256kB time=00:00:00.16 bitrate=12579.1kbits/s speed=0.147x
flutter: frame= 72 fps= 43 q=28.0 size= 768kB time=00:00:00.66 bitrate=9436.6kbits/s speed=0.401x
flutter: frame= 84 fps= 38 q=28.0 size= 1280kB time=00:00:01.16 bitrate=8987.5kbits/s speed=0.527x
flutter: frame= 85 fps= 19 q=-1.0 Lsize= 4334kB time=00:00:03.41 bitrate=10391.1kbits/s speed=0.773x
flutter: video:4332kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead:
flutter: 0.043800%
flutter:
flutter: frame I:1 Avg QP:22.19 size:178746
flutter: frame P:21 Avg QP:23.69 size:106999
flutter: frame B:63 Avg QP:28.13 size: 31899
flutter: consecutive B-frames: 1.2% 0.0% 0.0% 98.8%
flutter: mb I I16..4: 2.4% 97.0% 0.6%
flutter: mb P I16..4: 0.7% 38.2% 0.8% P16..4: 22.6% 19.2% 15.1% 0.0% 0.0% skip: 3.3%
flutter: mb B I16..4: 0.2% 6.7% 0.2% B16..8: 24.6% 8.6% 3.0% direct: 4.2% skip:52.5% L0:47.8% L1:36.8% BI:15.4%
flutter: 8x8 transform intra:95.8% inter:86.8%
flutter: coded y,uvDC,uvAC intra: 89.3% 95.1% 22.5% inter: 26.3% 28.9% 3.0%
flutter: i16 v,h,dc,p: 20% 33% 22% 24%
flutter: i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 19% 24% 33% 3% 4% 3% 4% 4% 5%
flutter: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 20% 20% 16% 6% 10% 7% 9% 6% 7%
flutter: i8c dc,h,v,p: 44% 22% 29% 5%
flutter: Weighted P-Frames: Y:0.0% UV:0.0%
flutter: ref P L0: 43.8% 18.2% 23.0% 15.0%
flutter: ref B L0: 69.6% 22.3% 8.1%
flutter: ref B L1: 86.1% 13.9%
flutter: kb/s:10018.70
flutter: Video erfolgreich erstellt
flutter: Ja. Video existiert im Pfad!
flutter: ffmpeg version git-2020-01-25-fd11dd500
flutter: Copyright (c) 2000-2020 the FFmpeg developers
flutter:
flutter: built with Apple clang version 11.0.0 (clang-1100.0.33.17)
flutter: configuration: --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.2.sdk --prefix=/Users/taner/Projects/mobile-ffmpeg/prebuilt/ios-arm64-apple-darwin/ffmpeg --enable-version3 --arch=aarch64 --cpu=armv8 --target-os=darwin --ar=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar --cc=clang --cxx=clang++ --as='/Users/taner/Projects/mobile-ffmpeg/.tmp/gas-preprocessor.pl -arch aarch64 -- clang -arch arm64 -target aarch64-ios-darwin -march=armv8-a+crc+crypto -mcpu=generic -DMOBILE_FFMPEG_ARM64 -Wno-unused-function -Wno-deprecated-declarations -fstrict-aliasing -fembed-bitcode -DIOS -DMOBILE_FFMPEG_BUILD_DATE=20200125 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.2.sdk -Oz -miphoneos-version-min=12.1 -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.2.sdk/usr/include' --ranlib=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib --strip=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip --enable-neon --enable-cross-compile --enable-pic --enable-asm --enable-inline-asm --enable-optimizations --enable-swscale --enable-static --disable-shared --enable-small --disable-v4l2-m2m --disable-outdev=v4l2 --disable-outdev=fbdev --disable-indev=v4l2 --disable-indev=fbdev --disable-openssl --disable-xmm-clobber-test --disable-debug --disable-neon-clobber-test --disable-programs --disable-postproc --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-sndio --disable-schannel --disable-securetransport --disable-xlib --disable-cuda --disable-cuvid --disable-nvenc --disable-vaapi --disable-vdpau --disable-appkit --disable-alsa --disable-cuda --disable-cuvid --disable-nvenc --disable-vaapi --disable-vdpau --enable-gmp --enable-gnutls --enable-libx264 --enable-gpl --enable-libxvid --enable-gpl --enable-libx265 --enable-gpl --enable-libvidstab --enable-gpl --disable-sdl2 --enable-zlib --enable-audiotoolbox --enable-coreimage --enable-bzlib --enable-videotoolbox --enable-avfoundation --enable-iconv
flutter: libavutil 56. 38.100 / 56. 38.100
flutter: libavcodec 58. 65.102 / 58. 65.102
flutter: libavformat 58. 35.101 / 58. 35.101
flutter: libavdevice 58. 9.103 / 58. 9.103
flutter: libavfilter 7. 70.101 / 7. 70.101
flutter: libswscale 5. 6.100 / 5. 6.100
flutter: libswresample 3. 6.100 / 3. 6.100
flutter: Input #0, mp3, from '/var/mobile/Containers/Data/Application/AEEF7BB8-36F3-4ECD-824B-B294E9DF7294/Library/Caches/melodic_slow.mp3':
flutter: Metadata:
flutter: encoder :
flutter: LAME 32bits version 3.99.5 (http://lame.sf.net)
flutter:
flutter: TLEN :
flutter: 134072
flutter:
flutter: Duration:
flutter: 00:02:14.11
flutter: , start:
flutter: 0.025057
flutter: , bitrate:
flutter: 320 kb/s
flutter:
flutter: Stream #0:0
flutter: : Audio: mp3, 44100 Hz, stereo, fltp, 320 kb/s
flutter:
flutter: Metadata:
flutter: encoder :
flutter: LAME3.99r
flutter:
flutter: Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '/var/mobile/Containers/Data/Application/AEEF7BB8-36F3-4ECD-824B-B294E9DF7294/Library/Caches/Memories_f578a1c0-f4d0-11ea-9e60-5b43394b2511.mp4':
flutter: Metadata:
flutter: major_brand :
flutter: isom
flutter:
flutter: minor_version :
flutter: 512
flutter:
flutter: compatible_brands:
flutter: isomiso2avc1mp41
flutter:
flutter: encoder :
flutter: Lavf58.35.101
flutter:
flutter: Duration:
flutter: 00:00:03.54
flutter: , start:
flutter: 0.000000
flutter: , bitrate:
flutter: 10023 kb/s
flutter:
flutter: Stream #1:0
flutter: (und)
flutter: : Video: h264 (avc1 / 0x31637661), yuvj422p(pc), 1920x1080 [SAR 1:1 DAR 16:9], 10020 kb/s
flutter: ,
flutter: 24 fps,
flutter: 24 tbr,
flutter: 12288 tbn,
flutter: 48 tbc
flutter: (default)
flutter:
flutter: Metadata:
flutter: handler_name :
flutter: VideoHandler
flutter:
flutter: Stream mapping:
flutter: Stream #1:0 -> #0:0
flutter: (h264 (native) -> h264 (libx264))
flutter:
flutter: Stream #0:0 -> #0:1
flutter: (mp3 (mp3float) -> aac (native))
flutter:
flutter: Press [q] to stop, [?] for help
flutter: frame= 0 fps=0.0 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbits/s speed=N/A
flutter: sws_param option is deprecated and ignored
flutter: using SAR=1/1
flutter: using cpu capabilities: ARMv8 NEON
flutter: profile High 4:2:2, level 4.0, 4:2:2, 8-bit
flutter: 264 - core 159 - H.264/MPEG-4 AVC codec - Copyleft 2003-2019 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=9 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=24 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
flutter: Output #0, mp4, to '/var/mobile/Containers/Data/Application/AEEF7BB8-36F3-4ECD-824B-B294E9DF7294/Library/Caches/Memories_f81f09a0-f4d0-11ea-983d-0b683ab874e3.mp4':
flutter: Metadata:
flutter: TLEN :
flutter: 134072
flutter:
flutter: encoder :
flutter: Lavf58.35.101
flutter:
flutter: Stream #0:0
flutter: (und)
flutter: : Video: h264 (libx264) (avc1 / 0x31637661), yuvj422p(pc, progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1
flutter: ,
flutter: 24 fps,
flutter: 12288 tbn,
flutter: 24 tbc
flutter: (default)
flutter:
flutter: Metadata:
flutter: handler_name :
flutter: VideoHandler
flutter:
flutter: encoder :
flutter: Lavc58.65.102 libx264
flutter:
flutter: Side data:
flutter:
flutter: cpb:
flutter: bitrate max/min/avg: 0/0/0 buffer size: 0
flutter: vbv_delay: N/A
flutter:
flutter: Stream #0:1
flutter: : Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s
flutter:
flutter: Metadata:
flutter: encoder :
flutter: Lavc58.65.102 aac
flutter:
flutter: frame= 47 fps=0.0 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
flutter: frame= 61 fps= 57 q=28.0 size= 256kB time=00:00:00.23 bitrate=9033.3kbits/s speed=0.218x
flutter: frame= 74 fps= 46 q=28.0 size= 768kB time=00:00:00.78 bitrate=7969.6kbits/s speed=0.489x
flutter: frame= 85 fps= 22 q=-1.0 Lsize= 3440kB time=00:00:03.55 bitrate=7933.2kbits/s speed=0.902x
flutter: video:3380kB audio:56kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead:
flutter: 0.117084%
flutter:
flutter: frame I:1 Avg QP:22.68 size:174045
flutter: frame P:22 Avg QP:23.88 size: 84065
flutter: frame B:62 Avg QP:28.21 size: 23184
flutter: consecutive B-frames: 1.2% 4.7% 0.0% 94.1%
flutter: mb I I16..4: 2.0% 97.3% 0.7%
flutter: mb P I16..4: 0.4% 13.4% 0.9% P16..4: 39.3% 21.6% 14.6% 0.0% 0.0% skip: 9.7%
flutter: mb B I16..4: 0.1% 2.4% 0.2% B16..8: 26.7% 6.3% 2.0% direct: 2.5% skip:59.8% L0:41.1% L1:45.7% BI:13.1%
flutter: 8x8 transform intra:91.8% inter:83.1%
flutter: coded y,uvDC,uvAC intra: 88.3% 97.2% 41.4% inter: 21.0% 26.5% 1.7%
flutter: i16 v,h,dc,p: 18% 25% 5% 52%
flutter: i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 18% 19% 16% 5% 8% 8% 9% 7% 9%
flutter: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 18% 16% 13% 7% 12% 9% 10% 7% 8%
flutter: i8c dc,h,v,p: 41% 19% 28% 12%
flutter: Weighted P-Frames: Y:0.0% UV:0.0%
flutter: ref P L0: 53.4% 22.2% 18.9% 5.5%
flutter: ref B L0: 86.6% 10.3% 3.2%
flutter: ref B L1: 95.8% 4.2%
flutter: kb/s:7817.54
flutter: Qavg: 149.529
flutter: Speichern mit GallerySaver: /var/mobile/Containers/Data/Application/AEEF7BB8-36F3-4ECD-824B-B294E9DF7294/Library/Caches/Memories_f81f09a0-f4d0-11ea-983d-0b683ab874e3.mp4
flutter: Speichern mit GallerySaver nicht erfolgreich
In general the created video works, but: If i try to save it as video with flutter gallery_saver to the device, this video will not saved. Other videos for example works well. But not the created with ffmpeg.
Can you find any reason for this in the ffmpeg output log? Thank you!

Videos for web playback usually require chroma sampling to be 4:2:0. FFmpeg, by default, will try to preserve the source sampling scheme, so your output is 4:2:2 (see yuvj422p in the output stream).
Use for step 1,
-r $settings_fps -i $tempPath/img%04d.jpg -vcodec libx264 -y -an -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" -pix_fmt yuv420p $tempPath/$videoFileName.mp4
And in step 2, avoid re-encoding video
-i ${finalSong.path} -i $videoPath -c:v copy -c:a aac -shortest $tempPath/$newVideoFileName.mp4

Related

how to get output video of flutter ffmpeg | operation not permitted

I am using flutter ffmpeg and try to save output video in local storage but getting error, plese help me I tried too many solutions but none of them worked. Thanking you :)
getting output path by path_provider package
code: String outputPath = (appDocDir.absolute.path + '/o.mp4').toString();
Performing hot restart...
Syncing files to device Pixel 5...
Restarted application in 1,451ms.
D/FilePickerDelegate( 8662): Selected type video/*
I/FilePickerUtils( 8662): Caching from URI: content://com.android.providers.media.documents/document/video%3A5332
I/OpenGLRenderer( 8662): Davey! duration=226847ms; Flags=1, FrameTimelineVsyncId=4722756, IntendedVsync=131408633604624, Vsync=131408633604624, InputEventId=0, HandleInputStart=131408633999713, AnimationStart=131408634002004, PerformTraversalsStart=131408634002733, DrawStart=131408634666067, FrameDeadline=131408716937954, FrameInterval=131408633989400, FrameStartTime=16666666, SyncQueued=131408636245702, SyncStart=131408636326588, IssueDrawCommandsStart=131408641269661, SwapBuffers=131408676689452, FrameCompleted=131635481327282, DequeueBufferDuration=3359323, QueueBufferDuration=676771, GpuCompleted=131635481327282, SwapBuffersCompleted=131408678665598, DisplayPresentTime=0,
I/OpenGLRenderer( 8662): Davey! duration=226847ms; Flags=1, FrameTimelineVsyncId=4722756, IntendedVsync=131408633604624, Vsync=131408633604624, InputEventId=0, HandleInputStart=131408633999713, AnimationStart=131408634002004, PerformTraversalsStart=131408634002733, DrawStart=131408634666067, FrameDeadline=131408733604620, FrameInterval=131408633989400, FrameStartTime=16666666, SyncQueued=131408636245702, SyncStart=131408636326588, IssueDrawCommandsStart=131408641269661, SwapBuffers=131408676689452, FrameCompleted=131635481327282, DequeueBufferDuration=3359323, QueueBufferDuration=676771, GpuCompleted=131635481327282, SwapBuffersCompleted=131408678665598, DisplayPresentTime=0,
D/FilePickerUtils( 8662): File loaded and cached at:/data/user/0/com.example.ffmpeg_sample/cache/file_picker/VID-20211221-WA0004.mp4
D/FilePickerDelegate( 8662): File path:[com.mr.flutter.plugin.filepicker.FileInfo#af3dcb6]
I/flutter ( 8662): new video path is: /data/user/0/com.example.ffmpeg_sample/cache/file_picker/VID-20211221-WA0004.mp4
D/flutter-ffmpeg( 8662): Running FFmpeg with arguments: [-i, /data/user/0/com.example.ffmpeg_sample/cache/file_picker/VID-20211221-WA0004.mp4, -vf, curves=vintage, -y, /data/user/0/com.example.ffmpeg_sample/app_flutter/o.mp4].
I/mobile-ffmpeg( 8662): ffmpeg version v4.4-dev-416
I/mobile-ffmpeg( 8662): Copyright (c) 2000-2020 the FFmpeg developers
I/mobile-ffmpeg( 8662):
I/mobile-ffmpeg( 8662): built with Android (6454773 based on r365631c2) clang version 9.0.8 (https://android.googlesource.com/toolchain/llvm-project 98c855489587874b2a325e7a516b99d838599c6f) (based on LLVM 9.0.8svn)
I/mobile-ffmpeg( 8662): configuration: --cross-prefix=aarch64-linux-android- --sysroot=/files/android-sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/sysroot --prefix=/home/taner/Projects/mobile-ffmpeg/prebuilt/android-arm64/ffmpeg --pkg-config=/usr/bin/pkg-config --enable-version3 --arch=aarch64 --cpu=armv8-a --cc=aarch64-linux-android21-clang --cxx=aarch64-linux-android21-clang++ --extra-libs='-L/storage/light/projects/mobile-ffmpeg/prebuilt/android-arm64/cpu-features/lib -lndk_compat' --target-os=android --enable-neon --enable-asm --enable-inline-asm --enable-cross-compile --enable-pic --enable-jni --enable-optimizations --enable-swscale --enable-shared --enable-v4l2-m2m --disable-outdev=fbdev --disable-indev=fbdev --enable-small --disable-openssl --disable-xmm-clobber-test --disable-debug --enable-lto --disable-neon-clobber-test --disable-programs --disable-postproc --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --disable-sndio --disable-schannel --disable-securetransport --disable-xlib --disable-cuda --disable-cuvid --disable-nvenc --disable-vaapi --disable-vdpau --disable-videotoolbox --disable-audiotoolbox --disable-appkit --disable-alsa --disable-cuda --disable-cuvid --disable-nvenc --disable-vaapi --disable-vdpau --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-gmp --enable-gnutls --enable-libmp3lame --enable-libass --enable-iconv --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libxml2 --enable-libopencore-amrnb --enable-libshine --enable-libspeex --enable-libwavpack --enable-libkvazaar --enable-libilbc --enable-libopus --enable-libsnappy --enable-libsoxr --enable-libaom --enable-libtwolame --disable-sdl2 --enable-libvo-amrwbenc --enable-zlib --enable-mediacodec
I/mobile-ffmpeg( 8662): libavutil 56. 55.100 / 56. 55.100
I/mobile-ffmpeg( 8662): libavcodec 58. 96.100 / 58. 96.100
I/mobile-ffmpeg( 8662): libavformat 58. 48.100 / 58. 48.100
I/mobile-ffmpeg( 8662): libavdevice 58. 11.101 / 58. 11.101
I/mobile-ffmpeg( 8662): libavfilter 7. 87.100 / 7. 87.100
I/mobile-ffmpeg( 8662): libswscale 5. 8.100 / 5. 8.100
I/mobile-ffmpeg( 8662): libswresample 3. 8.100 / 3. 8.100
I/mobile-ffmpeg( 8662): Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/data/user/0/com.example.ffmpeg_sample/cache/file_picker/VID-20211221-WA0004.mp4':
I/mobile-ffmpeg( 8662): Metadata:
I/mobile-ffmpeg( 8662): major_brand :
I/mobile-ffmpeg( 8662): isom
I/mobile-ffmpeg( 8662):
I/mobile-ffmpeg( 8662): minor_version :
I/mobile-ffmpeg( 8662): 512
I/mobile-ffmpeg( 8662):
I/mobile-ffmpeg( 8662): compatible_brands:
I/mobile-ffmpeg( 8662): isomiso2avc1mp41
I/mobile-ffmpeg( 8662):
I/mobile-ffmpeg( 8662): encoder :
I/mobile-ffmpeg( 8662): Lavf58.20.100
I/mobile-ffmpeg( 8662):
I/mobile-ffmpeg( 8662): Duration:
I/mobile-ffmpeg( 8662): 00:00:02.10
I/mobile-ffmpeg( 8662): , start:
I/mobile-ffmpeg( 8662): 0.000000
I/mobile-ffmpeg( 8662): , bitrate:
I/mobile-ffmpeg( 8662): 551 kb/s
I/mobile-ffmpeg( 8662):
I/mobile-ffmpeg( 8662): Stream #0:0
I/mobile-ffmpeg( 8662): (und)
I/mobile-ffmpeg( 8662): : Video: h264 (avc1 / 0x31637661), yuv420p, 208x208, 547 kb/s
I/mobile-ffmpeg( 8662): ,
I/mobile-ffmpeg( 8662): 20 fps,
I/mobile-ffmpeg( 8662): 20 tbr,
I/mobile-ffmpeg( 8662): 10240 tbn,
I/mobile-ffmpeg( 8662): 40 tbc
I/mobile-ffmpeg( 8662): (default)
I/mobile-ffmpeg( 8662):
I/mobile-ffmpeg( 8662): Metadata:
I/mobile-ffmpeg( 8662): handler_name :
I/mobile-ffmpeg( 8662): VideoHandler
I/mobile-ffmpeg( 8662):
I/mobile-ffmpeg( 8662): Stream mapping:
I/mobile-ffmpeg( 8662): Stream #0:0 -> #0:0
I/mobile-ffmpeg( 8662): (h264 (native) -> mpeg4 (native))
I/mobile-ffmpeg( 8662):
I/mobile-ffmpeg( 8662): Press [q] to stop, [?] for help
I/mobile-ffmpeg( 8662): frame= 0 fps=0.0 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbits/s speed=N/A
W/mobile-ffmpeg( 8662): [graph 0 input from stream 0:0 # 0x7a282228d0] sws_param option is deprecated and ignored
W/mobile-ffmpeg( 8662): [swscaler # 0x7b989ee7f0] No accelerated colorspace conversion found from yuv420p to rgb24.
I/mobile-ffmpeg( 8662): Output #0, mp4, to '/data/user/0/com.example.ffmpeg_sample/app_flutter/o.mp4':
I/mobile-ffmpeg( 8662): Metadata:
I/mobile-ffmpeg( 8662): major_brand :
I/mobile-ffmpeg( 8662): isom
I/mobile-ffmpeg( 8662):
I/mobile-ffmpeg( 8662): minor_version :
I/mobile-ffmpeg( 8662): 512
I/mobile-ffmpeg( 8662):
I/mobile-ffmpeg( 8662): compatible_brands:
I/mobile-ffmpeg( 8662): isomiso2avc1mp41
I/mobile-ffmpeg( 8662):
I/mobile-ffmpeg( 8662): encoder :
I/mobile-ffmpeg( 8662): Lavf58.48.100
I/mobile-ffmpeg( 8662):
I/mobile-ffmpeg( 8662): Stream #0:0
I/mobile-ffmpeg( 8662): (und)
I/mobile-ffmpeg( 8662): : Video: mpeg4 (mp4v / 0x7634706D), yuv420p, 208x208, q=2-31, 200 kb/s
I/mobile-ffmpeg( 8662): ,
I/mobile-ffmpeg( 8662): 20 fps,
I/mobile-ffmpeg( 8662): 10240 tbn,
I/mobile-ffmpeg( 8662): 20 tbc
I/mobile-ffmpeg( 8662): (default)
I/mobile-ffmpeg( 8662):
I/mobile-ffmpeg( 8662): Metadata:
I/mobile-ffmpeg( 8662): handler_name :
I/mobile-ffmpeg( 8662): VideoHandler
I/mobile-ffmpeg( 8662):
I/mobile-ffmpeg( 8662): encoder :
I/mobile-ffmpeg( 8662): Lavc58.96.100 mpeg4
I/mobile-ffmpeg( 8662):
I/mobile-ffmpeg( 8662): Side data:
I/mobile-ffmpeg( 8662):
I/mobile-ffmpeg( 8662): cpb:
I/mobile-ffmpeg( 8662): bitrate max/min/avg: 0/0/200000 buffer size: 0
I/mobile-ffmpeg( 8662): vbv_delay: N/A
I/mobile-ffmpeg( 8662):
I/mobile-ffmpeg( 8662): frame= 42 fps=0.0 q=6.7 Lsize= 99kB time=00:00:02.05 bitrate= 394.4kbits/s speed=4.22x
I/mobile-ffmpeg( 8662): video:98kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead:
I/mobile-ffmpeg( 8662): 1.040646%
I/mobile-ffmpeg( 8662):
D/flutter-ffmpeg( 8662): FFmpeg exited with rc: 0
I/flutter ( 8662): FFmpeg process exited with re: 0
I/flutter ( 8662): /data/user/0/com.example.ffmpeg_sample/app_flutter/o.mp4
changed the output path:
String outputPath = '/storage/emulated/0/video/o.mp4';
Launching lib\main.dart on Pixel 5 in debug mode...
Running Gradle task 'assembleDebug'...
√ Built build\app\outputs\flutter-apk\app-debug.apk.
Installing build\app\outputs\flutter-apk\app.apk...
Debug service listening on ws://127.0.0.1:54633/Ykc3Xz8Aoi8=/ws
Syncing files to device Pixel 5...
I/Gralloc4( 1550): mapper 4.x is not supported
W/Gralloc3( 1550): mapper 3.x is not supported
W/Gralloc4( 1550): allocator 4.x is not supported
W/Gralloc3( 1550): allocator 3.x is not supported
D/permissions_handler( 1550): No permissions found in manifest for: []22
D/permissions_handler( 1550): No permissions found in manifest for: []22
D/FilePickerDelegate( 1550): Selected type video/*
E/cutils-trace( 1550): Error opening trace file: No such file or directory (2)
D/CompatibilityChangeReporter( 1550): Compat change id reported: 78294732; UID 10229; state: DISABLED
I/FilePickerUtils( 1550): Caching from URI: content://com.android.providers.media.documents/document/video%3A5347
D/FilePickerUtils( 1550): File loaded and cached at:/data/user/0/com.example.ffmpeg_sample/cache/file_picker/VID-20211221-WA0010.mp4
D/FilePickerDelegate( 1550): File path:[com.mr.flutter.plugin.filepicker.FileInfo#bb9e260]
I/OpenGLRenderer( 1550): Davey! duration=36685ms; Flags=1, FrameTimelineVsyncId=4687973, IntendedVsync=130538053233976, Vsync=130538053233976, InputEventId=0, HandleInputStart=130538053733013, AnimationStart=130538053735357, PerformTraversalsStart=130538053736138, DrawStart=130538054754472, FrameDeadline=130538103233974, FrameInterval=130538053722076, FrameStartTime=16666666, SyncQueued=130538057200305, SyncStart=130538057291295, IssueDrawCommandsStart=130538059598899, SwapBuffers=130538096356295, FrameCompleted=130574739168052, DequeueBufferDuration=5764114, QueueBufferDuration=721302, GpuCompleted=130574739168052, SwapBuffersCompleted=130538098217336, DisplayPresentTime=4294967295,
I/OpenGLRenderer( 1550): Davey! duration=36685ms; Flags=1, FrameTimelineVsyncId=4687973, IntendedVsync=130538053233976, Vsync=130538053233976, InputEventId=0, HandleInputStart=130538053733013, AnimationStart=130538053735357, PerformTraversalsStart=130538053736138, DrawStart=130538054754472, FrameDeadline=130538119900640, FrameInterval=130538053722076, FrameStartTime=16666666, SyncQueued=130538057200305, SyncStart=130538057291295, IssueDrawCommandsStart=130538059598899, SwapBuffers=130538096356295, FrameCompleted=130574739168052, DequeueBufferDuration=5764114, QueueBufferDuration=721302, GpuCompleted=130574739168052, SwapBuffersCompleted=130538098217336, DisplayPresentTime=4294967295,
I/flutter ( 1550): new video path is: /data/user/0/com.example.ffmpeg_sample/cache/file_picker/VID-20211221-WA0010.mp4
D/flutter-ffmpeg( 1550): Running FFmpeg with arguments: [-i, /data/user/0/com.example.ffmpeg_sample/cache/file_picker/VID-20211221-WA0010.mp4, -vf, curves=vintage, -y, /storage/emulated/0/video/o.mp4].
I/mobile-ffmpeg( 1550): Loading mobile-ffmpeg.
I/mobile-ffmpeg( 1550): Loaded mobile-ffmpeg-full-arm64-v8a-4.4-lts-20210207.
D/mobile-ffmpeg( 1550): Callback thread started.
I/mobile-ffmpeg( 1550): ffmpeg version v4.4-dev-416
I/mobile-ffmpeg( 1550): Copyright (c) 2000-2020 the FFmpeg developers
I/mobile-ffmpeg( 1550):
I/mobile-ffmpeg( 1550): built with Android (6454773 based on r365631c2) clang version 9.0.8 (https://android.googlesource.com/toolchain/llvm-project 98c855489587874b2a325e7a516b99d838599c6f) (based on LLVM 9.0.8svn)
I/mobile-ffmpeg( 1550): configuration: --cross-prefix=aarch64-linux-android- --sysroot=/files/android-sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/sysroot --prefix=/home/taner/Projects/mobile-ffmpeg/prebuilt/android-arm64/ffmpeg --pkg-config=/usr/bin/pkg-config --enable-version3 --arch=aarch64 --cpu=armv8-a --cc=aarch64-linux-android21-clang --cxx=aarch64-linux-android21-clang++ --extra-libs='-L/storage/light/projects/mobile-ffmpeg/prebuilt/android-arm64/cpu-features/lib -lndk_compat' --target-os=android --enable-neon --enable-asm --enable-inline-asm --enable-cross-compile --enable-pic --enable-jni --enable-optimizations --enable-swscale --enable-shared --enable-v4l2-m2m --disable-outdev=fbdev --disable-indev=fbdev --enable-small --disable-openssl --disable-xmm-clobber-test --disable-debug --enable-lto --disable-neon-clobber-test --disable-programs --disable-postproc --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --disable-sndio --disable-schannel --disable-securetransport --disable-xlib --disable-cuda --disable-cuvid --disable-nvenc --disable-vaapi --disable-vdpau --disable-videotoolbox --disable-audiotoolbox --disable-appkit --disable-alsa --disable-cuda --disable-cuvid --disable-nvenc --disable-vaapi --disable-vdpau --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-gmp --enable-gnutls --enable-libmp3lame --enable-libass --enable-iconv --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libxml2 --enable-libopencore-amrnb --enable-libshine --enable-libspeex --enable-libwavpack --enable-libkvazaar --enable-libilbc --enable-libopus --enable-libsnappy --enable-libsoxr --enable-libaom --enable-libtwolame --disable-sdl2 --enable-libvo-amrwbenc --enable-zlib --enable-mediacodec
I/mobile-ffmpeg( 1550): libavutil 56. 55.100 / 56. 55.100
I/mobile-ffmpeg( 1550): libavcodec 58. 96.100 / 58. 96.100
I/mobile-ffmpeg( 1550): libavformat 58. 48.100 / 58. 48.100
I/mobile-ffmpeg( 1550): libavdevice 58. 11.101 / 58. 11.101
I/mobile-ffmpeg( 1550): libavfilter 7. 87.100 / 7. 87.100
I/mobile-ffmpeg( 1550): libswscale 5. 8.100 / 5. 8.100
I/mobile-ffmpeg( 1550): libswresample 3. 8.100 / 3. 8.100
I/mobile-ffmpeg( 1550): Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/data/user/0/com.example.ffmpeg_sample/cache/file_picker/VID-20211221-WA0010.mp4':
I/mobile-ffmpeg( 1550): Metadata:
I/mobile-ffmpeg( 1550): major_brand :
I/mobile-ffmpeg( 1550): mp4v
I/mobile-ffmpeg( 1550):
I/mobile-ffmpeg( 1550): minor_version :
I/mobile-ffmpeg( 1550): 0
I/mobile-ffmpeg( 1550):
I/mobile-ffmpeg( 1550): compatible_brands:
I/mobile-ffmpeg( 1550): mp4vmp42isom
I/mobile-ffmpeg( 1550):
I/mobile-ffmpeg( 1550): Duration:
I/mobile-ffmpeg( 1550): 00:00:01.00
I/mobile-ffmpeg( 1550): , start:
I/mobile-ffmpeg( 1550): 0.000000
I/mobile-ffmpeg( 1550): , bitrate:
I/mobile-ffmpeg( 1550): 1587 kb/s
I/mobile-ffmpeg( 1550):
I/mobile-ffmpeg( 1550): Stream #0:0
I/mobile-ffmpeg( 1550): (und)
I/mobile-ffmpeg( 1550): : Video: h264 (avc1 / 0x31637661), yuv420p, 480x480 [SAR 1:1 DAR 1:1], 1581 kb/s
I/mobile-ffmpeg( 1550): ,
I/mobile-ffmpeg( 1550): 10 fps,
I/mobile-ffmpeg( 1550): 10 tbr,
I/mobile-ffmpeg( 1550): 10240 tbn,
I/mobile-ffmpeg( 1550): 20 tbc
I/mobile-ffmpeg( 1550): (default)
I/mobile-ffmpeg( 1550):
E/mobile-ffmpeg( 1550): /storage/emulated/0/video/o.mp4: Operation not permitted
D/flutter-ffmpeg( 1550): FFmpeg exited with rc: 1
I/flutter ( 1550): FFmpeg process exited with re: 1
I/flutter ( 1550): /storage/emulated/0/video/o.mp4
I added these permissions in AndroidMainfest.xml
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
ffmpeg_pi.dart
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter_ffmpeg/flutter_ffmpeg.dart';
import 'package:path_provider/path_provider.dart';
edit(String videoPath) async {
FlutterFFmpeg fFmpeg = FlutterFFmpeg();
Directory appDocDir = await getApplicationDocumentsDirectory();
String outputPath = (appDocDir.absolute.path + '/o.mp4').toString();
String command = '-i $videoPath -vf curves=vintage -y $outputPath';
await fFmpeg.execute(command).then((rc) {
debugPrint("FFmpeg process exited with re: $rc");
});
debugPrint(outputPath);
}
select_file.dart
import 'dart:io';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';
import 'ffmpeg_pi.dart';
class SelectFile extends StatefulWidget {
const SelectFile({Key? key}) : super(key: key);
#override
_SelectFileState createState() => _SelectFileState();
}
class _SelectFileState extends State<SelectFile> {
File? video;
String? videoPath;
pickFile(BuildContext context) async {
FilePickerResult? result =
await FilePicker.platform.pickFiles(type: FileType.video);
if (result != null) {
setState(() {
video = File(result.files.single.path!);
videoPath = result.files.single.path!;
});
debugPrint("new video path is: " + videoPath!);
}
}
getPermission() async {
Permission.storage.request();
Permission.manageExternalStorage.request();
}
#override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
TextButton(
onPressed: () {
getPermission();
},
child: const Text("get Permission"),
),
const Text("select video"),
const SizedBox(
height: 50,
width: double.infinity,
),
ElevatedButton(
onPressed: () async {
await pickFile(context);
},
child: const Text("Select video"),
),
const SizedBox(height: 50),
Text(videoPath ?? "no file selected"),
const SizedBox(height: 100),
ElevatedButton(
onPressed: () {
edit(videoPath!);
},
child: const Text("edit"),
),
],
),
);
}
}
I got solution so I answered here, issue is not of flutter_ffmpeg, issue is caused because app had not permission to write in external storage to resolve this add "MANAGE_EXTERNAL_STORAGE" in mainfest.xml file and set output path is
File('storage/emulated/0/my_folder/o.mp4').path , and everything works fine.
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
String outputPath = File('storage/emulated/0/my_folder/o.mp4').path;

Can FFmpeg crop gif image under 1 second?

I am developing an iOS application about gif.
But I have a problem with gif cropping. Cropping gif spends so many times with FFmpeg.
(updated code)
These are the ffmpeg codes I've tried.
cropped images -> gif
ffmpeg -f image2 -i %d.jpg -vf 'scale=450:-1' output.gif
using concat command (cropped images -> gif)
ffmpeg -f concat -i tmp.txt output.gif
using crop filter
ffmpeg -i in.gif -filter:v "crop=out_w:out_h:x:y" out.gif
These codes are so slow when converting images to gif
or gif to cropped gif.
Is there a way to reduce the time to crop gif less than 1 second?
(updated2)
ffmpeg -i in.gif -filter:v "crop=out_w:out_h:x:y" out.gif
ffmpeg version 4.4 Copyright (c) 2000-2021 the FFmpeg developers
built with Apple clang version 12.0.5 (clang-1205.0.22.9)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.4_2 --enable-shared
--enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-avresample --enable-videotoolbox libavutil 56. 70.100 / 56. 70.100 libavcodec 58.134.100 /
58.134.100 libavformat 58. 76.100 / 58. 76.100 libavdevice 58. 13.100 / 58. 13.100 libavfilter 7.110.100 / 7.110.100 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 9.100 /
5. 9.100 libswresample 3. 9.100 / 3. 9.100 libpostproc 55. 9.100 / 55. 9.100 Input #0, gif, from './test.gif': Duration: 00:00:18.27, start: 0.000000, bitrate: 70098 kb/s Stream #0:0:
Video: gif, bgra, 1080x1920, 15 fps, 14.99 tbr, 100 tbn, 100 tbc
Stream mapping: Stream #0:0 -> #0:0 (gif (native) -> gif (native))
Press [q] to stop, [?] for help Output #0, gif, to './crop.gif':
Metadata:
encoder : Lavf58.76.100 Stream #0:0: Video: gif, bgr8(pc, progressive), 1080x1198, q=2-31, 200 kb/s, 14.99 fps, 100 tbn
Metadata:
encoder : Lavc58.134.100 gif frame= 1 fps=0.0 q=-0.0 size= 0kB time=00:00:00.01 bitrate= 0.0kbits/s speed=5e+03x
frame= 11 fps=0.0 q=-0.0 size= 4096kB time=00:00:00.68
bitrate=49344.8kbits/s speed=1.31x frame= 22 fps= 21 q=-0.0
size= 8192kB time=00:00:01.41 bitrate=47594.9kbits/s speed=1.32x
frame= 32 fps= 20 q=-0.0 size= 12288kB time=00:00:02.08
bitrate=48395.8kbits/s speed=1.32x frame= 43 fps= 20 q=-0.0
size= 16384kB time=00:00:02.81 bitrate=47764.3kbits/s speed=1.33x
frame= 54 fps= 20 q=-0.0 size= 20992kB time=00:00:03.55
bitrate=48441.3kbits/s speed=1.33x frame= 65 fps= 20 q=-0.0
size= 24832kB time=00:00:04.28 bitrate=47528.9kbits/s speed=1.35x
frame= 77 fps= 21 q=-0.0 size= 28928kB time=00:00:05.08
bitrate=46649.2kbits/s speed=1.36x frame= 87 fps= 21 q=-0.0
size= 32768kB time=00:00:05.75 bitrate=46684.4kbits/s speed=1.36x
frame= 98 fps= 21 q=-0.0 size= 36608kB time=00:00:06.48
bitrate=46279.7kbits/s speed=1.36x frame= 109 fps= 21 q=-0.0
size= 40704kB time=00:00:07.22 bitrate=46183.8kbits/s speed=1.37x
frame= 120 fps= 21 q=-0.0 size= 44800kB time=00:00:07.95
bitrate=46163.7kbits/s speed=1.37x frame= 131 fps= 21 q=-0.0
size= 49152kB time=00:00:08.69 bitrate=46335.2kbits/s speed=1.38x
frame= 142 fps= 21 q=-0.0 size= 53504kB time=00:00:09.42
bitrate=46529.2kbits/s speed=1.37x frame= 153 fps= 21 q=-0.0
size= 57344kB time=00:00:10.15 bitrate=46282.0kbits/s speed=1.38x
frame= 164 fps= 21 q=-0.0 size= 61184kB time=00:00:10.89
bitrate=46025.6kbits/s speed=1.38x frame= 174 fps= 21 q=-0.0
size= 65280kB time=00:00:11.55 bitrate=46300.8kbits/s speed=1.37x
frame= 185 fps= 21 q=-0.0 size= 69376kB time=00:00:12.29
bitrate=46243.1kbits/s speed=1.38x frame= 196 fps= 21 q=-0.0
size= 72960kB time=00:00:13.02 bitrate=45905.4kbits/s speed=1.38x
frame= 207 fps= 21 q=-0.0 size= 76544kB time=00:00:13.76
bitrate=45570.4kbits/s speed=1.38x frame= 218 fps= 21 q=-0.0
size= 80640kB time=00:00:14.49 bitrate=45590.3kbits/s speed=1.38x
frame= 229 fps= 21 q=-0.0 size= 84224kB time=00:00:15.23
bitrate=45302.9kbits/s speed=1.39x frame= 240 fps= 21 q=-0.0
size= 88064kB time=00:00:15.96 bitrate=45201.8kbits/s speed=1.39x
frame= 250 fps= 21 q=-0.0 size= 91648kB time=00:00:16.63
bitrate=45146.1kbits/s speed=1.39x frame= 261 fps= 21 q=-0.0
size= 96000kB time=00:00:17.36 bitrate=45301.4kbits/s speed=1.38x
frame= 271 fps= 21 q=-0.0 size= 99840kB time=00:00:18.03
bitrate=45362.7kbits/s speed=1.38x frame= 274 fps= 21 q=-0.0
Lsize= 101552kB time=00:00:18.23 bitrate=45634.2kbits/s speed=1.37x
video:101552kB audio:0kB subtitle:0kB other streams:0kB global
headers:0kB muxing overhead: 0.000019%
it takes 12 seconds

FFmpeg error while adding watermark: Not overwriting - exiting

I'm implementing a video editing feature on my Flutter App using the Flutter-FFmpeg package, [Adding watermarks on video] specifically, while executing the code I got this error:
E/mobile-ffmpeg( 5731): Not overwriting - exiting
D/flutter-ffmpeg( 5731): FFmpeg exited with rc: 1
Most importantly, the output file cannot be played by the VideoPlayer. And it just LOADS FOREVER, the VideoController Widget shows that the player is buffering. I've tested My VideoPlayer widget, and it works very well on the videos that were not processed.
Here's the code I'm using:
await FlutterFFmpeg().execute(
'-i video.mp4 -i logo.png -filter_complex [0:v][1:v]overlay=5:5 -c:a copy -movflags +faststart output.mp4'
);
A full log of the executing process in case it helps:
D/flutter-ffmpeg( 5731): Running FFmpeg with arguments: [-i, /data/user/0/com.raheyo.cheese/cache/REC5995709221575585296.mp4, -i, /data/user/0/com.raheyo.cheese/cache/e0baa6a8-4d4c-407a-a73e-be4dcf4d08fd.mp4, -filter_complex, [0:v][1:v]overlay=5:5, -c:a, copy, -movflags, +faststart, /data/user/0/com.raheyo.cheese/cache/e0baa6a8-4d4c-407a-a73e-be4dcf4d08fd.mp4].
I/mobile-ffmpeg( 5731): Loading mobile-ffmpeg.
I/mobile-ffmpeg( 5731): Loaded mobile-ffmpeg-full-arm64-v8a-4.4-20200725.
D/mobile-ffmpeg( 5731): Callback thread started.
I/mobile-ffmpeg( 5731): ffmpeg version v4.4-dev-416
I/mobile-ffmpeg( 5731): Copyright (c) 2000-2020 the FFmpeg developers
I/mobile-ffmpeg( 5731):
I/mobile-ffmpeg( 5731): built with Android (6454773 based on r365631c2) clang version 9.0.8 (https://android.googlesource.com/toolchain/llvm-project 98c855489587874b2a325e7a516b99d838599c6f) (based on LLVM 9.0.8svn)
I/mobile-ffmpeg( 5731): configuration: --cross-prefix=aarch64-linux-android- --sysroot=/files/android-sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/sysroot --prefix=/home/taner/Projects/mobile-ffmpeg/prebuilt/android-arm64/ffmpeg --pkg-config=/usr/bin/pkg-config --enable-version3 --arch=aarch64 --cpu=armv8-a --cc=aarch64-linux-android24-clang --cxx=aarch64-linux-android24-clang++ --extra-libs='-L/home/taner/Projects/mobile-ffmpeg/prebuilt/android-arm64/cpu-features/lib -lndk_compat' --target-os=android --enable-neon --enable-asm --enable-inline-asm --enable-cross-compile --enable-pic --enable-jni --enable-optimizations --enable-swscale --enable-shared --enable-v4l2-m2m --disable-outdev=fbdev --disable-indev=fbdev --enable-small --disable-openssl --disable-xmm-clobber-test --disable-debug --enable-lto --disable-neon-clobber-test --disable-programs --disable-postproc --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --disable-sndio --disable-schannel --disable-securetransport --disable-xlib --disable-cuda --disable-cuvid --disable-nvenc --disable-vaapi --disable-vdpau --disable-videotoolbox --disable-audiotoolbox --disable-appkit --disable-alsa --disable-cuda --disable-cuvid --disable-nvenc --disable-vaapi --disable-vdpau --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-gmp --enable-gnutls --enable-libmp3lame --enable-libass --enable-iconv --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libxml2 --enable-libopencore-amrnb --enable-libshine --enable-libspeex --enable-libwavpack --enable-libkvazaar --enable-libilbc --enable-libopus --enable-libsnappy --enable-libsoxr --enable-libaom --enable-libtwolame --disable-sdl2 --enable-libvo-amrwbenc --enable-zlib --enable-mediacodec
I/mobile-ffmpeg( 5731): libavutil 56. 55.100 / 56. 55.100
I/mobile-ffmpeg( 5731): libavcodec 58. 96.100 / 58. 96.100
I/mobile-ffmpeg( 5731): libavformat 58. 48.100 / 58. 48.100
I/mobile-ffmpeg( 5731): libavdevice 58. 11.101 / 58. 11.101
I/mobile-ffmpeg( 5731): libavfilter 7. 87.100 / 7. 87.100
I/mobile-ffmpeg( 5731): libswscale 5. 8.100 / 5. 8.100
I/mobile-ffmpeg( 5731): libswresample 3. 8.100 / 3. 8.100
I/mobile-ffmpeg( 5731): Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/data/user/0/com.raheyo.cheese/cache/REC5995709221575585296.mp4':
I/mobile-ffmpeg( 5731): Metadata:
I/mobile-ffmpeg( 5731): major_brand :
I/mobile-ffmpeg( 5731): mp42
I/mobile-ffmpeg( 5731):
I/mobile-ffmpeg( 5731): minor_version :
I/mobile-ffmpeg( 5731): 0
I/mobile-ffmpeg( 5731):
I/mobile-ffmpeg( 5731): compatible_brands:
I/mobile-ffmpeg( 5731): isommp42
I/mobile-ffmpeg( 5731):
I/mobile-ffmpeg( 5731): creation_time :
I/mobile-ffmpeg( 5731): 2021-08-06T19:50:53.000000Z
I/mobile-ffmpeg( 5731):
I/mobile-ffmpeg( 5731): com.android.version:
I/mobile-ffmpeg( 5731): 9
I/mobile-ffmpeg( 5731):
I/mobile-ffmpeg( 5731): Duration:
I/mobile-ffmpeg( 5731): 00:00:01.69
I/mobile-ffmpeg( 5731): , start:
I/mobile-ffmpeg( 5731): 0.000000
I/mobile-ffmpeg( 5731): , bitrate:
I/mobile-ffmpeg( 5731): 12834 kb/s
I/mobile-ffmpeg( 5731):
I/mobile-ffmpeg( 5731): Stream #0:0
I/mobile-ffmpeg( 5731): (eng)
I/mobile-ffmpeg( 5731): : Video: h264 (avc1 / 0x31637661), yuvj420p(pc, bt470bg/bt470bg/smpte170m), 1920x1080, 12728 kb/s
I/mobile-ffmpeg( 5731): , SAR 1:1 DAR 16:9
I/mobile-ffmpeg( 5731): ,
I/mobile-ffmpeg( 5731): 20.09 fps,
I/mobile-ffmpeg( 5731): 30 tbr,
I/mobile-ffmpeg( 5731): 90k tbn,
I/mobile-ffmpeg( 5731): 180k tbc
I/mobile-ffmpeg( 5731): (default)
I/mobile-ffmpeg( 5731):
I/mobile-ffmpeg( 5731): Metadata:
I/mobile-ffmpeg( 5731): rotate :
I/mobile-ffmpeg( 5731): 90
I/mobile-ffmpeg( 5731):
I/mobile-ffmpeg( 5731): creation_time :
I/mobile-ffmpeg( 5731): 2021-08-06T19:50:53.000000Z
I/mobile-ffmpeg( 5731):
I/mobile-ffmpeg( 5731): handler_name :
I/mobile-ffmpeg( 5731): VideoHandle
I/mobile-ffmpeg( 5731):
I/mobile-ffmpeg( 5731): Side data:
I/mobile-ffmpeg( 5731):
I/mobile-ffmpeg( 5731): displaymatrix: rotation of -90.00 degrees
I/mobile-ffmpeg( 5731):
I/mobile-ffmpeg( 5731): Stream #0:1
I/mobile-ffmpeg( 5731): (eng)
I/mobile-ffmpeg( 5731): : Audio: aac (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 96 kb/s
I/mobile-ffmpeg( 5731): (default)
I/mobile-ffmpeg( 5731):
I/mobile-ffmpeg( 5731): Metadata:
I/mobile-ffmpeg( 5731): creation_time :
I/mobile-ffmpeg( 5731): 2021-08-06T19:50:53.000000Z
I/mobile-ffmpeg( 5731):
I/mobile-ffmpeg( 5731): handler_name :
I/mobile-ffmpeg( 5731): SoundHandle
I/mobile-ffmpeg( 5731):
I/mobile-ffmpeg( 5731): Input #1, png_pipe, from '/data/user/0/com.raheyo.cheese/cache/e0baa6a8-4d4c-407a-a73e-be4dcf4d08fd.mp4':
I/mobile-ffmpeg( 5731): Duration:
I/mobile-ffmpeg( 5731): N/A
I/mobile-ffmpeg( 5731): , bitrate:
I/mobile-ffmpeg( 5731): N/A
I/mobile-ffmpeg( 5731):
I/mobile-ffmpeg( 5731): Stream #1:0
I/mobile-ffmpeg( 5731): : Video: png, rgba(pc), 393x822
I/mobile-ffmpeg( 5731): ,
This happens when target output file already exists. Make sure it is not the same file as the input. Then add -y to force overwrite output in case it already exists.

Concat filter: Error initializing output stream

This is a follow-up question to: Flutter (Dart): Merge two videos and view the new output in the device's gallery (photos)
In essence, I am trying to record two videos, merge them and then view the new video in the gallery. I am currently having some issues with the flutter_ffmpeg package.
I uploaded the my Flutter project onto GitHub here:
https://github.com/IttaiBarkai/Flutter-Video-Merger
Below is a snippet of my code used to execute ffmpeg:
void _videoMerger() async {
final appDir = await syspaths.getApplicationDocumentsDirectory();
String rawDocumentPath = appDir.path;
final outputPath = '$rawDocumentPath/output.mp4';
final FlutterFFmpeg _flutterFFmpeg = new FlutterFFmpeg();
String commandToExecute = '-y -i ${_storedVideoOne.path} -i ${_storedVideoTwo.path} -filter_complex \'[0:0][1:0]concat=n=2:v=1:a=0[out]\' -map \'[out]\' $outputPath';
_flutterFFmpeg.execute(commandToExecute).then((rc) => print("FFmpeg process exited with rc $rc"));
}
and this is the output displayed on my debug console when ffmpeg gets executed:
D/flutter-ffmpeg(29135): Running FFmpeg with arguments: [-y, -i, /storage/emulated/0/Android/data/com.example.video_merger_two/files/Pictures/1e8947f4-c9c2-4020-b78d-c40fb77ce0d16301015681843175998.mp4, -i, /storage/emulated/0/Android/data/com.example.video_merger_two/files/Pictures/3555b190-a9a6-450d-b6a7-7d1b8fc89ad38627500242651150494.mp4, -filter_complex, [0:0][1:0]concat=n=2:v=1:a=0[out], -map, [out], /data/user/0/com.example.video_merger_two/app_flutter/output.mp4].
I/mobile-ffmpeg(29135): Loading mobile-ffmpeg.
I/mobile-ffmpeg(29135): Loaded mobile-ffmpeg-https-x86-4.3.1-20200125.
D/mobile-ffmpeg(29135): Callback thread started.
I/mobile-ffmpeg(29135): ffmpeg version git-2020-01-25-fd11dd500
I/mobile-ffmpeg(29135): Copyright (c) 2000-2020 the FFmpeg developers
I/mobile-ffmpeg(29135):
I/mobile-ffmpeg(29135): built with Android (5220042 based on r346389c) clang version 8.0.7 (https://android.googlesource.com/toolchain/clang b55f2d4ebfd35bf643d27dbca1bb228957008617) (https://android.googlesource.com/toolchain/llvm 3c393fe7a7e13b0fba4ac75a01aa683d7a5b11cd) (based on LLVM 8.0.7svn)
I/mobile-ffmpeg(29135): configuration: --cross-prefix=i686-linux-android- --sysroot=/files/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/sysroot --prefix=/home/taner/Projects/mobile-ffmpeg/prebuilt/android-x86/ffmpeg --pkg-config=/usr/bin/pkg-config --enable-version3 --arch=i686 --cpu=i686 --cc=i686-linux-android24-clang --cxx=i686-linux-android24-clang++ --target-os=android --disable-neon --disable-asm --disable-inline-asm --enable-cross-compile --enable-pic --enable-jni --enable-optimizations --enable-swscale --enable-shared --disable-v4l2-m2m --disable-outdev=v4l2 --disable-outdev=fbdev --disable-indev=v4l2 --disable-indev=fbdev --enable-small --disable-openssl --disable-xmm-clobber-test --disable-debug --enable-lto --disable-neon-clobber-test --disable-programs --disable-postproc --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --disable-sndio --disable-schannel --disable-securetransport --disable-xlib --disable-cuda --disable-cuvid --disable-nvenc --di
I/mobile-ffmpeg(29135): libavutil 56. 38.100 / 56. 38.100
I/mobile-ffmpeg(29135): libavcodec 58. 65.102 / 58. 65.102
I/mobile-ffmpeg(29135): libavformat 58. 35.101 / 58. 35.101
I/mobile-ffmpeg(29135): libavdevice 58. 9.103 / 58. 9.103
I/mobile-ffmpeg(29135): libavfilter 7. 70.101 / 7. 70.101
I/mobile-ffmpeg(29135): libswscale 5. 6.100 / 5. 6.100
I/mobile-ffmpeg(29135): libswresample 3. 6.100 / 3. 6.100
I/mobile-ffmpeg(29135): Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/Android/data/com.example.video_merger_two/files/Pictures/1e8947f4-c9c2-4020-b78d-c40fb77ce0d16301015681843175998.mp4':
I/mobile-ffmpeg(29135): Metadata:
I/mobile-ffmpeg(29135): major_brand :
I/mobile-ffmpeg(29135): mp42
I/mobile-ffmpeg(29135):
I/mobile-ffmpeg(29135): minor_version :
I/mobile-ffmpeg(29135): 0
I/mobile-ffmpeg(29135):
I/mobile-ffmpeg(29135): compatible_brands:
I/mobile-ffmpeg(29135): isommp42
I/mobile-ffmpeg(29135):
I/mobile-ffmpeg(29135): creation_time :
I/mobile-ffmpeg(29135): 2020-06-17T18:26:00.000000Z
I/mobile-ffmpeg(29135):
I/mobile-ffmpeg(29135): com.android.version:
I/mobile-ffmpeg(29135): 10
I/mobile-ffmpeg(29135):
I/mobile-ffmpeg(29135): Duration:
I/mobile-ffmpeg(29135): 27:34:19.38
I/mobile-ffmpeg(29135): , start:
I/mobile-ffmpeg(29135): 0.000000
I/mobile-ffmpeg(29135): , bitrate:
I/mobile-ffmpeg(29135): 0 kb/s
I/mobile-ffmpeg(29135):
I/mobile-ffmpeg(29135): Stream #0:0
I/mobile-ffmpeg(29135): (eng)
I/mobile-ffmpeg(29135): : Video: h264 (avc1 / 0x31637661), yuv420p(tv, GBR), 1280x720, 3554 kb/s
I/mobile-ffmpeg(29135): , SAR 1:1 DAR 16:9
I/mobile-ffmpeg(29135): ,
I/mobile-ffmpeg(29135): 29.01 fps,
I/mobile-ffmpeg(29135): 29 tbr,
I/mobile-ffmpeg(29135): 90k tbn,
I/mobile-ffmpeg(29135): 180k tbc
I/mobile-ffmpeg(29135): (default)
I/mobile-ffmpeg(29135):
I/mobile-ffmpeg(29135): Metadata:
I/mobile-ffmpeg(29135): rotate :
I/mobile-ffmpeg(29135): 90
I/mobile-ffmpeg(29135):
I/mobile-ffmpeg(29135): creation_time :
I/mobile-ffmpeg(29135): 2020-06-17T18:26:00.000000Z
I/mobile-ffmpeg(29135):
I/mobile-ffmpeg(29135): handler_name :
I/mobile-ffmpeg(29135): VideoHandle
I/mobile-ffmpeg(29135):
I/mobile-ffmpeg(29135): Side data:
I/mobile-ffmpeg(29135):
I/mobile-ffmpeg(29135): displaymatrix: rotation of -90.00 degrees
I/mobile-ffmpeg(29135):
I/mobile-ffmpeg(29135): Stream #0:1
I/mobile-ffmpeg(29135): (eng)
I/mobile-ffmpeg(29135): : Audio: amr_nb (samr / 0x726D6173), 8000 Hz, mono, flt, 12 kb/s
I/mobile-ffmpeg(29135): (default)
I/mobile-ffmpeg(29135):
I/mobile-ffmpeg(29135): Metadata:
I/mobile-ffmpeg(29135): creation_time :
I/mobile-ffmpeg(29135): 2020-06-17T18:26:00.000000Z
I/mobile-ffmpeg(29135):
I/mobile-ffmpeg(29135): handler_name :
I/mobile-ffmpeg(29135): SoundHandle
I/mobile-ffmpeg(29135):
I/mobile-ffmpeg(29135): Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/Android/data/com.example.video_merger_two/files/Pictures/3555b190-a9a6-450d-b6a7-7d1b8fc89ad38627500242651150494.mp4':
I/mobile-ffmpeg(29135): Metadata:
I/mobile-ffmpeg(29135): major_brand :
I/mobile-ffmpeg(29135): mp42
I/mobile-ffmpeg(29135):
I/mobile-ffmpeg(29135): minor_version :
I/mobile-ffmpeg(29135): 0
I/mobile-ffmpeg(29135):
I/mobile-ffmpeg(29135): compatible_brands:
I/mobile-ffmpeg(29135): isommp42
I/mobile-ffmpeg(29135):
I/mobile-ffmpeg(29135): creation_time :
I/mobile-ffmpeg(29135): 2020-06-17T18:26:09.000000Z
I/mobile-ffmpeg(29135):
I/mobile-ffmpeg(29135): com.android.version:
I/mobile-ffmpeg(29135): 10
I/mobile-ffmpeg(29135):
I/mobile-ffmpeg(29135): Duration:
I/mobile-ffmpeg(29135): 27:34:19.62
I/mobile-ffmpeg(29135): , start:
I/mobile-ffmpeg(29135): 0.000000
I/mobile-ffmpeg(29135): , bitrate:
I/mobile-ffmpeg(29135): 0 kb/s
I/mobile-ffmpeg(29135):
I/mobile-ffmpeg(29135): Stream #1:0
I/mobile-ffmpeg(29135): (eng)
I/mobile-ffmpeg(29135): : Video: h264 (avc1 / 0x31637661), yuv420p(tv, GBR), 1280x720, 3765 kb/s
I/mobile-ffmpeg(29135): , SAR 1:1 DAR 16:9
I/mobile-ffmpeg(29135): ,
I/mobile-ffmpeg(29135): 28.80 fps,
I/mobile-ffmpeg(29135): 29.08 tbr,
I/mobile-ffmpeg(29135): 90k tbn,
I/mobile-ffmpeg(29135): 180k tbc
I/mobile-ffmpeg(29135): (default)
I/mobile-ffmpeg(29135):
I/mobile-ffmpeg(29135): Metadata:
I/mobile-ffmpeg(29135): rotate :
I/mobile-ffmpeg(29135): 90
I/mobile-ffmpeg(29135):
I/mobile-ffmpeg(29135): creation_time :
I/mobile-ffmpeg(29135): 2020-06-17T18:26:09.000000Z
I/mobile-ffmpeg(29135):
I/mobile-ffmpeg(29135): handler_name :
I/mobile-ffmpeg(29135): VideoHandle
I/mobile-ffmpeg(29135):
I/mobile-ffmpeg(29135): Side data:
I/mobile-ffmpeg(29135):
I/mobile-ffmpeg(29135): displaymatrix: rotation of -90.00 degrees
I/mobile-ffmpeg(29135):
I/mobile-ffmpeg(29135): Stream #1:1
I/mobile-ffmpeg(29135): (eng)
I/mobile-ffmpeg(29135): : Audio: amr_nb (samr / 0x726D6173), 8000 Hz, mono, flt, 12 kb/s
I/mobile-ffmpeg(29135): (default)
I/mobile-ffmpeg(29135):
I/mobile-ffmpeg(29135): Metadata:
I/mobile-ffmpeg(29135): creation_time :
I/mobile-ffmpeg(29135): 2020-06-17T18:26:09.000000Z
I/mobile-ffmpeg(29135):
I/mobile-ffmpeg(29135): handler_name :
I/mobile-ffmpeg(29135): SoundHandle
I/mobile-ffmpeg(29135):
I/mobile-ffmpeg(29135): Stream mapping:
I/mobile-ffmpeg(29135): Stream #0:0 (h264) -> concat:in0:v0
I/mobile-ffmpeg(29135):
I/mobile-ffmpeg(29135): Stream #1:0 (h264) -> concat:in1:v0
I/mobile-ffmpeg(29135):
I/mobile-ffmpeg(29135): concat
I/mobile-ffmpeg(29135): -> Stream #0:0 (mpeg4)
I/mobile-ffmpeg(29135): Press [q] to stop, [?] for help
W/mobile-ffmpeg(29135): [graph 0 input from stream 0:0 # 0xed087710] sws_param option is deprecated and ignored
W/mobile-ffmpeg(29135): [graph 0 input from stream 1:0 # 0xed086830] sws_param option is deprecated and ignored
W/mobile-ffmpeg(29135): [mp4 # 0xeccd8790] Frame rate very high for a muxer not efficiently supporting it.
W/mobile-ffmpeg(29135): Please consider specifying a lower framerate, a different muxer or -vsync 2
E/mobile-ffmpeg(29135): [mpeg4 # 0xe68049d0] timebase 1/1000000 not supported by MPEG 4 standard, the maximum admitted value for the timebase denominator is 65535
E/mobile-ffmpeg(29135): Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
I/mobile-ffmpeg(29135): Conversion failed!
D/flutter-ffmpeg(29135): FFmpeg exited with rc: 1
I/flutter (29135): FFmpeg process exited with rc 1
You probably need a slightly different filter:
-filter_complex "[0:v][1:v]concat=n=2:v=1:a=0[out]" -map "[out]"
Actually, you can copy the two input files to your PC, and tune the 'real' ffmpeg parameters using the command line until the result satisfies you. Only after that, and on condition that the expected true input files will be with same characteristics, you can put these parameters into your dart code.
BTW, do you deliberately drop the audio stream here?
This was the commandToExecute, which finally worked for me. Hope it helps anyone with a similar issue :)
'-y -i ${_storedVideoOne.path} -i ${_storedVideoTwo.path} -r 24000/1001 -filter_complex \'[0:v:0][0:a:0][1:v:0][1:a:0]concat=n=2:v=1:a=1[out]\' -map \'[out]\' $outputPath'
I then still had to save the final output using this:
GallerySaver.saveVideo(outputPath).then((_) {});

Flutter (Dart): Merge two videos and view the new output in the device's gallery (photos)

I am aware that there already exists a solution to a very similar question, which can be found on the following link: Flutter/Dart: Find two video segments and merge them into a single valid video file? However, being relatively new to Flutter (and programming in general) I cannot seem to replicate the desired result.
My app is very simple and currently looks like this:
I click on the button "Record Video" to record two videos, which are both successfully stored into the device's gallery. Using the Flutter image_picker and gallery_saver packages and the following piece of code:
void _recordVideo() async {
ImagePicker.pickVideo(source: ImageSource.camera)
.then((File recordedVideo) {
if (recordedVideo != null && recordedVideo.path != null) {
setState(() {
_buttonText = 'Saving in Progress...';
});
GallerySaver.saveVideo(recordedVideo.path).then((_) {
setState(() {
_buttonText = 'Video Saved!\n\nClick to Record New Video';
if (_storedVideoOne == null) {
_storedVideoOne = recordedVideo;
print('video 1 stored');
} else {
_storedVideoTwo = recordedVideo;
print('video 2 stored');
_videoMerger();
}
});
});
}
});
}
I can view these videos when I click on the button at the bottom "View Video From Gallery".
Next I try to merge these two stored video files, using the flutter_ffmpeg package, as well as following the solution provided in the stack overflow question mentioned above. I try and do this using the following function I wrote:
void _videoMerger() async {
final appDir = await syspaths.getApplicationDocumentsDirectory();
String rawDocumentPath = appDir.path;
final outputPath = '$rawDocumentPath/output.mp4';
final FlutterFFmpeg _flutterFFmpeg = new FlutterFFmpeg();
String commandToExecute = '-i ${_storedVideoOne.path} -i ${_storedVideoTwo.path} -filter_complex \'[0:0][1:0]concat=n=2:v=1:a=0[out]\' -map \'[out]\' outputPath';
_flutterFFmpeg.execute(commandToExecute).then((rc) => print("FFmpeg process exited with rc $rc"));
}
But after running the function I do not seem to get a new combined video, which should be stored in outputPath and ideally also viewable in the gallery. Uploaded the Flutter project onto GitHub here:
https://github.com/IttaiBarkai/Flutter-Video-Merger
Any help would be greatly appreciated :)
Updated:
Below is the output displayed on my debug console when ffmpeg gets executed:
D/flutter-ffmpeg( 4146): Running FFmpeg with arguments: [-i, /storage/emulated/0/Android/data/com.example.video_merger_two/files/Pictures/d2b7a612-7c6d-48fe-8d06-85ceeb10e2f584195978113840656.mp4, -i, /storage/emulated/0/Android/data/com.example.video_merger_two/files/Pictures/b6cb83a3-10ac-49c7-80f3-3447bebe93ac5245748251872788895.mp4, -filter_complex, [0:0][1:0]concat=n=2:v=1:a=0[out], -map, [out], outputPath.mp4].
I/mobile-ffmpeg( 4146): ffmpeg version git-2020-01-25-fd11dd500
I/mobile-ffmpeg( 4146): Copyright (c) 2000-2020 the FFmpeg developers
I/mobile-ffmpeg( 4146):
I/mobile-ffmpeg( 4146): built with Android (5220042 based on r346389c) clang version 8.0.7 (https://android.googlesource.com/toolchain/clang b55f2d4ebfd35bf643d27dbca1bb228957008617) (https://android.googlesource.com/toolchain/llvm 3c393fe7a7e13b0fba4ac75a01aa683d7a5b11cd) (based on LLVM 8.0.7svn)
I/mobile-ffmpeg( 4146): configuration: --cross-prefix=i686-linux-android- --sysroot=/files/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/sysroot --prefix=/home/taner/Projects/mobile-ffmpeg/prebuilt/android-x86/ffmpeg --pkg-config=/usr/bin/pkg-config --enable-version3 --arch=i686 --cpu=i686 --cc=i686-linux-android24-clang --cxx=i686-linux-android24-clang++ --target-os=android --disable-neon --disable-asm --disable-inline-asm --enable-cross-compile --enable-pic --enable-jni --enable-optimizations --enable-swscale --enable-shared --disable-v4l2-m2m --disable-outdev=v4l2 --disable-outdev=fbdev --disable-indev=v4l2 --disable-indev=fbdev --enable-small --disable-openssl --disable-xmm-clobber-test --disable-debug --enable-lto --disable-neon-clobber-test --disable-programs --disable-postproc --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-static --disable-sndio --disable-schannel --disable-securetransport --disable-xlib --disable-cuda --disable-cuvid --disable-nvenc --di
I/mobile-ffmpeg( 4146): libavutil 56. 38.100 / 56. 38.100
I/mobile-ffmpeg( 4146): libavcodec 58. 65.102 / 58. 65.102
I/mobile-ffmpeg( 4146): libavformat 58. 35.101 / 58. 35.101
I/mobile-ffmpeg( 4146): libavdevice 58. 9.103 / 58. 9.103
I/mobile-ffmpeg( 4146): libavfilter 7. 70.101 / 7. 70.101
I/mobile-ffmpeg( 4146): libswscale 5. 6.100 / 5. 6.100
I/mobile-ffmpeg( 4146): libswresample 3. 6.100 / 3. 6.100
I/mobile-ffmpeg( 4146): Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/Android/data/com.example.video_merger_two/files/Pictures/d2b7a612-7c6d-48fe-8d06-85ceeb10e2f584195978113840656.mp4':
I/mobile-ffmpeg( 4146): Metadata:
I/mobile-ffmpeg( 4146): major_brand :
I/mobile-ffmpeg( 4146): mp42
I/mobile-ffmpeg( 4146):
I/mobile-ffmpeg( 4146): minor_version :
I/mobile-ffmpeg( 4146): 0
I/mobile-ffmpeg( 4146):
I/mobile-ffmpeg( 4146): compatible_brands:
I/mobile-ffmpeg( 4146): isommp42
I/mobile-ffmpeg( 4146):
I/mobile-ffmpeg( 4146): creation_time :
I/mobile-ffmpeg( 4146): 2020-06-17T12:07:20.000000Z
I/mobile-ffmpeg( 4146):
I/mobile-ffmpeg( 4146): com.android.version:
I/mobile-ffmpeg( 4146): 10
I/mobile-ffmpeg( 4146):
I/mobile-ffmpeg( 4146): Duration:
I/mobile-ffmpeg( 4146): 27:34:19.40
I/mobile-ffmpeg( 4146): , start:
I/mobile-ffmpeg( 4146): 0.000000
I/mobile-ffmpeg( 4146): , bitrate:
I/mobile-ffmpeg( 4146): 0 kb/s
I/mobile-ffmpeg( 4146):
I/mobile-ffmpeg( 4146): Stream #0:0
I/mobile-ffmpeg( 4146): (eng)
I/mobile-ffmpeg( 4146): : Video: h264 (avc1 / 0x31637661), yuv420p(tv, GBR), 1280x720, 3536 kb/s
I/mobile-ffmpeg( 4146): , SAR 1:1 DAR 16:9
I/mobile-ffmpeg( 4146): ,
I/mobile-ffmpeg( 4146): 28.75 fps,
I/mobile-ffmpeg( 4146): 29.08 tbr,
I/mobile-ffmpeg( 4146): 90k tbn,
I/mobile-ffmpeg( 4146): 180k tbc
I/mobile-ffmpeg( 4146): (default)
I/mobile-ffmpeg( 4146):
I/mobile-ffmpeg( 4146): Metadata:
I/mobile-ffmpeg( 4146): rotate :
I/mobile-ffmpeg( 4146): 90
I/mobile-ffmpeg( 4146):
I/mobile-ffmpeg( 4146): creation_time :
I/mobile-ffmpeg( 4146): 2020-06-17T12:07:20.000000Z
I/mobile-ffmpeg( 4146):
I/mobile-ffmpeg( 4146): handler_name :
I/mobile-ffmpeg( 4146): VideoHandle
I/mobile-ffmpeg( 4146):
I/mobile-ffmpeg( 4146): Side data:
I/mobile-ffmpeg( 4146):
I/mobile-ffmpeg( 4146): displaymatrix: rotation of -90.00 degrees
I/mobile-ffmpeg( 4146):
I/mobile-ffmpeg( 4146): Stream #0:1
I/mobile-ffmpeg( 4146): (eng)
I/mobile-ffmpeg( 4146): : Audio: amr_nb (samr / 0x726D6173), 8000 Hz, mono, flt, 12 kb/s
I/mobile-ffmpeg( 4146): (default)
I/mobile-ffmpeg( 4146):
I/mobile-ffmpeg( 4146): Metadata:
I/mobile-ffmpeg( 4146): creation_time :
I/mobile-ffmpeg( 4146): 2020-06-17T12:07:20.000000Z
I/mobile-ffmpeg( 4146):
I/mobile-ffmpeg( 4146): handler_name :
I/mobile-ffmpeg( 4146): SoundHandle
I/mobile-ffmpeg( 4146):
I/mobile-ffmpeg( 4146): Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/Android/data/com.example.video_merger_two/files/Pictures/b6cb83a3-10ac-49c7-80f3-3447bebe93ac5245748251872788895.mp4':
I/mobile-ffmpeg( 4146): Metadata:
I/mobile-ffmpeg( 4146): major_brand :
I/mobile-ffmpeg( 4146): mp42
I/mobile-ffmpeg( 4146):
I/mobile-ffmpeg( 4146): minor_version :
I/mobile-ffmpeg( 4146): 0
I/mobile-ffmpeg( 4146):
I/mobile-ffmpeg( 4146): compatible_brands:
I/mobile-ffmpeg( 4146): isommp42
I/mobile-ffmpeg( 4146):
I/mobile-ffmpeg( 4146): creation_time :
I/mobile-ffmpeg( 4146): 2020-06-17T12:07:32.000000Z
I/mobile-ffmpeg( 4146):
I/mobile-ffmpeg( 4146): com.android.version:
I/mobile-ffmpeg( 4146): 10
I/mobile-ffmpeg( 4146):
I/mobile-ffmpeg( 4146): Duration:
I/mobile-ffmpeg( 4146): 27:34:19.35
I/mobile-ffmpeg( 4146): , start:
I/mobile-ffmpeg( 4146): 0.000000
I/mobile-ffmpeg( 4146): , bitrate:
I/mobile-ffmpeg( 4146): 0 kb/s
I/mobile-ffmpeg( 4146):
I/mobile-ffmpeg( 4146): Stream #1:0
I/mobile-ffmpeg( 4146): (eng)
I/mobile-ffmpeg( 4146): : Video: h264 (avc1 / 0x31637661), yuv420p(tv, GBR), 1280x720, 3561 kb/s
I/mobile-ffmpeg( 4146): , SAR 1:1 DAR 16:9
I/mobile-ffmpeg( 4146): ,
I/mobile-ffmpeg( 4146): 28.95 fps,
I/mobile-ffmpeg( 4146): 29 tbr,
I/mobile-ffmpeg( 4146): 90k tbn,
I/mobile-ffmpeg( 4146): 180k tbc
I/mobile-ffmpeg( 4146): (default)
I/mobile-ffmpeg( 4146):
I/mobile-ffmpeg( 4146): Metadata:
I/mobile-ffmpeg( 4146): rotate
:
I/mobile-ffmpeg( 4146): 90
I/mobile-ffmpeg( 4146):
I/mobile-ffmpeg( 4146): creation_time :
I/mobile-ffmpeg( 4146): 2020-06-17T12:07:32.000000Z
I/mobile-ffmpeg( 4146):
I/mobile-ffmpeg( 4146): handler_name :
I/mobile-ffmpeg( 4146): VideoHandle
I/mobile-ffmpeg( 4146):
I/mobile-ffmpeg( 4146): Side data:
I/mobile-ffmpeg( 4146):
I/mobile-ffmpeg( 4146): displaymatrix: rotation of -90.00 degrees
I/mobile-ffmpeg( 4146):
I/mobile-ffmpeg( 4146): Stream #1:1
I/mobile-ffmpeg( 4146): (eng)
I/mobile-ffmpeg( 4146): : Audio: amr_nb (samr / 0x726D6173), 8000 Hz, mono, flt, 12 kb/s
I/mobile-ffmpeg( 4146): (default)
I/mobile-ffmpeg( 4146):
I/mobile-ffmpeg( 4146): Metadata:
I/mobile-ffmpeg( 4146): creation_time :
I/mobile-ffmpeg( 4146): 2020-06-17T12:07:32.000000Z
I/mobile-ffmpeg( 4146):
I/mobile-ffmpeg( 4146): handler_name :
I/mobile-ffmpeg( 4146): SoundHandle
I/mobile-ffmpeg( 4146):
E/mobile-ffmpeg( 4146): outputPath.mp4: Read-only file system
D/flutter-ffmpeg( 4146): FFmpeg exited with rc: 1
I/flutter ( 4146): FFmpeg process exited with rc 1
Your mistake is when you construct comandToExecute. You missed a $:
String commandToExecute = '-i ${_storedVideoOne.path} -i ${_storedVideoTwo.path} -filter_complex \'[0:0][1:0]concat=n=2:v=1:a=0[out]\' -map \'[out]\' $outputPath';
outputPath.mp4: Read-only file system
Output to a location that can be written to.