How to stream a GIF with text and sound with ffmpeg, nginx and hls.js

How to stream a GIF with text and sound with ffmpeg, nginx and hls.js


ffmpeg -re -ignore_loop 0 -i /home/coffee/coffee.gif -stream_loop -1 -re -i /home/coffee/sound.mp3 -acodec libmp3lame -ab 24k -ar 22050 -f hls -hls_time 10 -hls_list_size 6 -start_number 1 -filter_complex drawtext="fontfile=/usr/share/fonts/dejavu/DejaVuSans.ttf: textfile=/home/coffee/stream.txt: reload=1: fontcolor=white: fontsize=17: x=0: y=1" /home/coffee/stream/hls/output.m3u8


[Unit]
Description=coffee-stream
Wants=network-online.target
After=network-online.target
[Service]
WorkingDirectory=/home/coffee/
User=coffee
Group=coffee
ExecStart=/bin/bash /home/coffee/coffee-stream.sh
Restart=always
[Install]
WantedBy=multi-user.target


[Unit]
Description=coffee-stats
Wants=network-online.target
After=network-online.target
[Service]
WorkingDirectory=/home/coffee/
User=coffee
Group=coffee
ExecStart=/bin/bash /home/coffee/coffee-stats.sh
Restart=always
[Install]
WantedBy=multi-user.target


while true ; do echo "stream.josecapurro.com.py - $(date +%Y%m%d%H%M%S) - ONLINE: $(ss -tlanp | grep 1935 | grep ESTAB | grep -v 127.0.0.1 | wc -l)" > /home/coffee/stream.txt ; sleep 5; done


rtmp {
server {
listen 1935;
chunk_size 4096;
allow publish 127.0.0.1;
deny publish all;
application coffee {
live on;
record off;
hls on;
hls_path /home/coffee/stream/hls;
hls_fragment 3;
hls_playlist_length 10;
}
}
}

server {
listen 443 ssl;
listen [::]:443 ssl;
server_name stream.josecapurro.com.py;
root /home/josecapurro/stream;
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 5;
gzip_buffers 16 8k;
gzip_http_version 1.0;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
ssl_certificate /etc/letsencrypt/live/stream.josecapurro.com.py/cert.pem;
ssl_certificate_key /etc/letsencrypt/live/stream.josecapurro.com.py/privkey.pem;
charset utf-8;
access_log /var/log/nginx/stream.josecapurro.com.py_access.log;
error_log /var/log/nginx/stream.josecapurro.com.py_error.log;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
location / {
index index.html;
limit_except GET {deny all;}
}
location /static {
alias /home/josecapurro/stream/static;
limit_except GET {deny all;}
}
location /hls {
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root /home/coffee/stream;
add_header Cache-Control no-cache;
}
}