added systemd config
This commit is contained in:
51
README.md
51
README.md
@@ -105,6 +105,57 @@ Use the dockerized ffmpeg with precompiled vaapi support, adjust `/dev/video2`
|
||||
Adjust `/dev/video2`, `-video_size 1920x1080 -framerate 60` and stream to peertube (if it can handle that much)
|
||||
> `ffmpeg -hide_banner -y -f v4l2 -input_format mjpeg -video_size 1920x1080 -framerate 60 -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format vaapi -i /dev/video2 -vf 'scale_vaapi=format=nv12' -c:v h264_vaapi -b:v 10M -f flv rtmp://peertube.virtonline.eu:1935/live/LIVE-STREAM-KEY`
|
||||
|
||||
### Setup a systemd service for the non-stop streaming
|
||||
Adjust `jrottenberg/ffmpeg:4.4-alpine` if you want to use a specific ffmpeg version
|
||||
```
|
||||
sudo tee /etc/systemd/system/virt-garage-webcam-streamer.service <<EOF
|
||||
[Unit]
|
||||
Description=Garage Webcam Streamer service
|
||||
Requires=docker.service
|
||||
After=docker.service
|
||||
DefaultDependencies=no
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
|
||||
Environment="HOME=/root"
|
||||
Environment=WEBCAM_URI="rtsp://garagecam.virtonline.eu:554/live3.sdp"
|
||||
Environment=PEERTUBE_LIVE="rtmp://peertube.virtonline.eu:1935/live/LIVE-STREAM-KEY"
|
||||
Environment=FFMPEG="docker run --rm --name virt-garage-webcam-streamer jrottenberg/ffmpeg:4.4-alpine"
|
||||
|
||||
ExecStartPre=-/usr/bin/env sh -c '/usr/bin/env docker kill virt-garage-webcam-streamer 2>/dev/null || true'
|
||||
ExecStartPre=-/usr/bin/env sh -c '/usr/bin/env docker rm virt-garage-webcam-streamer 2>/dev/null || true'
|
||||
|
||||
# Re-stream (Audio/Video) from IP camera to peertube live
|
||||
ExecStart=/bin/bash -c '${FFMPEG} -loglevel error \
|
||||
-i ${WEBCAM_URI} \
|
||||
-c copy \
|
||||
-f flv \
|
||||
${PEERTUBE_LIVE}'
|
||||
|
||||
ExecStop=-/usr/bin/env sh -c '/usr/bin/env docker kill virt-garage-webcam-streamer 2>/dev/null || true'
|
||||
ExecStop=-/usr/bin/env sh -c '/usr/bin/env docker rm virt-garage-webcam-streamer 2>/dev/null || true'
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
SyslogIdentifier=virt-garage-webcam-streamer
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
```
|
||||
Reload systemd manager configuration
|
||||
|
||||
`sudo systemctl daemon-reload`
|
||||
|
||||
Enable the virt-garage-webcam-streamer service at boot time and also run it
|
||||
|
||||
`sudo systemctl enable --now virt-garage-webcam-streamer`
|
||||
|
||||
If it does not work check logs
|
||||
|
||||
`journalctl -f -u virt-garage-webcam-streamer`
|
||||
|
||||
|
||||
### Transcode and scale video file (and copy audio) using VAAPI (see [HWAccelIntro](https://trac.ffmpeg.org/wiki/HWAccelIntro))
|
||||
> `alias ffmpeg='docker run --rm -w $(pwd) -v $(pwd):$(pwd) --device=/dev/dri jrottenberg/ffmpeg:vaapi'`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user