Play Video on Startup of Raspbian on Raspberry Pi

I wanted to be able to play a video on start up of the Raspberry Pi so no human intervention was necessary – you plug in the Pi it boots and plays the selected video(s). This proved a bit tricky in Raspbian so here are the steps required.

1. Create a file and call it put it on the desktop and in a text editor enter the following;


# get rid of the cursor so we don't see it when videos are running
setterm -cursor off																						


# you can normally leave this alone

# now for our infinite loop!
while true; do 
	$SERVICE -r -o hdmi $VIDEOPATH/video_name
	$SERVICE -r -o hdmi $VIDEOPATH/video_name

2. Create a file called videostart.desktop and put the following content in the file

[Desktop Entry]
Name=Play Videos
Comment=Play all videos in /home/pi/vids
Exec=lxterminal --command "/home/pi/Desktop/"

3. Put videostart.desktop in /etc/xdg/autostart/

4. Put the videos to play into /home/pi/vids or which ever path you define as the VIDEOPATH variable within which you created in Step 1.

5. Edit (from Step 1) to have the right video names. You can add as many videos as required to the list to play, just copy and paste the following line of code replacing video_name with the full name of the file including the extention (i.e. mp4).

	$SERVICE -r -o hdmi $VIDEOPATH/video_name

6. Simply restart the Raspberry Pi and the videos should start playing.


  • Sam Levin

    How would I work this same script but have it target arbitrary files? I.e. ‘iff a video file exists with any extension, play it.’. It’s an elegant solution but in my case I won’t always know what the video name will be.