Skip to content
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

Open
Arkelic opened this issue Nov 27, 2023 · 58 comments
Open

Enable AV1 hardware decoding on M3 Apple devices #1125

Arkelic opened this issue Nov 27, 2023 · 58 comments

Comments

@Arkelic
Copy link

Arkelic commented Nov 27, 2023

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

  1. Install Moonlight 5.0.1 on any Apple M3 device
  2. Set up a sunshine host that can hardware encode AV1
  3. In settings, set force hardware decoding, choose AV1 as the video codec

Screenshots
settings
decoding error

Moonlight settings (please complete the following information)

  1. Set force hardware decoding
  2. Choose AV1 as the video codec

Client PC details (please complete the following information)

  • OS: macOS Sonoma 14.1.1
  • Moonlight Version: 5.0.1
  • GPU: Apple M3 Pro

Server PC details (please complete the following information)

  • OS: Windows 11
  • GPU: RTX 4090
  • Sunshine Version: 0.21.0

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/

@cgutman
Copy link
Member

cgutman commented Nov 30, 2023

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.

@Arkelic
Copy link
Author

Arkelic commented Nov 30, 2023

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

@Foul-Tarnished
Copy link

Foul-Tarnished commented Feb 2, 2024

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.

apparently this branch implement AV1 for m3 macs :
jeeb/ffmpeg@2a179d5
WIP avcodec/videotoolbox: add AV1 hardware acceleration

could we build moonlight with this ffmepg patch ? git/cmake/submodules shenanigans 🤔

@Foul-Tarnished
Copy link

Getting 5-6ms at 150mbps HEVC 10 Main HDR with hw decoding forced
Mac M3 Max 10+4 CPU, 30C GPU

isn't it kinda slow ?

@cgutman
Copy link
Member

cgutman commented Feb 6, 2024

@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.

@nenkoru
Copy link

nenkoru commented May 5, 2024

Currently working on sending a patch to ffmpeg. Got this to work.
https://trac.ffmpeg.org/ticket/10642#comment:10

@Foul-Tarnished
Copy link

Foul-Tarnished commented May 6, 2024 via email

@nenkoru
Copy link

nenkoru commented May 6, 2024

♥️

Let me know if you need testing on real mac m3 hw, once you have a build

Le dim. 5 mai 2024, 18:08, Ruslan Chernenko @.***> a

écrit :

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.
Yesterday I pulled the code for the moonlight and going to build it against my patch to see if it works 'as-is'.
Sending the patch to ffmpeg gonna take some time I guess, from review up to an official release(or a commit into a master).
So I guess I would just build a version for a test usage.
Will link a branch if any change to a code will be added.

@nenkoru
Copy link

nenkoru commented May 6, 2024

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.
But yeah, it works 'as-is', no changes needed to the moonlight code.
One thing that I noticed is that I don't see any noticeable difference between hw accelerated vs sw accelerate using libadv1d.
The decoding time per frame is basically +- the same, the energy consumption is the same as well.
Will make a few more tests for this.

updated:
ok no, idk but I suppose my power draw metrics are wrong;
that being said when using hw acceleration the cpu usage of moonlight is significantly less, 20-25%(hwaccel) vs 115-125%(sw libdav1d)
however its worth noting that the decoding time shows the opposite relation
I am getting 4-5ms per frame(1920x1080x60) on sw libadv1d vs 6-7ms per frame on hwacceled
Have no idea why is that at this moment, going to dig a little bit into this.

@nenkoru
Copy link

nenkoru commented May 6, 2024

Here is a link to a branch of mine:
https://github.com/nenkoru/FFmpeg/tree/videotoolbox_av1_nenkoru
You could build it yourself and just copy the libavcodec.61.dylib in place of the one in ./libs/mac/lib after pulling. After that just build the code and it would work.
I could also attach a libavcodec.61.dylib itself or even a built application itself, but I need a clear vote for that.

@andre-ss6
Copy link

andre-ss6 commented Jun 19, 2024

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).

@rramnel
Copy link

rramnel commented Jun 26, 2024

Does AV1 with HDR work on MacBook Pro now? (M3 Pro)

@rramnel
Copy link

rramnel commented Jul 7, 2024

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?

@rramnel
Copy link

rramnel commented Jul 12, 2024

Can anyone check and confirm if AV1 with HDR works on the M3/M3 Pro models?

@andre-ss6
Copy link

Can anyone check and confirm if AV1 with HDR works on the M3/M3 Pro models?

See my last comment above

@Murmur2k
Copy link

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

@nenkoru
Copy link

nenkoru commented Aug 20, 2024

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.
But as I previously stated the performance improvement is barely noticeable between the hardware decoding and using dav1d. Idk why is that.

@Murmur2k
Copy link

Murmur2k commented Aug 26, 2024

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. But as I previously stated the performance improvement is barely noticeable between the hardware decoding and using dav1d. Idk why is that.

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.

@andre-ss6
Copy link

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. But as I previously stated the performance improvement is barely noticeable between the hardware decoding and using dav1d. Idk why is that.

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.

