Launch RTMP stream on startup

I’m trying to setup some Pi’s to run an RTMP stream at work on multiple TVs throughout campus.

I’ve setup a systemd .service and .timer to run a script at launch that references a RTMP stream, but VLC doesn’t allow for running as root. I’ve tried mplayer, but the service reports:

● stream.service - "Runs stream"
     Loaded: loaded (/etc/systemd/system/stream.service; static)
     Active: active (running) since Mon 2022-12-19 13:44:29 MST; 13min ago
TriggeredBy: ● stream.timer
   Main PID: 852 (stream.sh)
      Tasks: 2 (limit: 1818)
        CPU: 58.111s
     CGroup: /system.slice/stream.service
             ├─852 /bin/bash /home/pi/Documents/stream.sh
             └─853 mplayer -fs rtmp://192.168.133.22/screen/rtmp

Dec 19 13:57:28 RDACPI stream.sh[853]: VO: [fbdev] 1920x1080 => 1920x1080 BGR 16-bit  [fs]
Dec 19 13:57:28 RDACPI stream.sh[853]: Can't put VSCREENINFO: Invalid argument
Dec 19 13:57:28 RDACPI stream.sh[853]: FATAL: Cannot initialize video driver.
Dec 19 13:57:28 RDACPI stream.sh[853]: Too many buffered pts
Dec 19 13:57:30 RDACPI stream.sh[853]: Movie-Aspect is 1.78:1 - prescaling to correct movie aspect.
Dec 19 13:57:30 RDACPI stream.sh[853]: [swscaler @ 0xffff91b17af8]No accelerated colorspace conversion found from yuv420p to rgb565le.
Dec 19 13:57:30 RDACPI stream.sh[853]: VO: [fbdev] 1920x1080 => 1920x1080 BGR 16-bit  [fs]
Dec 19 13:57:30 RDACPI stream.sh[853]: Can't put VSCREENINFO: Invalid argument
Dec 19 13:57:30 RDACPI stream.sh[853]: FATAL: Cannot initialize video driver.
Dec 19 13:57:30 RDACPI stream.sh[853]: Too many buffered pts

It would be safe to assume there’s an issue with the video driver, but running the target script which is just mplayer rtmp://(ip of stream) turns out fine.

I’m running it on a Pi 4 Model B, but here’s a quick neofetch just if someone had questions about the environment

██████████████████  ████████   pi@RDACPI 
██████████████████  ████████   --------- 
██████████████████  ████████   OS: Manjaro ARM Linux aarch64 
██████████████████  ████████   Host: Raspberry Pi 4 Model B Rev 1.2 
████████            ████████   Kernel: 5.15.82-1-MANJARO-ARM-RPI 
████████  ████████  ████████   Uptime: 22 mins 
████████  ████████  ████████   Packages: 673 (pacman) 
████████  ████████  ████████   Shell: bash 5.1.16 
████████  ████████  ████████   Resolution: 1920x1080 
████████  ████████  ████████   DE: Xfce 4.16 
████████  ████████  ████████   WM: Xfwm4 
████████  ████████  ████████   WM Theme: Default 
████████  ████████  ████████   Theme: Matcha-dark-sea [GTK2], Adwaita [GTK3] 
████████  ████████  ████████   Icons: Papirus-Dark-Maia [GTK2], Adwaita [GTK3] 
                               Terminal: xfce4-terminal 
                               Terminal Font: Monospace 12 
                               CPU: BCM2835 (4) @ 1.500GHz

Why do you want to run as root?

Please post your systemd unit file (. service).

I guess it runs too early.

Didn’t have any desire to run it in root, just forgot about the autostart folder.

Got it working by creating a .desktop file in /home/pi/.config/autostart that read

[Desktop Entry] 
Type=Application
Exec=cvlc -f rtmp://(ip of stream)

Thanks for your help!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.