help-bash
[Top][All Lists]
Advanced

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

Re: record stream using time limit, reconnecting as needed


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

Here's something similar to what I wrote within another script, written 
approximately ten years ago.

Far more simplified than using timeout.

However, I'm still stumped for how to background an endless loop with the 
included ffmpeg stream recording, so the stream is easily reconnected if 
dropped, while falling through to get the PID of the backgrounded endless loop 
or ffmpeg, for killing after so many (eg 30) minutes?

Think this gets down to proper placement of the ampersand sign for 
backgrounding?

Sample script follows.

# FUNCTIONS

record()
{
    # created a function for the (endless) while recording loop, then 
    # backgrounded.
    while/loop
        ffmpeg http://some.url.m3u8
        pid_task="${!}"
    done &

    # FIXME: Where or how do I put the background & sign, to background the 
    # ffmpeg/while loop?
}

sleep_while_recording()
{
    # number of desired minutes of recording stream
    # converted minutes to seconds, if need to perform math on time
    sleep 30m
}

# MAIN

record

sleep_while_recording

kill $pid_task

Attachment: signature.asc
Description: PGP signature


reply via email to

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