bravobit / FFmpeg-Android

FFMpeg/FFprobe compiled for Android
https://bravobit.nl/
MIT License
741 stars 176 forks source link

ARM support enhancement for ARM-v7 and ARM-v8 with libx264 #24

Open tsoumalis opened 6 years ago

tsoumalis commented 6 years ago

Hello,

Using the FFMPEG executable from this project I notice in the logs that it is using "cpu capabilities: ARMv6-neon" on devices with arm v7 and v8 CPUs. This of course gives a great performance boost against "using cpu capabilities: none!" but I was wondering if there could be even more performance in case libx264 could use the full capabilities of the CPU.

Thanks in advance for your response.

tsoumalis commented 6 years ago

An update on this: using the static builds from the official ffmpeg site actually display CPU capabilities: ARMv7-neon (and ARMv8-neon for 64 bit) with some performance increase both in x264 and especially in other operations such as mp3 operations with libmp3lame or aac sound commands. Unfortunately, these builds failed to work in Nexus 6P (despite working on every other device I have tried) and are larger in size because they contain more libraries.

So, there is definitely some more performance hidden if ffmpeg is built correctly for every architecture. In fact, armeabi (armv6) is mostly used by ancient devices so I believe that it should be built at least for arm-v7a.

Brianvdb commented 6 years ago

Seems like a good idea to test this. I just build FFmpeg with --arch=arm --cpu=armv7-a but still getting: using cpu capabilities: ARMv6 NEON

Any idea which FFmpeg compile parameters I should use?

tsoumalis commented 6 years ago

Maybe ffmpeg is built for armv7 but libx264 is not? Check the following for example (64 bit): https://stackoverflow.com/questions/31138836/how-to-build-libx264-64bit-library-for-android

But even without libx264 I believe that ffmpeg built for armv7 and v8 will perform faster in other operations like audio processing. The speed difference is mostly visible with the 64 bit static build from the official site.

Aditya94A commented 6 years ago

Any updates?

tsoumalis commented 6 years ago

I managed to build FFmpeg with ARMv8 enhancement for 64 bit devices but the performance in video encoding/decoding has not been drastically improved. You can use the executables of my fork of this project here: https://github.com/tsoumalis/FFmpeg-Android

These builds show significant improvement though when it comes to audio processing (aac and libmp3lame encodings) and have been built to be small in size so they might lack some features.

The largest performance boost will come when FFmpeg decide to implement mediacodec hardware acceleration. I hope they do so in the near future. For now I see there is a h264_mediacodec encoder and I built these executables with this option enabled but again no performance boost has been noticed.

For now you can use -preset ultrafast -tune zerolatency -threads 0 to extract the most out of the performance in Android when using libx264 to encode.

mwshubham commented 6 years ago

I was hoping for a drastic change in terms of performance when using armV8. Let see when we will get the update from this repo. Thanks

kartik1225 commented 4 years ago

any updates on this?