-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Support AV1 hardware acceleration on Apple M3 and newer #6339
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
Conversation
|
Neither do I, it would be better to test it before merging it. |
|
@galad87 Any chance you can link a build for testing? |
|
There are the GitHub CI builds that can be accessed when logged into GitHub, here's the one for this PR: https://github.com/HandBrake/HandBrake/actions/runs/11204107074?pr=6339 |
|
Ah, right! |
|
@mstorsjo If you feel like testing this one, build linked above (likely need to be logged into GitHub for access). VT decoding can be enabled in preferences, and the activity log for any encode should indicate whether it is used. |
|
I tested this, but I'm actually not quite sure that it does get activated. Here's the activity log from a test transcode: I get near the exact same encoding speed (at around 223 fps) regardless of whether I check or uncheck the "Enable the VideoToolbox hardware decoders" box in settings. The log doesn't really say much about whether it is being used or not, as far as I can see. AV1 is a bit special in the sense that there's no default built-in decoder in libavcodec, but normally you'd use the libdav1d wrapper instead. But if you do hwaccel decoding, it uses the If decoding with This comes from But the log still contains this bit: Anyway, the handbrake log above does contain this bit: So that makes it seem like it possibly doesn't actually enable the hwaccel at all. Regarding decoding speed, so with |
|
Filters can cause fallback to software decoding. Perhaps try disabling cropping, everything on the filters tab, and set the frame rate to same as source variable. |
No notable difference while doing that. I think we'd want a build with a lot more debug printouts around those relevant areas (around hwaccel specific decoder selection), to be able to say anything about what it's doing. |
|
Hardware encoders are disabled by default, there is an option to enable them in the Settings -> Advanced panel. I guess you need the second checkbox too because the Decomb can run only on the CPU, or try one of the VideoToolbox presets that already have all the filters disabled, or maybe it's not actually working? 😅 The activity log will show if the hardware decoder could be used during the scan, and the job configuration something like
when encoding. |
I presume you mean decoders, not encoders here?
In my test above, I did check both boxes.
Right - when opening an AV1 file, I don't get the So my main guess is, as before, the fact that the usually default decoder (libdav1d) doesn't have the hwaccel callbacks/hooks, but to do hwaccel decoding, it requires switching to a different avcodec decoder. Within ffmpeg the command line tool, this switch happens automatically, but it's probably dependent on the actual API usage patterns. |
|
Whoops, right, decoders 😆 |
|
Thanks @mstorsjo, for testing this. Not entirely sure why it did not work for you, but thanks for your detailed explanations. Sadly I have no way to debug this at the moment by myself. |
|
wanted to test on M4 but build artifact: |
|
thanks! |
I now see the same with my new M4 Mac. It works with HEVC, but not with AV1.
Actually I have no idea how to do that, but maybe somebody else has. |
|
Hello, Warning This pull request appears to be inactive and will be automatically closed within 10 days if no further activity is detected. Thank You, |
|
This seems to work in combination with the PR from #6671. I am then seeing
on my M4 Mac if I open and encode an AV1 video file. |
|
Does it work if you use a full HW path? Without software encoders and filters? It should display something like
|
|
Sadly not. Without filters, but with software encoders I get
If I then also disable the software encoders I only get
|
|
Hello @Nomis101, Can you please make build one more time and share instruction how to check on M3 and share results. |
It is about decoding. So if you open an AV1 encoded video file. Not encoding. And at the moment this patch does not work correctly, as is. |
So at the moment there is no chance to add encoding AV1 (videotoolbox) for M3/M4? |
There is sadly no support in M3/M4 for AV1 encoding. |
I've tried today again with the latest master and the two MR and now I am getting: |
|
Still no full HW path, I reworded that line a bit after refactoring some QSV only code. |
|
OK. But its the same syntax I am seeing for H264 or HEVC sources:
And this should definitely work, shouldn't it? |
|
If there isn't any cpu filter, yes. If there is (null) at the end it means it's going from gpu to cpu. |
|
How can I see if there is any cpu filter? |
|
Here's a list of the supported ones #5721 |
|
By the way, if the hardware decoder works, it should just work in the full GPU path if you disable the unsupported filters and use the VideoToolbox encoders. I see no reason for it not working. |
I always disable all filters in my tests. If I in addition use a VT encoder, then I get: |
Will close #5487
This patch did not made it into FFmpeg 7.1 FFmpeg/FFmpeg@f9c5c53
I do not have a Mac with M3, so I can not test (will get an M4 when available, then I could test this).