Take the 2-minute tour ×
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

I'm trying to only use my ssh console from android to remote control the pi, and I'd love to be able to play a video on my TV. My pi is HDMI conntected to TV always prompting for username.

I'd like to know what to do so I can play a movie (w/ subtitles) from ssh.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

Please, provide the answers to following questions :

What is your Raspberry OS ?

Does your OS able to start a User Interface (x11) ?

To answer a bit your question, you'll need a video application on raspberry pi that can be launch in a terminal. For instance you could use VLC that is really great and once you're SSH connected to your Pi use the following commande :

vlc -vvv my_file.mpg

Obviously your video file should be located on the raspberry pi otherwise it won't work this way.

More information about VLC command line here : http://www.videolan.org/doc/vlc-user-guide/en/ch04.html

EDIT : About subtitle, if your subtitle has the same name than the video file then VLC will automatically play the video and overlay the subtitle to it ;)

share|improve this answer
    
It's raspbian :b –  bernardo Jul 29 at 16:29

As most distributions come with mplayer installed, I use it for playing videos on the Linux framebuffer. It can be used to play video in a totally X-free system. There are some serious downsides to this approach which I mention below.

export TERM=linux
setterm -blank 0 -cursor off -powerdown 0 -powersave off \
        -bfreq 0 -blength 0 < /dev/console > /dev/console
mplayer -vo fbdev2,fbdev, -zoom -fs -really-quiet \
        -screenw 1280 -screenh 768 -xy 1024 \
        -geometry '50%:50%'        the_video_file.mp4
setterm -cursor on -blank 10 < /dev/console > /dev/console

Description of the commands:

  • The TERM environment variable is set to linux to 'trick' the setterm command into working.

  • The setterm commands stop the linux console from interfering with the framebuffer. This means cursor blinking and screen blanking are disabled. The IO are connected to /dev/console because an ssh session uses a 'ttyS' device and setterm only works on (physical) 'tty' devices. The < /dev/console > /dev/console part tells setterm to operate on the 'tty' devices.

  • -vo fbdev2,fbdev, instructs mplayer to try the fbdev2 output driver, falling back to the fbdev driver, and (,) falling back to any other driver that works. Most likely no other drivers will work.

  • -zoom -fs stretch the image to fill the desired screen (fullscreen).

  • -really-quiet instructs mplayer to not print anything to the console. Normally it does. This text would be visible through the framebuffer image.

  • -screenw 1280 -screenh 768 these are the pixel dimensions of your monitor. Be aware that if you have two monitors (i.e., a laptop and a TV connected via an HDMI cable) there are several screen "dimensions." You want the real dimensions -- not the virtual dimensions. You can find real dimensions using cat /sys/class/graphics/fb0/modes

  • -xy 1024 instructs mplayer to scale the video to a width of 1024 pixels. Why not 1280? Because mplayer scales the video height in proportion to maintain the video's aspect ratio. However, if the height it larger than the screen dimensions (1280x768 in this case) it will simply fail. There are ways around this, but it is a bit of a rabbit hole...

  • -geometry '50%:50%' instructs mplayer to place the video images in the centre of the framebuffer.

Notes, pitfalls, downsides:

  • mplayer doesn't (to my knowledge) support hardware acceleration. Decoding and drawing to the framebuffer are both slow without hardware acceleration. Because the raspberry pi cpu is so low-powered, you will simply not be able to play videos with large dimensions. Try the unrelated omxplayer if possible.

  • mplayer is unforgiving regarding the screen and video dimensions. If you ask it to scale the video beyond the physically available screen, it will simply fail to play. Video dimensions can be found using ffprobe, mplayer, file, or in many other ways.

  • The linux framebuffer is not really designed for this sort of thing. It cannot be modified without rebooting, and is set with kernel boot parameters. Something like DirectFB would be an improvement.

  • Because the framebuffer will overwrite the console, and you are using the console to launch mplayer, there may be some text visible during playback. You can get around this by launching playback on an unused terminal. This can be done with something like:

    openvt --console=6 --switch --force --wait -- \ bash -c "cd '$(pwd)' && \ /opt/script_containing_above_commands.sh "'$@' '' $@ &>/dev/null &

    But this is a bordering on the scope of your question.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.