New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FFmpeg-Kit on Android consumes excessive time and memory compared to Termux #959
Comments
Thanks for the benchmarks. According to the screenshots: The test on
The test on
Which means this test mostly compares Is seeing If you have time I suggest testing the performance of the same encoder in both implementations. |
I apologize for not providing a full screenshot initially. However, I am sure I am not making the wrong comparison. The command lines used in each round of comparison are exactly the same except for the output file path. In the first round of comparison (on my Android 14 phone), command lines are visible, both used hevc(native) decoding and hevc_mediacodec (hardware accelerated) encoding. You can also see that the file size output by both is the same at 22440KB. In the second comparison (on Android 10 emulator), both used hevc(native) decoding and libx265(software) encoding. |
Thanks for updating the screenshots. Now, I see the difference for the same codec. Well, On one hand, it is good to have a reference library to compare our performance against. On the other hand, identifying the root cause requires extensive testing. I'll add a task to the If you have time, I suggest testing
|
I tested all three scenarios and did not seem to observe any performance improvement. Could we customize the version of FFmpeg source code when compiling FFmpeg-Kit? If possible, maybe I can try it myself using a newer version of FFmpeg. |
Okay. Thanks for checking. Well, this line defines |
I noticed that the wiki page Speed Optimization mentioned that the Also, I think the performance issues I mentioned may still need to be reproduced by anyone else to ensure that this issue is not caused by my personal compilation environment. (If it is because of my stupid mistake that this issue arose, I would feel really embarrassed to inconvenience you!🥹) |
I previously tested the However, these tests were conducted on older versions. It may be necessary to rerun them to reassess the situation. Unfortunately, time constraints are a significant factor for me. I am currently pressed for time, and we have limited contributions to address these issues. I appreciate your contribution and feedback. I will make an effort to dedicate some time on |
Today, I conducted some tests on the I ran the following command on an
I observed a difference in memory usage. Other than that, I didn't see a significant difference between This is
This is
I also repeated my tests on a local
|
In recent days, I've been reflecting on and investigating this issue extensively, conducting numerous tests in an attempt to identify the cause behind these test results. Upon reviewing the tests I've conducted, I realized that all the video samples used in my tests were recorded using my phone. This is because I'm trying to develop an Android application to compress videos shot on my phone. When testing with my own recorded videos, visible performance differences were evident regardless of the encoder used. However, after receiving your response, I attempted testing with video samples downloaded from the internet and obtained results similar to yours - no noticeable performance differences during transcoding. This prompted me to consider that the issue might lie in decoding performance. Videos from the internet are typically compressed and easier to decode, whereas videos recorded on my phone usually have higher resolution and bitrate, making decoding performance the true bottleneck. Therefore, I selected some videos I recorded and others downloaded from the internet, and tested decoding performance using the List of files used for testing:
Test result:
Let's review the log output. On the left side of the screenshot is the output from Here I'm taking It appears that they both use the decoder called It seems like this is the real issue at hand. |
Additionally, I also tested not using the Command line used for testing:
Log output in
Log output in
As you can see, the decoding performance of Termux and FFmpegKit is exactly the same when using the Android hardware accelerated decoder |
Thanks for running those tests. I need some time to review them. |
I ran your test scenarios on my end. The results from the native decoder are consistent with the figures in your tests. However, in my case, the I've noticed the following differences between the
|
I managed to enable There is also a new |
Background: Termux is a Linux terminal emulator on the Android platform. We can install FFmpeg in it by executing
pkg install ffmpeg
, and the current provided version is6.1.1
.Recently, I compared the performance of transcoding videos using FFmpeg via Termux and via FFmpeg-Kit and found that Termux consumes much less time and memory.
For example, on my Android 14 phone, FFmpeg in Termux transcoded a video in 44.4 seconds and consumed 604M of memory. However, using FFmpeg-Kit (implemented with
com.arthenica:ffmpeg-kit-full-gpl:6.0-2.LTS
and callingFFmpegKit.executeAsync()
) for the same task required 82.1 seconds and 724M of memory. Screenshots:To ensure this is not device-specific, I conducted tests on an Android 10 x86-64 emulator. Termux completed the task in 30 seconds, using 585M of memory, while FFmpeg-Kit took 88 seconds and utilized nearly 1GB of memory. Screenshots:
Despite various attempts to find the cause — including making sure both were using the arm64-v8a platform (or both were x86-64), importing different videos, altering bit depths, and hardware acceleration settings, as well as adjusting power options and background process limits — the huge performance gap persisted consistently.
I tested video transcoding on Windows using FFmpeg versions
6.0
and6.1.1
and observed no significant performance differences.So I am wondering if this is an unexpected behavior, and it would be better if FFmpeg inside FFmpeg-Kit could perform as well as Termux.
The FFmpeg-Kit project brings great convenience to Android developers like me who develop functions based on FFmpeg. I am eager to provide additional information or assistance if required. Any insights or guidance would be sincerely appreciated.
The text was updated successfully, but these errors were encountered: