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

Compilation sped is too slow #577

Closed karthiknew01 closed 3 years ago

karthiknew01 commented 3 years ago

Description I using the following command -i 1caf527f-30a9-4cab-9ca1-2a98b52a6d6a/Movie/Q78730.mp4 -i video1.mp4 -i CleanLogo_720-hb.mp4 -i looped.m4a -i ba255f8b-a5ad-431a-9285-362366b3ffe7.png -filter_complex "[0:v]scale=1280x720,setdar=16/9,setsar=1/1[v0];[1:v]scale=1280x720,setdar=16/9,setsar=1/1[v1];[2:v]scale=1280x720,setdar=16/9,setsar=1/1[v2];[3:v]scale=1280x720,setdar=16/9,setsar=1/1[v3];[v0][0:a][v1][1:a][v2][2:a][v3][3:a]concat=n=4:v=1:a=1[outv1][outa1],[5:v]scale=160:-1[outv2],[outv1][outv2]overlay=main_w-overlay_w-20:main_h-overlay_h-70[outv];[4:a]volume=enable='between(t,11.96,21.991)+between(t,20.991,29.951)':volume=0.4,afade=t=out:st=26.951:d=3[outa2];[outa1][outa2]amix=inputs=2[outa]" -map [outv] -map [outa] -g 2 -preset ultrafast video2.mp4 -y to merge multiple videos and add overlays

Expected behavior I used this command with WritingMinds library. It used to work with speed of 1x to 1.5x.

Current behavior After migration to this library, compilation speed is very slow. I'm getting a speed of 0.0005x.

Logs frame=120000 fps=564 q=19.0 size= 114944kB time=00:00:00.11 bitrate=7847697.1kbits/s dup=119996 drop=0 speed=0.000564x

Environment

AllwinJohnson commented 3 years ago

Environment Platform : Android 10, arm-64v8a

I'm also facing this issue. I migrated from Bravobit. Below command, I used to merge two videos and an image

"-y", "-i", inputFile1, "-i", inputFile2, "-i",  inputFile3,
              "-filter_complex", "[0:v]scale=" + res + ",setsar=1[v0];" + "[1:v]scale=" + res + ",setsar=1[v1];" +
              "[v0][0:a][v1][1:a]concat=n=2:v=1:a=1[v];" +
              "[v][2]overlay=x=0:y=(main_h-overlay_h)/2:enable='lte(t," + duration + ")'",
              "-ab", "48000",
              "-ac", "2", "-ar", "22050", "-s", "" + res, "-vcodec", "libx264", "-crf", "27", "-preset",
              "ultrafast", outputPath

Inputs input1 - 1.86mb - .mp4 input2 - 692kb - .mp4 input3 - 1.54kb - .png

Bravobit version - nl.bravobit:android-ffmpeg:1.1.7

Output - 14.42mb - .mp4 Log

mobile-ffmpeg version - mobile-ffmpeg-full-gpl:4.4.LTS Log

I'm getting a speed of I/mobile-ffmpeg: frame=33333 fps=1273 q=21.0 size= 2304kB time=00:00:00.20 bitrate=89889.6kbits/s dup=33331 drop=0 speed=0.00802x to I/mobile-ffmpeg: frame=3000000 fps=1318 q=21.0 size= 234752kB time=00:00:03.18 bitrate=604339.7kbits/s dup=2999909 drop=0 speed=0.0014x In log i'm getting W/mobile-ffmpeg: More than 1000 frames duplicated as processing the command the frame count increases by 100000, 1000000 after the process is completed I'm getting an output of file size 598mb and also the video can't play.

Comparing both Library Logs

 W/mobile-ffmpeg: [graph 0 input from stream 2:0 @ 0x753497a240] sws_param option is deprecated and ignored
 W/mobile-ffmpeg: [mp4 @ 0x7560656600] Frame rate very high for a muxer not efficiently supporting it.Please consider specifying a lower framerate, a different muxer or -vsync 2
 I/mobile-ffmpeg: [libx264 @ 0x756099df00] using SAR=1/1
 W/mobile-ffmpeg: [libx264 @ 0x756099df00] MB rate (858000000) > level limit (16711680)
 I/mobile-ffmpeg: [libx264 @ 0x756099df00] using cpu capabilities: ARMv8 NEON
 I/mobile-ffmpeg: [libx264 @ 0x756099df00] profile Constrained Baseline, level 6.2, 4:2:0, 8-bit

Conclusion Issue fixed by adding -vsync 0 to the command, to avoid frame duplication. Better processing speed and lesser output size. output - 1.56mb - .mp4

Thank you @tanersener

tanersener commented 3 years ago

When we are talking about a performance difference between two different libraries, there are a lot of variables that come into play. And the right way to understand the root cause is to:

  1. Run the same command
  2. Using the same input files
  3. On the same device
  4. Compare the ffmpeg console outputs

I don't see that kind of information in this ticket. So, I'm marking it with missing-issue-template label. Please provide console outputs of each library if you want this to be investigated.

github-actions[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.