Restream a live stream for Emby on Kubernetes.
If a live stream isn't being imported properly into Emby sometimes restreaming it can fix the issue. The setup is as follows:
- Nginx RTMP server
- ffmpeg container pulling down original stream and sending it to RTMP server
- m3u8 file pointing to RTMP server
Apply the following manifests:
- Create a
rtmp
namespace - RTMP server:
- Deployment:
apiVersion: apps/v1
kind: Deployment
metadata:
name: rtmp
namespace: rtmp
labels:
app: rtmp
spec:
replicas: 1
selector:
matchLabels:
app: rtmp
template:
metadata:
labels:
app: rtmp
spec:
containers:
- name: rtmp
image: tiangolo/nginx-rtmp:latest-2020-08-16
ports:
- containerPort: 1935
- Service:
apiVersion: v1
kind: Service
metadata:
name: rtmp
namespace: rtmp
spec:
selector:
app: rtmp
ports:
- protocol: TCP
port: 1935
targetPort: 1935
type: LoadBalancer
- Start a container to restream using ffmpeg
apiVersion: apps/v1
kind: Deployment
metadata:
name: ffmpeg
namespace: rtmp
labels:
app: ffmpeg
spec:
replicas: 1
selector:
matchLabels:
app: ffmpeg
template:
metadata:
labels:
app: ffmpeg
spec:
containers:
- name: rtmp
image: linuxserver/ffmpeg:7.0.1
args:
- -re
- -i
- <SOURCE m3u8 FILE URL>
- -c:v
- copy
- -f
- flv
- rtmp://<SERVICE LOAD BALANCER IP>/live
Be sure to replace the <SOURCE m3u8 FILE URL>
with your own.
Also be sure to replace <SERVICE LOAD BALANACER>
with the external IP of the rtmp
service.
- Then create an m3u8 file pointing towards your RTMP server:
#EXTM3U
#EXTINF:-1, <STREAM TITLE>
rtmp://<SERVICE LOAD BALANCER IP>/live
Be sure to replace <SERVICE LOAD BALANACER>
with the external IP of the rtmp
service.
- Add this
m3u8
file to your Emby server
Might be able to avoid needing the service load balancer IP if we use the internal Kubernetes service discovery DNS name.