-
Notifications
You must be signed in to change notification settings - Fork 649
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
Enable AV1 hardware decoding on M3 Apple devices #1125
Comments
We use FFmpeg for video decoding, and it doesn't yet support AV1 decoding using the macOS VideoToolbox API yet. Once it does, we can pull in the new version and it will just work without any work from us. |
Thanks, just found the ticket (10642) where FFmpeg is tracking this. I’ll keep an eye on the progress there and comment here again when they’ve added that feature to a release |
apparently this branch implement AV1 for m3 macs : could we build moonlight with this ffmepg patch ? git/cmake/submodules shenanigans 🤔 |
Getting 5-6ms at 150mbps HEVC 10 Main HDR with hw decoding forced isn't it kinda slow ? |
@Foul-Tarnished We build our own FFmpeg, so we can include custom patches if we want. However, I never saw confirmation anywhere that the changes mentioned in that branch actually worked. I just saw that one report of a crash and no users reporting working AV1 decoding. |
Currently working on sending a patch to ffmpeg. Got this to work. |
Currently working on sending a patch to ffmpeg. Got this to work.
https://trac.ffmpeg.org/ticket/10642#comment:10
—
Reply to this email directly, view it on GitHub
<#1125 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AZVYVBRNSPNIZXD7B52PNHTZAZKOLAVCNFSM6AAAAAA74WIJ42VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJUHA3DEOJXGQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Yeah, okay. |
Got this to work in moonlight, however needed to do a little hack on ffmpeg's side. Need to take into account a few things in terms of copying sequence header obu into the config format of VT. updated: |
Here is a link to a branch of mine: |
Hey, has this been merged? Just the other day I was trying this out and getting the message saying that the software decoder would be used instead; Today, however, I got a different message, saying that my GPU did not support AV1 Main10 HDR streaming. The stream then started with AV1, but without HDR on the client (image was blown out due to HDR/SDR mismatch). Is that really the case? Will HDR over AV1 not be supported on M3 devices? I'm using Moonlight 6.0.0 on a Macbook Pro (M3 Pro). |
Does AV1 with HDR work on MacBook Pro now? (M3 Pro) |
I read that AV1 decoding (with HDR support) on Moonlight is supported on iPhone Pro 15 as well as the new M4 iPad Pro. Will it also be released for the M3 Pro macOS version? |
Can anyone check and confirm if AV1 with HDR works on the M3/M3 Pro models? |
See my last comment above |
Has there been any progress on implementing M3 AV1 support? When I try with the current build it refuses to allow hardware decoding with or without HDR enabled. I had to build Moonlight manually from here owing to being on the MacOS beta: #1355 @nenkoru please could you share your libavcodec.61.dylib or provide some more detail on the process for somebody with little experience in compiling, thanks |
I still didn't have time to file a proper patch to ffmpeg's upstream. Either someone could file it for me, I will provide with patches(or just try to find in ffmpeg's issue tracker). Or just wait for me, I am almost back to filing a patch one more time to ffmpeg's upstream. |
That does sound strange. My iPhone 15 Pro Max (different hardware albeit similar processor) seems to handle AV1 with Moonlight really well though the exact performance isn't shown in the stats. |
The bandwidth usage should be lower at least, no? I wanted to use AV1 mostly for the decrease in bandwidth usage, however, as I said in a previous comment, currently choosing AV1 + HDR in moonlight on a M3 Pro Macbook causes issues, namely the HDR is improperly handled and shows up like a overexposed SDR image. AV1 + SDR works correctly, as does H264 + HDR. |
Which version are you using - the latest release or a different build? |
Latest release for both the moonlight client (6.0.1) on the Macbook Pro (also latest macOS stable public build) and latest sunshine release (0.23.1) on Windows host (Windows 23H2) Edit: Just tested connecting with AV1 + HDR to that same host with Moonlight v9.0.2 on my Iphone 15 Pro Max and it does work correctly. |
I'm on a similar situation. Moonlight client (6.0.1) on a M3 Macbook Pro connecting to Sunshine (2024.809.202917.copr) on Fedora Linux host. I get a washed out SDR image when trying AV1 + HDR, and moonlight says something in the lines of "This PCs GPU doesn't support AV1 Main10 decoding for HDR video". Using Moonlight (12.1) on my Galaxy S23 I'm able to stream AV1 + HDR, no problem |
This works |
Here's the libavcodec.61.dylib he mentioned: https://drive.google.com/file/d/1O7NQKJ1owclx7LM1BUVayXvjMZLIeY09/view?usp=sharing |
I have applied patches from that branch onto our FFmpeg, but I need someone with an M3 Mac to verify it works before I can ship it in the next release. The build is here: https://ci.appveyor.com/project/cgutman/moonlight-deps/builds/50578163/job/enfwy81blmqtuhc2/artifacts Please extract |
Sure, on it - is that to be tested with the latest stable 6.01 or nightly? |
@cgutman I compiled using the below and I'm afraid with AV1 enabled I get a black screen (though the connection is made as I can hear sound) - please let me know how you would like me to debug git clone https://github.com/moonlight-stream/moonlight-qt.git copied the two files over qmake6 moonlight-qt.pro |
Okay, here are my results: Client: Native resolution: 3024x1964 Host: Tested over Wi-Fi, same network Summary: 4K AV1 HW decoding is broken, everything else working with HDR + AV1 HW Decoding 🎉
In all cases where I encountered a black screen, sound and input still worked -- only rendering that didn't. I also tested the performance difference. These are some rough average estimates for ~4K(3024x1924)@60fps, bitrate 80Mbps, HDR10:
AV1 HW is almost 2x faster. |
@andre-ss6 ah yes good spot, for lower resolutions I get the same outcomes on an M3 Max. Native res (3456x2234) or 4K results in black screen. Lower resolutions and both HDR/normal works fine with good performance |
@carlosresu does 4K work with the libavcodec.61.dylib build that you compiled? |
I haven't tried 4K but I can later
…________________________________
From: Cameron Gutman ***@***.***>
Sent: Thursday, September 12, 2024 1:42:59 PM
To: moonlight-stream/moonlight-qt ***@***.***>
Cc: Carlos Miguel Resurreccion ***@***.***>; Mention ***@***.***>
Subject: Re: [moonlight-stream/moonlight-qt] Enable AV1 hardware decoding on M3 Apple devices (Issue #1125)
@carlosresu<https://github.com/carlosresu> does 4K work with the libavcodec.61.dylib build that you compiled?
—
Reply to this email directly, view it on GitHub<#1125 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/BJOPULGTNV42S53XXS2TXKTZWESWHAVCNFSM6AAAAAA74WIJ42VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNBVGMYTSNRUGE>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
4K doesn't work either, sound and mouse and keyboard work. Highest resolution that works for me is native. 3024x1964. Note that I don't own a 4K display, so maybe it's that? Enabling HDR but having HDR off in Windows leads to 4x lower decoding time, as opposed to HDR off in moonlight + HDR off in windows. |
It appears to be only the x-axis pixel size causing the black screen - anything at or above 1986 pixels vertical results in the blacksreen. Y-axis I can put anything without impact. |
I tested the provided builds on my MacBook while hooked up to an external 4K display, still a black screen. If I set the resolution to the native resolution, I was able to get it to work, as previously reported. Seems a 4K display connected doesn't affect what does or doesn't work. |
Another version of the AV1 support patch was posted on the FFmpeg-devel mailing list, so I'd appreciate another round of testing. I'll report the results to the patch developer. Steps to test are the same as in: #1125 (comment) |
Just tested and it was the same behaviour as before.. any x-axis resolution at or above 1986 results in a black screen |
I can confirm black screens as well for me. The built-in screen's native resolution works, as well as 1080p and 720p, but 1440p and 4k do not work. |
Can you post the Moonlight log file from your attempts to stream 4K with AV1 using the last test build? The log files are located in the |
Here ya go |
One more sample log file when attempting native resolution of 3456x2234 (black screen): Another at 4K (black screen) One below 1985 x pixels (doesn't result in a black screen) |
Thanks, I believe we've figured out the issue and an FFmpeg developer has posted a new patch. Please give this new build one last try with both low-res and high-res streams: https://ci.appveyor.com/project/cgutman/moonlight-deps/builds/50685992/job/gtjfnhhetm4yc3uv/artifacts Steps to test are the same as in: #1125 (comment) |
Working like a charm 😙 I have the impression there was a slight perf regression (+~0.5ms decoding time 4K60 HW AV1 HDR10 80Mbps), but that might just be my flawed methodology (or the recent macOS update). 🚀 PS.: out of curiosity, what was the issue with ffmpeg? |
This does solve the black screen issue! I tested at 4k240 with 150 bitrate and it worked flawlessly. I did also see a slight decode increase vs HEVC as well. One problem I ran into, I've been using the unlocked bitrate option with HEVC to stream 500mbps bitrate for a bit, doing this with AV1 caused significant issues where playback would "jump" forward a few times a second, looking like pretty intense stutter. I captured a log of this for the records, but I'm assuming this is a performance limitation of the hardware decoder. |
Also able to confirm the latest version works, thank you |
NVENC was producing a different bitstream depending on the resolution. I believe it is related to the split frame encoding support where the driver can utilize both NVENC units together on a single stream if it decides that's worthwhile. The result is a change in the number of tiles in the frame, which changed the bitstream in a way that was causing some data to be missed when submitting a frame to VideoToolbox. More details are in the thread here: https://ffmpeg.org/pipermail/ffmpeg-devel/2024-September/333720.html
Yeah, it looks like the AV1 decoder cannot keep up with the selected bitrate. Decode time is over 40 ms, which is extremely high for VideoToolbox. It's possible that the AV1 decoder on the M3 can't handle as high of bitrate as the HEVC decoder can. |
Can someone please help me break it down in steps on how to do this on MacOS. Window user, recently switched to MacBook. Using Moonlight v6.0.1 and getting the same AV1 not supported on this PC error. MacBook Pro M3 Pro client, Host 4070. Help would be highly appreciated. EDIT:
You will find the application in Launchpad or can navigate to moonlight-qt/apps/Moonlight.app to execute from there. Working for Native - 120FPS + AV1 + Force HW decoding + HDR (On + in Windows). |
hi @TFMasterFlowHub can you share the libs file, the link above + Artifacts got deleted so cannot obtain this. Many thanks |
@cgutman is there any ETA for this arriving on the official moonlight client release? |
The updated FFmpeg library with VideoToolbox AV1 decoding is already merged, so nightly builds already contain the change: https://ci.appveyor.com/project/cgutman/moonlight-qt/branch/master |
FYI: Latest M4 Max decodes 8K HDR AV1 video with 10% cpu usage, compared to the 400% cpu usage with libdav1d. |
I've tried the latest artifact but it doesn't seem to be working...? (r2673?) |
Same here, not working with r2675 on a MacBook Pro M4 Pro. |
Hi guys
Try my fork carlosresu/moonlight-qt-carlosresu. I am getting same error with 2675. My fork works. It uses the latest FFmpeg version from the FFmpeg github, along with the AV1 fixes I picked up along the way. Then builds moonlight with said fixes. I can't for the life of my remember who made the AV1 FFmpeg patch that I incorporated into my FFmpeg fork, I'm sorry. Both repos are open source though. (Might've been @nenkoru via nenkoru/FFmpeg/tree/videotoolbox_av1_nenkoru) Moonlight.app.zip Simply
I only have an M3 base model though, not an M4. Let me know if it works. Sorry if it's badly coded, I only used ChatGPT. I tried my best to automate the process of pulling the latest changes from both moonlight-qt master repo and FFmpeg master repo. @Moderators sorry if posting a file is not allowed. P.S. how do I make GitHub run build.sh and post the .app file as a .dmg in the releases section of my fork? |
Late to the party, but I compiled a release version based on release 6.1.0 and linked against jellyfin-ffmpeg, which already enabled av1 hardware decoding for M3 series and later: https://github.com/gnattu/moonlight-qt/releases/tag/jellyfin-ffmpeg This build should be portable and you can download and run just on your machine. Also another friendly note to @carlosresu, your build is not self-contained and it dynamically links some libraries only on your local machine, so the uploaded tarball is not run-able on someone else's computer. |
Just got my hands on a M4 Mac mini, thank you @gnattu for the just in time build! |
Thanks for the feedback @gnattu ! |
Am I missing something or is it expected to not work on M1? @gnattu |
Apple only implemented AV1 hardware decoder on M3 and later. |
Describe the bug
Hardware AV1 decoding does not work on M3 Apple devices and defaults back to software decoding if set to automatic
Steps to reproduce
Screenshots
Moonlight settings (please complete the following information)
Client PC details (please complete the following information)
Server PC details (please complete the following information)
Additional context
Apple added AV1 hardware decode support to M3 devices: https://www.apple.com/newsroom/2023/10/apple-unveils-m3-m3-pro-and-m3-max-the-most-advanced-chips-for-a-personal-computer/
The text was updated successfully, but these errors were encountered: