====== FFMPEG ======
===== Get Data from OctoPrint =====
#!/bin/bash
DATA=$(curl -s --header "X-Api-Key: xxx" http://localhost/api/printer)
DATA2=$(curl -s --header "X-Api-Key: xxx" http://localhost/api/job)
TOOTEMP=$(echo $DATA | jq -r '.temperature.tool0.actual')
TOOREQTEMP=$(echo $DATA | jq -r '.temperature.tool0.target')
BEDTEMP=$(echo $DATA | jq -r '.temperature.bed.actual')
BEDREQTEMP=$(echo $DATA | jq -r '.temperature.bed.target')
PROGRES=$(echo $DATA2 | jq -r '.progress.completion')
TIMELEFT=$(echo $DATA2 | jq -r '.progress.printTimeLeft')
STATE=$(echo $DATA2 | jq -r '.state')
FINAME=$(echo $DATA2 | jq -r '.job.file.name')
PRROUND=$(echo "$PROGRES/1" | bc )
$QTEMP°C\n Status: $STATE\n\n Progress: $PRROUND\n File: $FINAME\nTime Left: $TIMELEFT\n" > status-temp.txt
cp -f status-temp.txt status.txt
===== Stream to youtube =====
#!/bin/bash
KEY=xxxx
URL=rtmp://a.rtmp.youtube.com/live2
while true ; do
ffmpeg \
-ar 44100 -ac 2 -f s16le -i /dev/zero \
-i desktop-background.png \
-s 800x600 -i /dev/video0 \
-f flv \
-s 1920x1080 \
-filter_complex "[1:v][2:v]overlay=(main_w-overlay_w):(main_h-overlay_h)/2 [a];[a]
drawtext=fontfile=DejaVuSansMono.ttf:textfile=status.txt:fontsize=26:fontcolor=white:y=main_h-(text_h*1):reload=1" \
-vcodec h264_omx -pix_fmt yuv420p -b:v 15242310 -maxrate 15242310 -bufsize 30484620 \
"$URL/$KEY"
sleep 5
done