Skip to content

Conversation

@notjulian
Copy link
Contributor

@notjulian notjulian commented Mar 19, 2025

Hi Alex,
Thanks for this amazing project!

I'd like to have the PTZ controls...

So I made some changes. I understand that more features means more code to maintain and more bugs, so I tried to be as minimal as possible. Also, the layout maybe needs a UI/UX review.

Please let me know what you think.
If it needs improvement, I'm happy to make changes.

PS: at the moment is only ptz, no zoom
PPS: to display the controls the src needs to have the _ptz in the name (happy to improve ...)

2025-03-19 10 29 34
2025-03-19 10 29 40

@AlexxIT AlexxIT self-assigned this Mar 19, 2025
@notjulian notjulian changed the title New feature PTZ controls on screen New feature Onvif PTZ controls on screen Mar 19, 2025
@notjulian
Copy link
Contributor Author

if someone would like to play, compiled images are here:
https://hub.docker.com/r/jcsoftware/go2rtc_onvif_ptz

example config:

streams:
  xxxx_ptz: onvif://user:pwd@ip

at the moment the onvif PTZ controls will be displayed on the page if the name of the stream ends with "_ptz"

@mchilli
Copy link

mchilli commented Jun 5, 2025

Hey @notjulian I like your idea for ptz. But I have a problem with this branch, when I want to send a request from a custom website in Chrome, I get this erros:

Access to fetch at 'http://10.10.1.25:1984/api/ptz' from origin 'http://10.10.1.25' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.

I have set this in the go2rtc configuration:

api: origin: "*"

Could it be that the CORS handling from the api code does not work here?

@notjulian
Copy link
Contributor Author

notjulian commented Jun 6, 2025

Hey @notjulian I like your idea for ptz. But I have a problem with this branch, when I want to send a request from a custom website in Chrome, I get this erros:

Access to fetch at 'http://10.10.1.25:1984/api/ptz' from origin 'http://10.10.1.25' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.

I have set this in the go2rtc configuration:

api: origin: "*"

Could it be that the CORS handling from the api code does not work here?

It could be, I haven't tried yet ...

Does it work if you connect directly to the IP?

I'll let you know ...

@mchilli
Copy link

mchilli commented Jun 6, 2025

Interestingly, it works under Firefox or when I send the request directly.
Only Chrome causes problems, whether on android or desktop

@notjulian
Copy link
Contributor Author

notjulian commented Jun 6, 2025

I've tried, but I may not have replicated your issue correctly...

I use the docker image: jcsoftware/go2rtc_onvif_ptz:j-branch-1

If I enable:

api:
  origin: "*"

I see this:
Screenshot 2025-06-06 at 11 09 21

Do you?

@mchilli
Copy link

mchilli commented Jun 6, 2025

I also use your Docker image and get the same result when I use the integrated website with the name extension “_ptz” under Chrome. But when I use my own website in Chrome, the ptz request does not work. Under Firefox or direct requests everything works fine.
After some research, I found out that Chrome uses a “preflight” request before a normal request. And in the network analytics, it looks like there may be a problem:

2025-06-06 14-28-25

Maybe I'm doing something wrong, but I don't know where. The only problem in my case is Chrome.

@mchilli
Copy link

mchilli commented Jun 6, 2025

I found out that the preflights use “OPTIONS” methods which are not allowed in your ptzHandler.
I hope this will help a little.

@notjulian
Copy link
Contributor Author

when is enabled
if cfg.Mod.Origin == "*" {

it should do L216

from the log

Screenshot 2025-06-06 at 14 37 08

can you please post yours?

@mchilli
Copy link

mchilli commented Jun 6, 2025

Sure:
2025-06-06 16-06-10

@notjulian
Copy link
Contributor Author

@mchilli can you please try with the latest image ... thanks

@mchilli
Copy link

mchilli commented Jun 6, 2025

Oh yes, now it works on all my devices and browsers! Thank you so much for your quick help!

@Pimmetje
Copy link

I would love for something like this to be merged. Is there anything the community can do to speed this process?

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.

9 participants