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

Add Intel Quick Sync Support #753

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Add Intel Quick Sync Support #753

wants to merge 9 commits into from

Conversation

mitchross
Copy link

@mitchross mitchross commented Mar 28, 2023

#736

'ffmpeg -loglevel verbose -hwaccel qsv -c:v h264_qsv -i - -c:v copy -c:a copy -rtsp_transport tcp -f rtsp rtsp://0.0.0.0:8554/{cam_name}'

image

@mrlt8
Copy link
Owner

mrlt8 commented Mar 31, 2023

@mitchross is hwaccel_output_format needed in the ffmpeg command? I want to update the h264_enc env option so that it would work with H264_ENC=h264_qsv.

@mitchross
Copy link
Author

@mitchross is hwaccel_output_format needed in the ffmpeg command? I want to update the h264_enc env option so that it would work with H264_ENC=h264_qsv.

Not sure it yelled at me when I ran it and said it would be deprecated. I updated comment....

Also I think the current hw version works with quick sync, I just had the wrong command passed. Now I used

          value: 'ffmpeg -loglevel verbose -hwaccel qsv -c:v h264_qsv -i - -c:v copy -c:a copy -rtsp_transport tcp -f rtsp rtsp://0.0.0.0:8554/{cam_name}'

One thing to note, this PR does let you use "intel_gpu_top" which lets you monitor gpu usage.

So I'm not sure now if this PR is needed, but take what you want out of it. I am however running this PR version in my home lab things are going great.

@mitchross
Copy link
Author

@mrlt8 rotate cam seems to break with these args tho...

@mrlt8
Copy link
Owner

mrlt8 commented Apr 2, 2023

Are you using some variant of FFMPEG_CMD? That will override all other ffmpeg commands including the rotation or recording options.

Ideally, it should work with H264_ENC=h264_qsv so that the other commands are still recognized.

@mitchross
Copy link
Author

Are you using some variant of FFMPEG_CMD? That will override all other ffmpeg commands including the rotation or recording options.

Ideally, it should work with H264_ENC=h264_qsv so that the other commands are still recognized.

I -think- this is working for me... need to run a few more tests

@mitchross
Copy link
Author

Ok so "H264_ENC=h264_qsv" does work, my PR adds in intel_gpu_top if you wanted to parse for stats.

This is what frigate does

@BeardedTek
Copy link

BeardedTek commented Apr 11, 2023

I wonder if this could be applied to non qsv video. For example, I use intel-va-api on frigate which significantly reduces CPU usage. (I went from 300% cpu to 40-50%)

It does appear the drivers are there in this image as well.

I'm going to try this out and see if I can come up with an elegant configuration and command for ffmpeg qsv and vaapi for both amd and intel cards.

@mitchross
Copy link
Author

HW acceleration has stopped working for me. Any ideas? let me know commands/logs you want!

@mrlt8
Copy link
Owner

mrlt8 commented May 31, 2023

Nothing has really changed RE: ffmpeg or encoding. Could it be a local issue? May want to run with DEBUG_FFMPEG to see if ffmpeg is throwing any errors?

@calimansi
Copy link

This doesn't work for me. Is there a way to get intel acceleration going again?

@carldanley
Copy link

Are you using some variant of FFMPEG_CMD? That will override all other ffmpeg commands including the rotation or recording options.

Ideally, it should work with H264_ENC=h264_qsv so that the other commands are still recognized.

re: @mrlt8

I was wondering about hardware acceleration for intel and found this PR. I pulled down dev-qsv tag and added the environment variable H264_ENC=h264_qsv. In the debug logs, I see:

[vist#0:0/h264 @ 0x55a364c33fc0] WARNING: defaulting hwaccel_output_format to qsv for compatibility with old c │
│ Selecting decoder 'h264_qsv' because of requested hwaccel method qsv

All 8 of my Wyze Cam Pro v3's appear to be working correctly. I've definitely noticed a significant decrease in latency (it's hard for me to attribute it directly to this but "it definitely feels faster").

I tried to install intel_gpu_top in the container and all I get is: Failed to initialize PMU! (Operation not permitted). I even tried adding the CAP_PERFMON capability to the container and still can't get it to work. However, frigate does come bundled with that tool and it's really nice for me to exec into the container and see that frigate is taking advantage of hardware acceleration.

It would be really nice if we could have that tool available for docker-wyze-bridge as well. I'm "pretty sure" it's working cause I didn't get any errors or anything but hard to tell.

@carldanley
Copy link

I tried to install intel_gpu_top in the container and all I get is: Failed to initialize PMU! (Operation not permitted). I even tried adding the CAP_PERFMON capability to the container and still can't get it to work. However, frigate does come bundled with that tool and it's really nice for me to exec into the container and see that frigate is taking advantage of hardware acceleration.

I got intel_gpu_top working by adding SYS_ADMIN capability (don't do this, not a good practice). I was able to see the intel_gpu_top command work but all of my resources sat @ 0% -- it doesn't actually appear to be taking advantage of hardware acceleration yet.

Let me know if there's anything I can help with, happy to test.

@mrlt8
Copy link
Owner

mrlt8 commented Jul 9, 2023

@carldanley see #736 for the ongoing discussion re: qsv and alternate ffmpeg commands.

@mitchross
Copy link
Author

I tried to install intel_gpu_top in the container and all I get is: Failed to initialize PMU! (Operation not permitted). I even tried adding the CAP_PERFMON capability to the container and still can't get it to work. However, frigate does come bundled with that tool and it's really nice for me to exec into the container and see that frigate is taking advantage of hardware acceleration.

I got intel_gpu_top working by adding SYS_ADMIN capability (don't do this, not a good practice). I was able to see the intel_gpu_top command work but all of my resources sat @ 0% -- it doesn't actually appear to be taking advantage of hardware acceleration yet.

Let me know if there's anything I can help with, happy to test.

yea I never got it to work with all the suggestions posted here. I dont have a clue why frigate works but wyze bridge does not. I tried everything. When I do get it working, rotate breaks. I gave up on it for now.

@StoneLegion
Copy link

Sorry you were unable to get this to work. Was just looking for ways to improve performance. Hopefully some one else might have the answer.

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