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

[Request] Add the option to turn on/off video output via the new FPV web request api #220

Open
tipoman9 opened this issue Dec 2, 2024 · 2 comments

Comments

@tipoman9
Copy link

tipoman9 commented Dec 2, 2024

Recently a new feature was added to majestic, that allows some encoder parameters, important for FPV, to be changed realtime by external requests.
For example, to change bitrate curl -s http://localhost/api/v1/set?video0.bitrate=7000
So I tried curl -s http://localhost/api/v1/set?video0.enabled=false or curl -s http://localhost/api/v1/set?outgoing.enabled=false , but they do not seem to affect anything.
These settings are present in majestic yaml as

video0:
  enabled: false
outgoing:
  enabled: true
  server: udp://127.0.0.1:5600

For dual camera setups, when switching between cameras, I need to enable one majestic and disable the other.
Setting the parameters above and restarting majestic works, but this causes video delay of more than a second.
Like this:

nice -n 0 /usr/bin/ssh -T -y -y -i /etc/id_rsa [email protected] 'yaml-cli -s .video0.enabled false ; killall -1 majestic'

It would be better to be able to start/stop video output with the new interface with a simple web call.
So a ssh to the second cam will not be required and there will be no video interruption.
Any of the two settings above will do the job, even simply changing the output server udp address is enough.

@tipoman9
Copy link
Author

tipoman9 commented Dec 3, 2024

I have created majestic plugins, so I can implement the functionality there.
Can you at least point me how to stop/start sigmastar video encoder from within a plugin?
I can access the VENC API from there, calling MI_VENC_StopRecvPic(...) seems the easy part , but I can't recreate the process majestic uses to initialize a stream with MI_VENC_StartRecvPic(...)
So I need some hints how to pause the encoder or how to redirect majestic output to some other endpoint.
Thanks

@tipoman9
Copy link
Author

tipoman9 commented Dec 4, 2024

So, seems brute-force pause/resume video via plugin is working, although I'm not sure whether it will not cause any problems with majestic

static void pauseVideo(const char *value) {
    int res = MI_VENC_StopRecvPic(0);
    RETURN("Video paused %d",res);
}

static void resumeVideo(const char *value) {
    int res = MI_VENC_StartRecvPic(0);
    RETURN("Video resumed %d",res);
}

It turned out that plugin server binds to 127.0.0.1:4000 instead of 0.0.0.0:4000
So I had to create a simple redirection to make it accessible from the outside.

while true; do    
	nc -l -p 4001  | nc 127.0.0.1 4000	
done```

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

1 participant