Nohup not give expected output. Non-stop running process

Hello,
I am trying to make a bash script, I tested nohup but it did not help me.
My code is:

ffmpeg -i $input_url -c:v copy -c:a copy -listen 1 -f mpegts http://localhost:port/live/test

When I open it in VLC, it starts feeding my screen and I see bitrate values.
When I stop watching it, script ends but it does not go back to sleep mode.
To open it in VLC again, I need to run that command from terminal.
What I wish to accomplish is when the script ends, it should re-runs itself after killing reserved PID nr.

1.st attempt

nohup & ffmpeg -i $input -listen 1 -c:v copy -c:a copy -f mpegts http://localhost:port/live/test

2.nd attempt

nohup ffmpeg -i $input -listen 1 -c:v copy -c:a copy -f mpegts http://localhost:port/live/test &

Could you please let me know with which command I can make it running?

Thanks in advance
Boris

Not sure I entirely understand, but why don't you run the command in a loop and drop the nohup and & ?

1 Like

Hello Rudic,
Do you mean something like this:

while true; do
    $ffmpeg_command
    sleep 5
done

PS: I wish that script be ready to run even if I watch it or not. For that reason I wish to make it vivid permanently.

Thanks in advance
Boris

Can't tell; test it and find out if it suits your needs...

Works very nice
Thanks once again Rudic!!

Kind regards
Boris