Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Change source on demand / disconnect or on parameter #110

Closed
Kiwa21 opened this issue Nov 5, 2020 · 1 comment
Closed

Change source on demand / disconnect or on parameter #110

Kiwa21 opened this issue Nov 5, 2020 · 1 comment
Labels
question Further information is requested

Comments

@Kiwa21
Copy link

Kiwa21 commented Nov 5, 2020

Which version are you using?

v0.12

Which operating system are you using?

Linux

Question

I have 2 RTSP streams inputs, streaming the same camera but going from different network path, I would like to relay one or the other on the same output RTSP URL depending on network performance. (camera is moving between network AP).

The switch between input could be done from a parameter / env variable / http request or even when the first input source is lost (sourceOnDisconnect ?)

Is there a way to achieve this ?
Thanks !

@Kiwa21 Kiwa21 changed the title Change source on demand / on parameter Change source on demand / disconnect or on parameter Nov 5, 2020
@aler9
Copy link
Member

aler9 commented Nov 7, 2020

Hello, my advice is: write a script that rewrites the configuration file every time you need to switch the camera.
The server will reload the configuration and switch the source.

Something like this (i wrote it in bash but it's practically pseudo-code that can be written in any language):

#!/bin/bash

choose_camera() {
    # set new_camera by running some algorithm
    new_camera=1
}

current_camera=1

write_conf() {
    conf=""
    conf+="paths:\n"
    conf+="  path1:\n"
    
    if [ $current_camera = 1 ]; then
        conf+="    source: rtsp://url1\n"
    else
        conf+="    source: rtsp://url2\n"
    fi

    printf "$conf" > rtsp-simple-server.yml
}

write_conf

while true; do
    choose_camera
    
    if [ $new_camera != $current_camera ]; then
        current_camera=new_camera
        write_conf
    fi

    sleep 1
done

@aler9 aler9 added the question Further information is requested label Nov 7, 2020
@aler9 aler9 closed this as completed Mar 30, 2021
@bluenviron bluenviron locked and limited conversation to collaborators Mar 30, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants