# SRT to RTMP

## Requrements:

```bash
sudo apt install -y ffmpeg srt-tools
```

To test start a SRT stream with FFMPEG:

```bash
ffmpeg -re -i video.mp4 -c:v copy -c:a copy -f mpegts "srt://127.0.0.1:2088?mode=caller&passphrase=mypassword"
```

start srt listener:

```bash
srt-live-transmit srt://:2088?passphrase=mypassword udp://127.0.0.1:23000
```

convert srt to rtmp with ffmpeg:

```bash
ffmpeg -i udp://127.0.0.1:23000 -c:v copy -c:a copy -f flv rtmp://192.168.1.129:1935/live
```

replace [rtmp://192.168.1.129:1935/live](rtmp://192.168.1.129:1935/live) with your RMP stream destination

### Set as systemd

edit `/etc/systemd/system/srt-live-transmit.service`

```bash
[Unit]
Description=SRT Live Transmit Service
After=network.target

[Service]
ExecStart=/usr/bin/srt-live-transmit srt://:2088?passphrase=mypassword udp://127.0.0.1:23000
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

```

change `srt://:2088?passphrase=mypassword`

edit `/etc/systemd/system/ffmpeg.service`

```bash
[Unit]
Description=FFmpeg RTMP Service
After=network.target srt-live-transmit.service
Requires=srt-live-transmit.service

[Service]
ExecStart=/usr/bin/ffmpeg -i udp://127.0.0.1:23000 -c:v copy -c:a copy -f flv rtmp://192.168.1.129:1935/live
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

```

change `rtmp://192.168.1.129:1935/live`

### Aktivate:

```bash
sudo systemctl daemon-reload
```

```bash
sudo systemctl enable srt-live-transmit
sudo systemctl enable ffmpeg
```

and start:

```bash
sudo systemctl start srt-live-transmit
sudo systemctl start ffmpeg
```

check:

```bash
sudo systemctl status srt-live-transmit
sudo systemctl status ffmpeg
```