SmartCradle v1
Baby smart cradle
livestream.c
Go to the documentation of this file.
1
10#include <stdlib.h>
11#include <sys/wait.h>
12#include "../inc/livestream.h"
13
14static _Bool streamRunning = 0; /* Status of the stream */
15
17{
18 if(!streamRunning)
19 {
20 system("ffmpeg -re \
21 -f alsa -ac 1 -thread_queue_size 1024 -ar 44100 -i plughw:0,0 \
22 -f v4l2 -video_size 320x240 -thread_queue_size 16384 -i /dev/video0 \
23 -c:a copy -c:v h264 -b:v 2048k -preset ultrafast -filter:v fps=fps=30 -tune zerolatency \
24 -f flv rtmp:localhost/live \
25 -nostdin -nostats > /var/log/ffmpeg_output.log 2>&1 < /dev/null &");
26
27 streamRunning = 1;
28 }
29}
30
32{
33 if(streamRunning)
34 {
35 /* Get ffmpeg PID and kill the process */
36 system("pidof ffmpeg | xargs kill -9"); //9 = SIGKILL
37 streamRunning = 0;
38 }
39}
40
42{
43 return streamRunning;
44}
_Bool getStreamStatus()
Get the Streaming Status object.
Definition: livestream.c:41
void stopLivestream()
Stop the livestream.
Definition: livestream.c:31
void startLivestream()
Start the livestream.
Definition: livestream.c:16