Skip to content

Instantly share code, notes, and snippets.

@ryanlong1004
Created April 6, 2025 01:40
Show Gist options
  • Save ryanlong1004/d3339c32fe75d36436a7f97b6ec9cb13 to your computer and use it in GitHub Desktop.
Save ryanlong1004/d3339c32fe75d36436a7f97b6ec9cb13 to your computer and use it in GitHub Desktop.
Slingshot

To run this VLC command as a service on Raspbian (Raspberry Pi OS) at startup, the best approach is to use a systemd service.


βœ… Steps to Create a systemd Service for CVLC on Startup:

1. Create a systemd service file

Open a terminal and run:

sudo nano /etc/systemd/system/cvlc-video.service

2. Paste this into the file:

[Unit]
Description=Looping CVLC Video Playback
After=network.target sound.target graphical.target

[Service]
User=pi
ExecStart=/usr/bin/cvlc --no-osd --fullscreen --loop --no-video-title-show --no-sub-autodetect-file --quiet --drop-late-frames --skip-frames /home/default/video.mp4
Restart=always
RestartSec=5
StandardOutput=null
StandardError=null

[Install]
WantedBy=graphical.target

πŸ”„ Change User=pi if you're using a different user.


3. Enable and Start the Service

sudo systemctl daemon-reexec
sudo systemctl daemon-reload
sudo systemctl enable cvlc-video.service
sudo systemctl start cvlc-video.service

4. Check Status

systemctl status cvlc-video.service

βœ… Notes:

  • This runs after the GUI starts, because graphical.target ensures X11 is ready.
  • You might need to run this with a valid DISPLAY if it’s running outside a login session. You can tweak the service like this if needed:
Environment=DISPLAY=:0
Environment=XAUTHORITY=/home/pi/.Xauthority

Want it to run on a headless system, or should it auto-login to the GUI first?

Yes, you can optimize your VLC command for low-resource devices by reducing CPU and memory usage. Here are some optimizations:

Optimized Command:

cvlc --no-osd --fullscreen --loop --no-video-title-show --no-sub-autodetect-file --quiet --drop-late-frames --skip-frames /home/default/video.mp4

Explanation of Optimizations:

  1. --no-osd β†’ Disables On-Screen Display (already in your command).
  2. --fullscreen β†’ Starts in full-screen mode.
  3. --loop β†’ Loops the video.
  4. --no-video-title-show β†’ Prevents VLC from displaying the video title overlay.
  5. --no-sub-autodetect-file β†’ Prevents VLC from scanning for subtitles (reduces CPU usage).
  6. --quiet β†’ Disables verbose logging.
  7. --drop-late-frames β†’ Drops late frames instead of trying to render them, reducing CPU/GPU load.
  8. --skip-frames β†’ Skips frames when necessary to keep playback smooth.

Would you like further tuning for a specific device, like a Raspberry Pi or a low-end PC?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment