Friday 24 March 2017

Playing Video on Raspberry Pi

So you have a new raspberry pi, it is all set up, something like Raspbian is running on the SD card, and you have a desktop in front to of you. You might have even played with some of it, maybe one of the built in games. I know the first thing I wanted to do was to play a video. There doesn't seem to be a video player on the dropdown menu, but there is one built in, To get to it, the terminal is needed. I know it seems kinda scary, but its just one line.

Firstly, you need to know where the video is that you want to play. I have mine on a memory stick in the USB port. When the memory stick is plugged in, it will usually open in the file manager. In the bar at the top it will show the file path, mine is shown below as an example.

/media/pi/memstick/
Also, note the name of the file you want to play, and the way it is encoded. So it might be a .mp4 or a .avi or anything similar. If you want to play an uncommonly encoded video, look at the omxplayer documentation to check it supports it.

The next part is easy, open up the terminal, and type in:

omxplayer -o hdmi /media/pi/memstick/hk3.avi
Note the last bit is the file path, and will be different depending on where your file is stored; the above is an example. Just to explain what is going on here, omxplayer is the command we are using, and uses the already installed application associated with it. -o opens the port, and hdmi tells the pi where the stream needs to be output to (remember the pi has a few video outs). This command also allows the audio to play through the hdmi.

All going well, a video will play. Note you cant use the mouse to control the video, it is all done run through the terminal, so pressing keys controls what you want to do. A short list of commands is shown below.

1                    decrease speed
2                    increase speed
<                    rewind
>                    fast forward
z                     show info
j                     previous audio stream
k                    next audio stream
i                     previous chapter
o                    next chapter
n                    previous subtitle stream
m                   next subtitle stream
s                     toggle subtitles
w                    show subtitles
x                     hide subtitles
d                     decrease subtitle delay (- 250 ms)
f                      increase subtitle delay (+ 250 ms)
q                     exit omxplayer
p / space         pause/resume
-                      decrease volume
+ / =                increase volume
left arrow       seek -30 seconds
right arrow    seek +30 seconds
down arrow   seek -600 seconds
up arrow        seek +600 seconds


No comments:

Post a Comment