Skip to content

Commit

Permalink
cleanup stream on stop
Browse files Browse the repository at this point in the history
  • Loading branch information
Giona Righini committed Sep 2, 2024
1 parent a6677ae commit 9a4db7c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ app.post("/api/live_start", async (req, res) => {
const s = shutter ? `--shutter ${shutter}` : "";

try {
execSync(`sudo rm stream/*`);
spawn(
`libcamera-vid -t 0 ${resolution} --framerate 15 --codec h264 --bitrate ${bitrate} ${g} ${s} -o - | ffmpeg -i - -c copy -f hls -hls_time 4 -hls_list_size 5 -hls_flags delete_segments -hls_segment_filename './stream/segment_%03d.ts' ./stream/index.m3u8`,
{
Expand All @@ -49,6 +48,7 @@ app.post("/api/live_start", async (req, res) => {
app.post("/api/live_stop", async (req, res) => {
try {
execSync(`sudo pkill libcamera-vid`);
execSync(`sudo rm -f stream/*`);

isLive = false;
io.emit("live", { event: "stop" });
Expand Down

0 comments on commit 9a4db7c

Please sign in to comment.