How to force VLC to play a video fullscreen at a specific size?

7,846

Your question made me curious all day. I've been playing around on an Ubuntu VM for the past hour and did a little digging.

The first two set of options you are using:

cvlc --fullscreen --vout glx --no-autoscale --scale 0.65 video.mp4

and

cvlc --fullscreen --vout glx --width 800 --height 519 video.mp4

are targeting window scaling. If you remove --fullscreen from your command, you will see that the window opening is the exact size as you specify, but once you enable fullscreen, the video plays in the original size.

I have tried every single option that includes the word width/height in the official VLC command-line help and the result is the same.


Your third command is your best case. The third command is the only one that affects the video stream and not the window. So you have to find the best percentage that will play your video exactly as you want to.

The suggestions I made in the comments for Devilspie2 and kpie are affecting the size of the window as well, so they may not seem appropriate in your case.

Right now, your best shot is to find the ideal number for the --zoom option


Zoom will not give you the exact size that you are looking for since there is no way to specify width and height with --zoom. If you are willing to give transcoding a shot, then you might get the expected results

Share:
7,846
linuxfan
Author by

linuxfan

Updated on September 18, 2022

Comments

  • linuxfan
    linuxfan over 1 year

    I have a video that's 1232×800 pixels in size, to be played on a projector with 1280×800 resolution, but constrained to a box of 800×800 in the middle of the screen, maintaining aspect ratio. So the actual video size would be about 800×519, i.e. scaled to about 65%; black bars are to be added on all sides:

    +---------screen---------+
    |                        |
    |    +----video-----+    |
    |    |              |    |
    8    5              |    |
    0    1              |    |
    0    9              |    |
    |    |              |    |
    |    +------800-----+    |
    |                        |
    +----------1280----------+
    

    I could alter the video file to include the black bars, but would rather avoid the inevitable quality loss (and codec hassles) from transcoding. Moreover, we'd like this to be easily adaptable to other resolutions in the future.

    So how to achieve this during playback using cvlc (i.e. just command line options)?

    Things I tried:

    1. cvlc --fullscreen --vout glx --no-autoscale --scale 0.65 video.mp4

      This is what the documentation (--help) of --autoscale and --scale would suggest. But it seems that --scale is just ignored.

    2. cvlc --fullscreen --vout glx --width 800 --height 519 video.mp4

      This doesn't seem to do anything. The video is still scaled to fit the screen.

    3. cvlc --fullscreen --vout glx --no-autoscale --zoom 0.6493506493506493 video.mp4

      This works on my machine (VLC 2.2.6) but reportedly results in a tiny video on the production system.

    I'm using VLC 2.2.2 on Ubuntu 16.04 LTS, so I cannot easily upgrade.

    • Seth
      Seth over 6 years
      Why not setup the projector in a way that it's just using that center space? Also make sure that Video > Always fit to Window isn't set.
    • linuxfan
      linuxfan over 6 years
      @Seth Can't, because it needs to use the other areas in some circumstances. Note that I asked cvlc specifically: there is no GUI, no clicky things. I would assume that that checkbox corresponds to --no-autoscale but there's no way to tell (apart from reading the source).
    • Jimmy_A
      Jimmy_A over 6 years
      Have you tried to transcode the video to the projector? set something like --sout-transcode-maxwidth=<integer> and --sout-transcode-maxheight=<integer>, Transcoding will transfer the data to the device to the desired format
    • linuxfan
      linuxfan over 6 years
      @D.A I have tried those flags, but by themselves they do nothing. Do I need to add more flags to make them work?
    • Jimmy_A
      Jimmy_A over 6 years
      I haven't used transcoder before. But what it does is that it decodes and re-encodes the video stream to a specified format. So I am assuming that you need to specify a video encoder as well. Check the transcode part in the documentation
    • Jimmy_A
      Jimmy_A over 6 years
      Also have a look at this daemon
    • linuxfan
      linuxfan over 6 years
      Transcoding on the fly sounds like it'll have all the drawbacks of quality loss and encoder hassles, plus possible performance issues if the encoder can't keep up. Devilspie is a good "out of the box" suggestion, but seems overly complicated for what should be a simple thing. (For one, VLC wouldn't be fullscreen, so I'd need to disable window decorations and somehow ensure a black background.)
    • Jimmy_A
      Jimmy_A over 6 years
      You mentioned in the question that the parameters you tried, are working on your machine but not on the projector. You may have tried that already but, have you checked all possible projections? Duplicate screens, only on screen two, extend screen?
    • linuxfan
      linuxfan over 6 years
      @D.A There is no monitor attached to the machine except the projector, so the setup is as simple as it gets. Any further testing is difficult, because the machine is not easily accessible.
  • linuxfan
    linuxfan over 6 years
    Thanks a lot for your digging! I did find a bug where my auto-zoom-calculator script returned 0 rather than 0.649... because the target system uses python2 instead of python3. Yet, setting --zoom 0 on my own machine just results in an error, not a tiny video as my client reports on the target system.
  • brunetton
    brunetton over 6 years
    @Jimmy_A I'm experimenting around the same problem, without any working solution so far. What version of VLC are you using ? Thanks
  • Jimmy_A
    Jimmy_A about 6 years
    @brunetton I now have version 2.2.2. But keep in mind that the answer is 6 months old. I think 2.2.2 was introduced around August so I might had 2.1.2 at the time. However, I get the same results.