# “Apple VT H264 Hardware Encoder" unlocked for Apple Silicon M1



## RustySly (Feb 1, 2021)

hey guys, i've been using macbook air m1 16gb for a couple of weeks for streaming and i am generally happy with the performance, m1 is an absolute beast. but, the "x264" encoding in obs' current state (lack of m1 compatibility) leaves a lot to be desired. it's almost impossible to stream at 1080p 60fps with a good quality and hardware encoding is unavailable, so i've been waiting for the arm compatibility patch.

today, i was on discord and saw an issue on github containing a fix for obs to allow using the "apple vt h264 hardware encoder". i built the obs with required changes and managed to unlock the hardware encoding! so far, great performance.

you can see the code here, all credit to polamjag and sharkyrawr: Apple VT H264 Hardware Encoder not available in Apple Silicon (M1) MacBook Pro · Issue #4170 · obsproject/obs-studio · GitHub

i'll attach the "mac-vth264.so" zip file, all you gotta do is replace it with the one in the folder "obs>contents>plugins". of course this is a temporary solution but i thought you could try it for yourself and test it. i don't know if it's ok to share such a file, if not please remove :)


----------



## itrends (Feb 1, 2021)

THANK YOU SO MUCH! Going to try this right now.


----------



## itrends (Feb 1, 2021)

RustySly said:


> i'll attach the "mac-vth264.so" zip file, all you gotta do is replace it with the one in the folder "obs>contents>plugins". of course this is a temporary solution but i thought you could try it for yourself and test it. i don't know if it's ok to share such a file, if not please remove :)



What other settings are you using? Would you mind posting your full recording and streaming config at all? E.g. the profile... are you using baseline etc


----------



## itrends (Feb 1, 2021)

