===== Live streaming to youtube =====
- compile ffmpeg with hardware encoder
cd /usr/src
git clone https://git.ffmpeg.org/ffmpeg.git
cd ffmpeg
./configure --enable-omx --enable-omx-rpi --enable-libfreetype
make
make install
Scripts
#!/bin/bash
KEY=********
URL=rtmp://a.rtmp.youtube.com/live2
while true ; do
ffmpeg \
-ar 44100 -ac 2 -f s16le -i /dev/zero \
-thread_queue_size 512 \
-i /dev/video0 -f flv \
-framerate 30 -video_size 720x404 \
-vcodec h264_omx -maxrate 768k -bufsize 8080k \
-vf drawtext="fontfile=DejaVuSansMono.ttf:textfile=status.txt:fontsize=10:fontcolor=white:y=main_h-(text_h*1):reload=1" \
"$URL/$KEY"
sleep 5
done
#!/bin/bash
DATA=$(curl -s --header "X-Api-Key: *****" http://localhost/api/printer)
DATA2=$(curl -s --header "X-Api-Key: *****" http://localhost/api/job)
TOOTEMP=$(echo $DATA | jq -r '.temperature.tool0.actual')
BEDTEMP=$(echo $DATA | jq -r '.temperature.bed.actual')
PROGRES=$(echo $DATA2 | jq -r '.progress.completion')
STATE=$(echo $DATA2 | jq -r '.state')
FINAME=$(echo $DATA2 | jq -r '.job.file.name')
PRROUND=$(echo "$PROGRES/1" | bc )
printf " Tool: $TOOTEMP°C / Bed: $BEDTEMP°C\n State: $STATE, Progress: $PRROUND\n File: $FINAME\n" > status-temp.txt
cp -f status-temp.txt status.txt