@Murmur2k
Copy link

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. But as I previously stated the performance improvement is barely noticeable between the hardware decoding and using dav1d. Idk why is that.

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?

@andre-ss6
Copy link

andre-ss6 commented Aug 26, 2024

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. But as I previously stated the performance improvement is barely noticeable between the hardware decoding and using dav1d. Idk why is that.

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.

@lk-vila
Copy link

lk-vila commented Sep 7, 2024

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. But as I previously stated the performance improvement is barely noticeable between the hardware decoding and using dav1d. Idk why is that.

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

@carlosresu
Copy link

Here is a link to a branch of mine: https://github.com/nenkoru/FFmpeg/tree/videotoolbox_av1_nenkoru You could build it yourself and just copy the libavcodec.61.dylib in place of the one in ./libs/mac/lib after pulling. After that just build the code and it would work. I could also attach a libavcodec.61.dylib itself or even a built application itself, but I need a clear vote for that.

This works

@carlosresu
Copy link

Here's the libavcodec.61.dylib he mentioned: https://drive.google.com/file/d/1O7NQKJ1owclx7LM1BUVayXvjMZLIeY09/view?usp=sharing

@cgutman
Copy link
Member

cgutman commented Sep 11, 2024

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 lib/libavcodec.61.dylib and lib/libavutil.59.dylib from macos.zip and copy them into the moonlight-qt/libs/mac/lib directory. Delete any preexisting build output from any earlier builds you've done before building with the new libraries. Run Moonlight and force AV1 and report if it is working with hardware decoding.

@Murmur2k
Copy link

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 lib/libavcodec.61.dylib and lib/libavutil.59.dylib from macos.zip and copy them into the moonlight-qt/libs/mac/lib directory. Delete any preexisting build output from any earlier builds you've done before building with the new libraries. Run Moonlight and force AV1 and report if it is working with hardware decoding.

Sure, on it - is that to be tested with the latest stable 6.01 or nightly?

@Murmur2k
Copy link

Murmur2k commented Sep 11, 2024

@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
cd moonlight-qt
git submodule update --init --recursive

copied the two files over

qmake6 moonlight-qt.pro
make release

@andre-ss6
Copy link

andre-ss6 commented Sep 11, 2024

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 lib/libavcodec.61.dylib and lib/libavutil.59.dylib from macos.zip and copy them into the moonlight-qt/libs/mac/lib directory. Delete any preexisting build output from any earlier builds you've done before building with the new libraries. Run Moonlight and force AV1 and report if it is working with hardware decoding.

Building C projects is like learning something new every time

Okay, here are my results:

Client:
MacBook Pro M3 Pro 18GB
macOS Sonoma 14.6.1
XCode 15.4
Qt 6.7.2
moonligh-qt master 67e89d9
Built with the provided libavcodec.61.dylib and libavutil.59.dylib libraries

Native resolution: 3024x1964

Host:
Sunshine 0.23.1, all default settings IIRC
NVIDIA RTX 4090, driver v560.94
Windows 11 23H2
Display settings: 4K HDR10 RGB 10bit 120hz, 100% scaling

Tested over Wi-Fi, same network

Summary: 4K AV1 HW decoding is broken, everything else working with HDR + AV1 HW Decoding 🎉
Details:

Resolution FPS Bitrate(Mbps) Codec Decoder HDR Host HDR Result
4K 60 80 AV1 Force HW Yes Yes ❌ Black Screen
4K 30 40 AV1 Force HW Yes Yes ❌ Black Screen
4K 120 30 AV1 Force HW Yes Yes ❌ Black Screen
4096x2560 60 80 AV1 Force HW Yes Yes ❌ Black Screen
4K 60 80 AV1 Force HW No Yes ❌ Black Screen
4K 60 80 AV1 Force HW No No ❌ Black Screen
Native 60 60 AV1 Force HW Yes Yes ✅ Fully works
Native 120 84 AV1 Force HW Yes Yes ✅ Fully works
1440p 60 40 AV1 Force HW Yes Yes ✅ Fully works
4K 60 80 AV1 Force SW Yes Yes ✅ Fully works
4K 60 80 HEVC Force HW Yes Yes ✅ Fully works

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:

Codec Encoder Decoding time Rendering time
AV1 Force HW 4.5ms 1.9ms
AV1 Force SW 8.5ms 2.9ms
HEVC Force HW 4.8ms 2.0ms
HEVC Force SW 160ms 2.8ms

AV1 HW is almost 2x faster.

@Murmur2k
Copy link

@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

@cgutman
Copy link
Member

cgutman commented Sep 12, 2024

@carlosresu does 4K work with the libavcodec.61.dylib build that you compiled?

@carlosresu
Copy link

carlosresu commented Sep 12, 2024 via email

@carlosresu
Copy link

carlosresu commented Sep 12, 2024

@carlosresu does 4K work with the libavcodec.61.dylib build that you compiled?

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.

@Murmur2k
Copy link

Murmur2k commented Sep 12, 2024

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.

@jmalexan
Copy link

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.

