3

I run VLC player and It starts in my command line as well, how to run It in background and to output only via HDMI? Raspbian OS (Raspberry)

1

I'm not sure how Raspbian OS handle multiple outputs, but I'm assuming its using the current common practice, which is to use Xinerama - i.e. multiple screens are used by the same "display" (in X11 terms). In such a case, you basically can't "select an output port" - all outputs are on the same display (you can think of it as a virtual screen that covers all of your screens, and possibly more).

To target a specific "screen" (the X11 term, which means a part of a display), you need to ask the X server which part of the display is mapped to the screen you want, and then force VLC to render to that area. The standard way to do this is to use a --geometry flag that the application should recognize and accept a very specific format that looks like this: <width>X<height>+<X>+<Y> - which is (not)incidentally the exact format that the X server query tool displays that information - run xrandr and see.

Unfortunately, VLC doesn't accept such a parameter - it has to be different. Instead it uses 4 different parameters: --width, --height, --video-x, and --video-y.

So here is a short script that uses xrandr to get the geometry of the first connected HDMI port (I have multiple, so its useful like that) and then breaks up the geometry specification from xrandr to launch VLC with the correct parameters:

geom=( $(xrandr | grep ' connected' | grep HDMI | head -n1 | cut -d' ' -f3 | tr 'x+' '  ') ); \
  [ -n "${geom[*]}" ] && vlc \
    --width=${geom[0]} --height=${geom[1]} \
    --video-x=${geom[2]} --video-y=${geom[3]} \
    my-video.mp4

(formatted to multiple lines with backslashes for readability, this should be on a one line, but will run fine as it is - with the backslashes).

[Update]: Now that I re-read your question it appears to me that you may mean that you want to run your script from outside the X server session, in which case you also need to set up the DISPLAY environment variable correctly. So try to set the DISPLAY before you run VLC by running export DISPLAY=:0.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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