Update : I closed OBS. It 'crashed' after closing. Now when trying to launch it just bounces forever. Suspect this may not be ready to use. :(

UPDATE 2: Logged out. Logged in and it booted again. Presently unsure if related but leaving this here in case others see the same.


----------



## Bada (Feb 4, 2021)

I've tested it on a M1 Mac mini and it seems to be working, but you actually can't stream to Twitch or Youtube. I'm not sure what the problem is. I was able to record it btw. Can you upload the full build of OBS? Here's what Twitch say on the Inspector:


----------



## thmsdj (Feb 4, 2021)

Bada said:


> I've tested it on a M1 Mac mini and it seems to be working, but you actually can't stream to Twitch or Youtube. I'm not sure what the problem is. I was able to record it btw. Can you upload the full build of OBS? Here's what Twitch say on the Inspector:View attachment 66910


Yeah, I have the same issue. It seems that it somehow can't lock the bitrate :( Hopefully there will be a fix soon. Can't wait to get my M1 Air streaming some sweet 1080p video.


----------



## maximilianmuc (Feb 4, 2021)

RustySly said:


> i'll attach the "mac-vth264.so" zip file, all you gotta do is replace it with the one in the folder "obs>contents>plugins". of course this is a temporary solution but i thought you could try it for yourself and test it. i don't know if it's ok to share such a file, if not please remove :)




Thank you for this post?

I am new to the Mac.
For those who do not know where to put the file:

.so is a plugin file.

In Finder, go to "Applications", then to OBS Control+click (right-click), view package contents: There then Contents/PlugIns. There is already such a file, overwrite it - but maybe save it first...


----------



## Bada (Feb 4, 2021)

Tested again using a custom rtmp server:

Apple VT Hardware encoder -> NGINX RTMP server -> restream it to Twitch is working. There's no additional encoding process at all, So I don't think this is a bitrate problem.






(Incompatible is normal for VT encoder)


----------



## Bada (Feb 5, 2021)

Never mind, It seems VT hardware encoder can't send the audio source.


----------



## Koen Willems (Feb 14, 2021)

I was thinkering: considering the architecture of the Apple Silicon M1, is there really a difference between software or hardware encoding at all?


----------



## Yangtse (Feb 17, 2021)

RustySly said:


> i'll attach the "mac-vth264.so" zip file, all you gotta do is replace it with the one in the folder "obs>contents>plugins". of course this is a temporary solution but i thought you could try it for yourself and test it. i don't know if it's ok to share such a file, if not please remove :)


This is genius, man! Thanks a mille! Worked right from the start and reduced CPU load on my MB Air from around 50% to less than 10%! Even streaming to youTube in 1440p60 worked like a charm. This is the future. I hope that the OBS developer community will soon integrate it into an official release (can't be that hard since the essential coding has obviously been done already. A big hand to those guys!)


----------



## komplik (Feb 22, 2021)

RustySly said:


> i'll attach the "mac-vth264.so" zip file, all you gotta do is replace it with the one in the folder "obs>contents>plugins". of course this is a temporary solution but i thought you could try it for yourself and test it. i don't know if it's ok to share such a file, if not please remove :)



HI, great stuff. It works great, just tried it to record some footage. I was able to record smooth 1080p with x264 superfast, so poor overall quality and my MBA was throttling with mostly 100°C. With HW acceleration I can use it to record 1080p with higher quality and low CPU utilization and after hour it averages at 60°C.


----------



## Bada (Feb 23, 2021)

idk why but it works now… did you update the file?


----------



## rd1 (Feb 23, 2021)

Bada said:


> idk why but it works now… did you update the file?


@Bada
It will not record audio If you set checkmark "Limit bitrate" in advanced output settings.
Without checkmark audio is recorded properly.
Also I have not tested streaming yet, only recording.

@RustySly 
Thank a lot for this fix! You are awesome!


----------



## vicantu (Feb 23, 2021)

Thanks @RustySly ! 

I have a Mac Mini with the silicon M1, 16 GB Ram and 512 GB SSD, I am using elgato cam-link 4K USB connected to a Sony a6400 at 10p 60fps, for my case, I just need to record locally the video produced by the last version of OBS, not streaming for the moment.

The problem I have after using your solution is that if I select Apple VT H264 Hardware Encoder no matter which bitrate I selected for Recording (I used 10,000 20,000 and 30,000 kbps for example), the MOV file generated is huge because it do not respect the bitrates I selected, I can see the bitrate inside the file is on the hundred of thousands.

This is normal with this "hack" or there is something I can do?

thanks


----------



## JonesTheHulk (Feb 23, 2021)

This is awesome! Replaced in the plugin folder and works perfectly on the Macbook Pro M1 2020. Streaming Warzone in a bit so we shall see how we get on! :)


----------



## Bada (Feb 24, 2021)

rd1 said:


> @Bada
> It will not record audio If you set checkmark "Limit bitrate" in advanced output settings.
> Without checkmark audio is recorded properly.
> Also I have not tested streaming yet, only recording.
> ...



Oh Thanks for the information, yeah. It seems you have to uncheck the "limit bitrate" option for now.


----------



## CKayJr (Mar 1, 2021)

I am streaming and recording LIVE to Facebook w/a Sony 4K cam, HQ HDMI cable (15 ft) to BMG UltraStudio 3G, TB3 to 16" MBP, i9/32GB RAM/8GB Video Card. This is for a live church service. Cam is about 60-70 feet away in balcony. 20X optical zoom. I am using VT H264 hardware encoding for stream. CPU resources is 10% or lower. I am streaming and recording at same time. Don't have the hardware option for encoding on the record settings. However, my video is not smooth, looks like it is dropping frames like 1 of every 2 or so with visual motion (a tad jerky, but not terrible). But driving me nuts! Cam is on a rock solid Monfretto tripod. My actual encoded stream or recording is not showing hardly any dropped frames. It is the actual capture or throughput to the MBP that seems to be the problem. I have both Cam and OBS set to 1080/30p. I have the Sony cam steady-shot feature set to off (thinking it was messing w/video). Could it be an exposure issue w/cam set to auto? Also, what should my keyframe interval be for recording? I'm including some screenshots. Tell me what I need to fix! I really need some help. Thx!!


----------



## BenMitchell (Apr 25, 2021)

Hello! I have just recompiled OBS for apple silicon using the latest code from the master branch on the OBS GitHub. I've also added the virtual camera to the build too. 

You will need qt@5 and ffmpeg installed to use it:
`brew install qt@5 ffmpeg`

In order to open it you will have to right click and press open, you might have to do this twice because the build is not signed or notarised. 

Download: link


----------



## kellemar (May 8, 2021)

BenMitchell said:


> Hello! I have just recompiled OBS for apple silicon using the latest code from the master branch on the OBS GitHub. I've also added the virtual camera to the build too.
> 
> You will need qt@5 and ffmpeg installed to use it:
> `brew install qt@5 ffmpeg`
> ...



I'm getting these errors when I try to start a stream using your M1 build. Any ideas?

13:58:24.216: 
13:58:26.072: Output 'adv_stream': Tried to set a delay value on a non-encoded output
13:58:26.072: Stream output type 'rtmp_output' failed to start!


----------



## kellemar (May 8, 2021)

BenMitchell said:


> Hello! I have just recompiled OBS for apple silicon using the latest code from the master branch on the OBS GitHub. I've also added the virtual camera to the build too.
> 
> You will need qt@5 and ffmpeg installed to use it:
> `brew install qt@5 ffmpeg`
> ...


----------



## XDR (May 11, 2021)

The hardware acceleration of the M1 chip is fantastic! Has anyone had luck with the hevc_videotoolbox encoder in Custom Output? it records fine and opens in VLC and IINA but isn't read natively by macOS 11 or QuickTime Player 10.5. I'm not sure why since the M1 natively encodes/decodes HEVC/h.265.


----------



## T0ni (May 14, 2021)

Hi there!
Thanks for all your input; incredibly good.
I am new on M1 too, 16GB RAM, 8 core
I used to use OBS on my old PC and also on Mac Intel as source for Zoom and to record stuff.
---
NOW, even without trying to stream, just to record, I have the following issues which might fit this thread, hopefully:

1.
CPU is at 300-450%. >> I read somewhere else this is due to using 3-4 cores in this case.
Why is it that high?

2.
To capture external cams and mics and sound sources >> no problem
To Capture whole display >> no problem
To "Window capture" BIG problem >> the window-video presented in OBS is jerky / delayed / not smooth.

Any ideas? To me this seems to be a similar problem due to ARM of M1 ?!

I installed / changed the above plugin, just to give it a try, but nothing changed (of course, somehow)

Any help is welcome. Thanks again to everyone in here!

Toni


----------



## KayneGiordano (May 17, 2021)

T0ni said:


> Hi there!
> Thanks for all your input; incredibly good.
> I am new on M1 too, 16GB RAM, 8 core
> I used to use OBS on my old PC and also on Mac Intel as source for Zoom and to record stuff.
> ...



Hi ! Don't you have fluidity/smooth issues with a capture card? Personally, I have the same concern as you with and without a capture card, but apparently it is because OBS is not yet natively supported in ARM. To have been able to test Wirecast and Ecamm natively, it's much better :(


----------



## T0ni (May 18, 2021)

KayneGiordano said:


> Thx for your kind help.
> Meanwhile I figured out how to solve it for myself, even I do not understand why that helped.
> I had the open project and a camera-app called Camo usung iPhone as a source BUT iPhone was not connected at that point. >> so far the problems mentioned
> After connecting iPhone CPU went down to about 8% within OBS.
> ...


----------



## JonesTheHulk (Jun 23, 2021)

Is there an updated file for use? Since the latest 27.0.1 hot fix I can no longer activate a stream to Twitch? Receive the following error with the file replaced in the plugins which is the same error received with original mac-vth264.so file.


----------



## StrayTexel (Aug 20, 2021)

EDIT: Please disregard. 

For anyone else with this issue, the HW encoder is HIDDEN BEHIND THE ADVANCED MENU. 


--

I just got a new M1 Mini and tried this today. Now running natively-M1-compiled version of obs: OBS 27.0.1-169-g94009535c-modified (mac)

Using the attached file from @RustySly it's* still telling me that it's compiled for the wrong arch.*


```
19:21:02.245: [mac-virtualcam] version=1.3.0
19:21:02.245: os_dlopen(../obs-plugins/mac-vth264.so->../obs-plugins/mac-vth264.so): dlopen(../obs-plugins/mac-vth264.so, 257): no suitable image found.  Did find:
19:21:02.245:     /Applications/OBS.app/Contents/Resources/bin/../obs-plugins/mac-vth264.so: mach-o, but wrong architecture
19:21:02.245:     /Applications/OBS.app/Contents/Resources/bin/../obs-plugins/mac-vth264.so: mach-o, but wrong architecture
19:21:02.245:     /Applications/OBS.app/Contents/Resources/bin/../obs-plugins/mac-vth264.so: mach-o, but wrong architecture
19:21:02.245:     /Applications/OBS.app/Contents/Resources/bin/../obs-plugins/mac-vth264.so: mach-o, but wrong architecture
19:21:02.245:     ../obs-plugins/mac-vth264.so: mach-o, but wrong architecture
19:21:02.245:     /Applications/OBS.app/Contents/Resources/obs-plugins/mac-vth264.so: mach-o, but wrong architecture
19:21:02.245:
19:21:02.245: Module '../obs-plugins/mac-vth264.so' not loaded
```

As a sanity check, to make sure it was looking at the right lib I deleted the lib entirely and the error went away.

Anyone have any ideas?


----------



## DapperDan (Dec 2, 2021)

kellemar said:


> I'm getting these errors when I try to start a stream using your M1 build. Any ideas?
> 
> 13:58:24.216:
> 13:58:26.072: Output 'adv_stream': Tried to set a delay value on a non-encoded output
> 13:58:26.072: Stream output type 'rtmp_output' failed to start!



Excuse me if there is a fix for this already 

But having this same error logs using the M1 build

Installing latest release of OBS(rosetta install) and using with the same h/w capture devices streams starts 

@kellemar, have you been able to resolve this?


----------

