help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

record stream using time limit, reconnecting as needed


From: Roger
Subject: record stream using time limit, reconnecting as needed
Date: Tue, 21 Feb 2023 18:59:22 -0500

Trying to get ffmpeg to record a stream.

While recording (or downloading) the stream, sometimes the stream disconnects 
and need ffmpeg to re-attach/continue downloading the stream.

So far, I'm converting time to unix seconds or unix time  and monitoring within 
a while loop for reconnecting recording the stream during random disconnects.

(Forget whether unix seconds/times, as I wrote the implimentation awhile ago 
and forgot to document ...  doh!)

I then call this while/loop using timeout.

So I have something like this, not sure if the final kill statement will be 
executed correctly though.  Pretty much a snipping of the original script 
containing the relevant parts.


declare runtime="30 minutes"
declare runtime_timeout="30m"

endtime=$(date -ud "$runtime" +%s)

record_loop() {
    while [[ $(date -u +%s) -le $endtime ]] ; do
        ...
        ffmpeg http://some.stream.somewhere/over/the/hill.m3u8
        ...
    done
}

timeout --foreground ${runtime_timeout} bash -c record_loop

kill -INT $$


The timeout is likely working.  If timeout works and drops to the next kill 
statement, then this should work and I will not need anymore help.

However, If timeout does not drop to the kill statement for terminating the 
script, then I'm still doing something wrong.

The big problem I'm trying to work around, are the frequent disconnects, and 
then looping while using a timed timeout to kill.

Sounds like I might need to spawn a sub-process, then kill the process using 
the timeout command if the above is not working.


Roger

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]