[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: record stream using time limit, reconnecting as needed
From: |
Koichi Murase |
Subject: |
Re: record stream using time limit, reconnecting as needed |
Date: |
Wed, 22 Feb 2023 16:21:14 +0900 |
2023年2月22日(水) 12:52 Roger <rogerx.oss@gmail.com>:
> 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?
If you specify a negative integer (e.g. -<PGID> where <PGID> is an
integer) to `kill', `kill' will kill all the processes that belong to
the process group PGID. You can give a distinct process group ID to
the background while loop by specifying `set -m' before starting the
background job. Then you can pass the PGID (i.e., the PID of the
`while' loop) to `kill' to kill all the processes including ffmpeg. In
this way, you do not need to directly specify the PID of ffmpeg. This
is an example.
#!/usr/bin/env bash
record() {
local -
set -m
while true; do
ffmpeg http://some.url.m3u8
done & pgid_task="${!}"
}
sleep_while_recording() { sleep 30m; }
record
sleep_while_recording
kill -INT -"$pgid_task"
- record stream using time limit, reconnecting as needed, Roger, 2023/02/21
- Re: record stream using time limit, reconnecting as needed, Roger, 2023/02/21
- Re: record stream using time limit, reconnecting as needed, Roger, 2023/02/21
- Re: record stream using time limit, reconnecting as needed, alex xmb ratchev, 2023/02/22
- Re: record stream using time limit, reconnecting as needed, Koichi Murase, 2023/02/22
- Re: record stream using time limit, reconnecting as needed, Koichi Murase, 2023/02/22
- Re: record stream using time limit, reconnecting as needed, Roger, 2023/02/22
- Re: record stream using time limit, reconnecting as needed,
Koichi Murase <=
- Re: record stream using time limit, reconnecting as needed, Roger, 2023/02/22
- Re: record stream using time limit, reconnecting as needed, Roger, 2023/02/23
- Re: record stream using time limit, reconnecting as needed, Roger, 2023/02/23
- Re: record stream using time limit, reconnecting as needed, Greg Wooledge, 2023/02/23
- Re: record stream using time limit, reconnecting as needed, Roger, 2023/02/24