BtbN / FFmpeg-Builds

MIT License
7.76k stars 1.07k forks source link

`arm` hardware acceleration / NEON (`libx264`) #395

Open strarsis opened 3 months ago

strarsis commented 3 months ago

The current ffmpeg build (from this repository) runs with 30fps on a relatively low-powered ARM Linux system, but with ultrafast preset. Any preset below ultrafast results in much lower fps. How can I find out whether the ffmpeg build indeed uses the arm processor hardware acceleration and NEON for H.264 re-encoding?

Edit: Under /proc/cpuinfo asimd is listed, which should be the same as neon, just the older name for it.

ffmpeg -buildconf does not list --enable-neon flag.

BtbN commented 3 months ago

You'd have to check with x264 folks what kind of acceleration it has for your arch. 30 fps sounds pretty good for software encoding on a potato-class device. There is no point in explicitly passing enable for that, stuff like that is enabled by default.

strarsis commented 3 months ago

@BtbN: Well, before you posted the comment, I manually built ffmpeg on that system, with NEON support explicitly enabled, and indeed, the performance was the same (30fps with ultrafast, 3 to 4 fps with superfast, one step below) as with this ffmpeg build.

My expectations with using ARM/NEON had been a bit higher. In fact, I have really hoped that even a 2-core ARM CPU with NEON extensions allows the realtime re-encoding of a 2K H.264 stream (its flaky data necessitating a re-encode). I think I avoided this workaround now by updating the firmware of the stream source and some changes to the protocol and video-copy settings used.

BtbN commented 3 months ago

Not sure what specific device you got there, but even the latest Raspberry Pis will struggle with any kind of advanced software encoding. Those CPUs are incredibly low power and thus pretty dang slow.

strarsis commented 3 months ago

In this case it is an Amazon EC2 t4g.nano instance (Graviton ARM CPU): https://aws.amazon.com/blogs/opensource/optimized-video-encoding-with-ffmpeg-on-aws-graviton-processors/ The graphs and such look great (notably under the section Live stream encoding), but now I think that nano is a little too small of an SKU for this – or I missed something crucial.

The ffmpeg binary from this repository was installed by following these instructions: https://arthurpello.medium.com/how-to-install-ffmpeg-on-aws-arm-amazon-linux-2023-graviton-c4bc092260bf