Skip to content

Adds support for hardware-accelerated video encoding#30

Open
timothybasanov wants to merge 1 commit intogozoinks:masterfrom
timothybasanov:vaapi
Open

Adds support for hardware-accelerated video encoding#30
timothybasanov wants to merge 1 commit intogozoinks:masterfrom
timothybasanov:vaapi

Conversation

@timothybasanov
Copy link
Copy Markdown

To enable hardware-accelerated video encoding add a new config option:
"vaapiDevice": "/dev/dri/renderD128" (Intel CPU example).
This would pass a new set of options to ffmpeg:
-hwaccel vaapi -hwaccel_output_format vaapi -vaapi_device /dev/dri/renderD128
and it would replace
-c:v libx264 -vf scale=1280:720 -threads 0 -tune zerolatency
with
-c:v h264_vaapi -vf format=nv12|vaapi,hwupload,scale_vaapi=w=720:h=480 -threads 1

Verified to work on Synology NAS DS718+ within Docker environment.
More details https://timothybasanov.com/2018/12/08/hardware-accelerated-h264-encoding-synology-nas.html
Gotchas: One needs to correctly pass devs into docker and give
access to a Homebridge's user.

Additional changes:

  • Support for audio encoding
  • Better logging integration with Homebridge
  • Logs from ffmpeg in Homebridge's logs

@timothybasanov
Copy link
Copy Markdown
Author

I intentionally did not update README, this is a beta feature and I want advanced users to try it first. Not sure how testing is done for this GitHub repo. Hope you can guide me.

To enable hardware-accelerated video encoding add a new config option:
`"vaapiDevice": "/dev/dri/renderD128"` (Intel CPU example).
This would pass a new set of options to ffmpeg:
`-hwaccel vaapi -hwaccel_output_format vaapi -vaapi_device /dev/dri/renderD128`
and it would replace
`-c:v libx264 -vf scale=1280:720 -threads 0`
with
`-c:v h264_vaapi -vf format=nv12|vaapi,hwupload,scale_vaapi=w=720:h=480 -profile:v 578 -bf 0`

Verified to work on Synology NAS DS718+ within Docker environment.
More details https://timothybasanov.com/2018/12/08/hardware-accelerated-h264-encoding-synology-nas.html
Gotchas: One needs to correctly pass devs into docker and give
access to a Homebridge's user.

Additional changes:
 - Support for audio encoding
 - Better logging integration with Homebridge
 - Logs from ffmpeg in Homebridge's logs
@jmbwell
Copy link
Copy Markdown
Collaborator

jmbwell commented Jan 12, 2019

I’m interested in this. I wish we didn’t have to know in advance what device provides DRM for vaapi. I don’t know much about probing for hardware acceleration capabilities. Is there a way to have ffmpeg do the right thing on any system, or are we going to be dependent on configuration, or what?

@glan
Copy link
Copy Markdown

glan commented Jan 17, 2019

Nice! I just about to buy a DS718+. A factor for that model was the possiblity of using hardware acceleration for homebridge-camera-ffmpeg feeds (something that more expensive Atom models lack). So I wondering if a simular change in that project should be made too. I might take a look once I have my device.

@pashdown
Copy link
Copy Markdown

pashdown commented Dec 7, 2019

Would be nice to see this merged. I'd also suggest being able to define scale_vaapi.

@malhal
Copy link
Copy Markdown

malhal commented Jun 13, 2020

How about committing to the original repo instead of this forked one? So hardware encoding can be used on a Synology for any camera.

@NiccoStar86
Copy link
Copy Markdown

Hi everybody, any updates about this useful functionality? Any idea when Homebridge will support the hardware encoding for the cameras? Thank you!

@timothybasanov
Copy link
Copy Markdown
Author

Hey, I've originally created this PR. I would not be able to update this PR anymore.
It would be really nice if somebody would take initiative and merge it either here or upstream.
I'm grateful in advance.

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

Successfully merging this pull request may close these issues.

6 participants