@cgutman
Copy link
Member

cgutman commented Sep 21, 2024

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)

New build: https://ci.appveyor.com/project/cgutman/moonlight-deps/builds/50647418/job/vt2o7rawhthqqn82/artifacts

@Murmur2k
Copy link

Murmur2k commented Sep 21, 2024

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)

New build: https://ci.appveyor.com/project/cgutman/moonlight-deps/builds/50647418/job/vt2o7rawhthqqn82/artifacts

Just tested and it was the same behaviour as before.. any x-axis resolution at or above 1986 results in a black screen

@jmalexan
Copy link

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.

@cgutman
Copy link
Member

cgutman commented Sep 23, 2024

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 /tmp folder on your Mac.

@jmalexan
Copy link

Here ya go

Moonlight-1727121984.log

@Murmur2k
Copy link

Murmur2k commented Sep 23, 2024

One more sample log file when attempting native resolution of 3456x2234 (black screen):
Moonlight-1727126296.log

Another at 4K (black screen)
Moonlight-1727126434.log

One below 1985 x pixels (doesn't result in a black screen)
Moonlight-1727126524.log

@cgutman
Copy link
Member

cgutman commented Sep 27, 2024

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)

@andre-ss6
Copy link

andre-ss6 commented Sep 27, 2024

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?

@jmalexan
Copy link

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.

Moonlight-1727450098.log

@Murmur2k
Copy link

Also able to confirm the latest version works, thank you

@cgutman
Copy link
Member

cgutman commented Sep 28, 2024

PS.: out of curiosity, what was the issue with ffmpeg?

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

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.

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.

@TFMasterFlowHub
Copy link

TFMasterFlowHub commented Oct 8, 2024

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:
Finally able to figure out by myself (Thanks to @Murmur2k).
For anyone looking for same. Please follow this command in terminal.

  1. git clone https://github.com/moonlight-stream/moonlight-qt.git

  2. cd moonlight-qt

  3. git submodule update --init --recursive

  4. copied the two files over from this link only, as it contain last update from @cgutman (other versions doesn't work)
    https://ci.appveyor.com/project/cgutman/moonlight-deps/builds/50685992/job/gtjfnhhetm4yc3uv/artifacts

  5. qmake6 moonlight-qt.pro (need qmake to be installed separately)

  6. make release

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).
Stats:
Rendering Time: 1.49 - 2.05 ms, Avg: 1.80 ms
Decoding Time: 4.5ms

@TungAn
Copy link

TungAn commented Oct 31, 2024

hi @TFMasterFlowHub can you share the libs file, the link above + Artifacts got deleted so cannot obtain this. Many thanks

@andre-ss6
Copy link

@cgutman is there any ETA for this arriving on the official moonlight client release?

@cgutman
Copy link
Member

cgutman commented Nov 3, 2024

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

@kasimok
Copy link

kasimok commented Nov 26, 2024

I am getting 4-5ms per frame(1920x1080x60) on sw libadv1d vs 6-7ms per frame on hwacceled

FYI: Latest M4 Max decodes 8K HDR AV1 video with 10% cpu usage, compared to the 400% cpu usage with libdav1d.

@sofakng
Copy link

sofakng commented Dec 11, 2024

I've tried the latest artifact but it doesn't seem to be working...? (r2673?)

@duracell
Copy link

Same here, not working with r2675 on a MacBook Pro M4 Pro.
Hardware decoding only gives the usual error messages about missing hardware support for HW decoding (with and without HDR).

@carlosresu
Copy link

carlosresu commented Dec 16, 2024

Hi guys

@duracell

Same here, not working with r2675 on a MacBook Pro M4 Pro. Hardware decoding only gives the usual error messages about missing hardware support for HW decoding (with and without HDR).

@sofakng

I've tried the latest artifact but it doesn't seem to be working...? (r2673?)

Try my fork carlosresu/moonlight-qt-carlosresu. I am getting same error with 2675.
image

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
Here's the latest one I built just now (12:30 AM UTC time Dec 16, 2024), works with AV1 HDR on M3 base model. Works (tested) until 4K60).
image (Bad internet at the office sorry, but it works up to 120hz that I tested) In case you can't/don't want to clone/build yourself. See virustotal here: virustotal of Moonlight.app.zip

Simply

  1. clone carlosresu/moonlight-qt-carlosresu,
  2. cd into it,
  3. make sure to run git submodule update --init --recursive,
  4. run ./build.sh
  5. it should build and copy Moonlight.app into your Applications folder.

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?

@gnattu
Copy link

gnattu commented Dec 19, 2024

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.

@ClassicOldSong
Copy link

Just got my hands on a M4 Mac mini, thank you @gnattu for the just in time build!

@carlosresu
Copy link

Thanks for the feedback @gnattu !

@pmffromspace
Copy link

Am I missing something or is it expected to not work on M1? @gnattu

@gnattu
Copy link

gnattu commented Dec 22, 2024

Am I missing something or is it expected to not work on M1? @gnattu

Apple only implemented AV1 hardware decoder on M3 and later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests