tanersener / mobile-ffmpeg

FFmpeg for Android, iOS and tvOS. Not maintained anymore. Superseded by FFmpegKit.
https://tanersener.github.io/mobile-ffmpeg
GNU General Public License v3.0
3.85k stars 787 forks source link

Terminated due to memory issue #687

Closed ahmedAlmasri closed 3 years ago

ahmedAlmasri commented 3 years ago

Description memory issue when trying to convert video to timelapse using this command -y -i input.mp4 -filter:v \"setpts=\0.0651*PTS\" output.mp4

Video Size: 10 MB Video Type: Wide-angle camera Frame dimension : 3840x2160 4K Logs

ffmpeg version v4.4-dev-416 Copyright (c) 2000-2020 the FFmpeg developers
  built with Apple clang version 11.0.3 (clang-1103.0.32.62)
  configuration: --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.6.sdk --prefix=/Users/taner/Projects/mobile-ffmpeg/prebuilt/ios-arm64/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=20200725 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.6.sdk -Oz -miphoneos-version-min=12.1 -I/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.6.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-outdev=audiotoolbox --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-libfontconfig --enable-libfreetype --enable-libfribidi --enable-gmp --enable-gnutls --enable-libmp3lame --enable-libass --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libxml2 --enable-libopencore-amrnb --enable-libshine --enable-libspeex --enable-libwavpack --enable-libkvazaar --enable-libx264 --enable-gpl --enable-libxvid --enable-gpl --enable-libx265 --enable-gpl --enable-libvidstab --enable-gpl --enable-libilbc --enable-libopus --enable-libsnappy --enable-libsoxr --enable-libaom --enable-libtwolame --disable-sdl2 --enable-libvo-amrwbenc --enable-zlib --enable-audiotoolbox --enable-bzlib --enable-videotoolbox --enable-avfoundation --enable-iconv
  libavutil      56. 55.100 / 56. 55.100
  libavcodec     58. 96.100 / 58. 96.100
  libavformat    58. 48.100 / 58. 48.100
  libavdevice    58. 11.101 / 58. 11.101
  libavfilter     7. 87.100 /  7. 87.100
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/var/mobile/Containers/Data/Application/3A9CF9FF-0B57-4711-9797-CFFDDA8FEB2B/Documents/output.mov':
  Metadata:
    major_brand     : qt  
    minor_version   : 0
    compatible_brands: qt  
    creation_time   : 2021-03-03T14:38:56.000000Z
  Duration: 00:00:02.73, start: 0.000000, bitrate: 40079 kb/s
    Stream #0:0(und): Video: hevc (hvc1 / 0x31637668), yuv420p(tv, bt709), 3840x2160, 40039 kb/s, 30 fps, 30 tbr, 600 tbn, 600 tbc (default)
    Metadata:
      creation_time   : 2021-03-03T14:38:56.000000Z
      handler_name    : Core Media Video
      encoder         : HEVC
Stream mapping:
  Stream #0:0 -> #0:0 (hevc (native) -> h264 (libx264))
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    
[graph 0 input from stream 0:0 @ 0x10de2cf60] sws_param option is deprecated and ignored
[libx264 @ 0x10e018c00] using cpu capabilities: ARMv8 NEON
[libx264 @ 0x10e018c00] profile High, level 5.1, 4:2:0, 8-bit
[libx264 @ 0x10e018c00] 264 - core 160 - H.264/MPEG-4 AVC codec - Copyleft 2003-2020 - 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=25 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 '/private/var/mobile/Containers/Data/Application/3A9CF9FF-0B57-4711-9797-CFFDDA8FEB2B/tmp/360_camera/tlp.mp4':
  Metadata:
    major_brand     : qt  
    minor_version   : 0
    compatible_brands: qt  
    encoder         : Lavf58.48.100
    Stream #0:0(und): Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 3840x2160, q=-1--1, 30 fps, 15360 tbn, 30 tbc (default)
    Metadata:
      creation_time   : 2021-03-03T14:38:56.000000Z
      handler_name    : Core Media Video
      encoder         : Lavc58.96.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
frame=   11 fps=8.7 q=0.0 size=       0kB time=00:00:00.00 bitrate=N/A dup=2 drop=0 speed=   0x    
frame=   22 fps= 12 q=0.0 size=       0kB time=00:00:00.00 bitrate=N/A dup=5 drop=0 speed=   0x    
frame=   31 fps= 12 q=0.0 size=       0kB time=00:00:00.00 bitrate=N/A dup=7 drop=0 speed=   0x    
frame=   40 fps= 13 q=0.0 size=       0kB time=00:00:00.00 bitrate=N/A dup=9 drop=0 speed=   0x    
frame=   48 fps=9.4 q=0.0 size=       0kB time=00:00:00.00 bitrate=N/A dup=11 drop=0 speed=   0x    
frame=   54 fps=9.3 q=29.0 size=     256kB time=-00:00:00.06 bitrate=N/A dup=12 drop=0 speed=N/A    
frame=   57 fps=8.4 q=29.0 size=     768kB time=00:00:00.03 bitrate=188389.7kbits/s dup=13 drop=0 speed=0.00492x    
frame=   58 fps=7.8 q=29.0 size=    1024kB time=00:00:00.06 bitrate=125711.7kbits/s dup=13 drop=0 speed=0.00902x    
frame=   62 fps=7.8 q=29.0 size=    1536kB time=00:00:00.20 bitrate=62896.0kbits/s dup=14 drop=0 speed=0.0251x

Environment

bojanstef commented 3 years ago

@tanersener I too have this issue when running "-i input.mov output.mov"

dkgupta2516 commented 3 years ago

@tanersener i am also facing same issue with this command

*{"-y", "-i", videoPath, "-movflags", "+faststart", "-map_metadata", "0","-vcodec", "libx264", "-b:v", videoBitrate, "-b:a", "128k","-vf", "lutyuv=y=val2.0","-preset", "superfast","-c:a", "copy" ,mDestinationURL}**

tanersener commented 3 years ago

Sorry but I don't understand why this is an issue. We all know that ffmpeg is a library that has high memory consumption and mobile devices have limited memory. So, it is normal to have memory issues sometimes.

What you need to do is work on your command and modify the filters/options in it to decrease the memory usage.

If you suspect ffmpeg has a memory leak then you must make a more detailed analysis and show us that it consumes more memory than it needs.

dkgupta2516 commented 3 years ago

@tanersener thanks for the reply.

but when the command running from main UI thread, its working great. when starting in the background service (like Service, Woker), and if closed the that Main Ui thread (like Activities), it stopeed working.

tanersener commented 3 years ago

This project will be retired. Please consider switching to FFmpegKit.