2

I want to be able to play quality video from a text console. I have two options set up, neither of which is ideal:

  1. I have mplayer set up to use the -vo fbdev2 option, which I understand to directly use a frame buffer provided by linux. This works, but it is not the best quality.

  2. I have a script that changes to tty 7 to play the video and then changes back. I thereby get the quality of X, but there are a few issues:

The problems with the second method are as follows.

  1. If I am not logged into a gui session on tty7 the video does not show (I just stare at the login screen).

  2. The contents of the gui session are flashed when the player is done. Not a big deal, but it just looks cludgy.

  3. If I change tty's during the video, I get pulled back to the tty that started the video when the video is done playing.

I would like to play a video from a text console (tty1-6) using X. As far as I can tell, that is the only way to get quality video and have it act like it is playing in the console I am using.

Any advice on how to set up a text console to launch mplayer in X would be much appreciated!

NOTE 1: I think an old install I had of Ubuntu 14 did this automatically when mplayer was called, as mplayer played with good quality from text console. I no longer have that setup to verify.

NOTE 2: What happens when I just call mplayer with vo -x11 is that it can not find a display, as DISPLAY is not set. The only valid value for DISPLAY is :0[.0], and when I use that display the video plays in tty7 but taking stdin from the tty that called the video.

NOTE 3: I am running Ubuntu Mate 16.04.1, amd64, and experience the same problem on multiple such systems with varying video cards.

Kyle
  • 655
  • Awesome! mpv with -vo drm worked and definitely looked better than mplayer with -vo fbdev2 (despite not being hardware acel). Can you please enlighten me as to why that worked? Also, the second option, with hardware acceleration, failed in mpv. It said it failed to set the command line option. Is there an extra dependency for that second option? – Kyle Aug 04 '16 at 23:06
  • I've turned my comments in to a proper answer, and also given a few hints about actually getting X11 to do what you want as well. – derobert Aug 05 '16 at 00:38

1 Answers1

4

Turning my comment in to an answer:

My best recommendation is to use mpv, which supports video-out drivers (and a lot more!) that AFAIK mplayer does not. Although mplayer development has recently seen some activity, for a long time (mplayer 1.1: June 2012; 1.2: October 2015) it was effectively dead. mpv, on the other hand, has had consistent releases since its first one in August 2013; it's honestly far ahead of mplayer at this point.

With mpv, you can directly use the kernel's mode setting and direct rendering manager (DRM) with mpv -vo drm FILE. This should provide full-quality, fully-resolution output, but without hardware acceleration (I don't believe fbdev2 ever had hardware acceleration). If your mpv is compiled with it, you can also use OpenGL/DRM output (which is hardware accelerated): mpv -vo opengl:backend=drm-egl FILE. You can check by seeing which backends are listed by mpv -vo opengl:backend=help

Alternatively, you can run an X server without a desktop environment. For example, depending on how your distro has configured things permissions-wise, you may be able to start an X server running just mplayer (and exiting when mplayer quits) using something like this:

startx /usr/bin/mpv FILE -- :1 # full path required; runs w/o xterm
startx -e mpv FILE -- :1       # runs it inside an xterm, which you'll probably see flicker on screen at start/exit.

You could of course use something like $(command -v mpv) to get the full path for the first form. That starts up display :1, runs mpv on it, and then shuts down the X server when mpv is done (I tried with mplayer, but it didn't work on my machine—given, possibly mplayer is just broken on my machine, I haven't used it since switching to mpv). You could also leave an X server running w/o a desktop environment. You may find something like nodm useful to start an X server w/o the desktop environment.

derobert
  • 109,670
  • So how might one recompile with OpenGL/DRM output support? I'm kind of new to this sort of thing. You can not do it using apt-get, can you? – Kyle Aug 05 '16 at 00:50
  • @Kyle It is indeed non-trivial... I suspect we already have a question on how to rebuild programs. apt-get can actually do a lot of the work for you (mainly, it can install all the dependencies) – derobert Aug 05 '16 at 00:55
  • 1
    @Kyle Basic instructions to recompile a Debian package are here: http://unix.stackexchange.com/questions/117503/how-to-compile-a-debian-package-from-source — you may want to ask a question specific to recompiling mkv w/ drm-egl though. – derobert Aug 05 '16 at 00:56
  • Sorry to have so many follow up questions, but is hardware acceleration likely to improve video quality, or is it generally only useful when there is jumping/skipping without it? – Kyle Aug 05 '16 at 01:28
  • And thanks for the info on using X, I ran mpv in X using that outline, but mplayer did not work for me either. – Kyle Aug 05 '16 at 01:29
  • 1
    @Kyle some of the opengl stuff can improve video quality, on sufficiently fast hardware (e.g., it can help smooth out low-framerate and framerate that doesn't match your display by blending adjacent frames, and there are shaders to do better scaling, denoising, etc.) But mostly it's to use less CPU to help playing back e.g., 1080p or 4k video on slower CPUs. Often uses less power (watts) as well, useful on laptops. – derobert Aug 05 '16 at 01:30
  • @Kyle the -e mplayer form (with xterm) worked for me with mplayer. Both forms work for me with mpv. – derobert Aug 05 '16 at 01:33
  • Thank you for that information on the effects of hardware acceleration. I may try recompiling later, but I have quality now that is good enough my monitory probably isn't good enough to distinguish anything better. And I tried mplayer with the -e option, and that worked for me as well. – Kyle Aug 05 '16 at 01:48