How to choose video quality in VLCJ?

673 Views Asked by At

At the moment I'm using this HLS stream for testing:

https://cph-p2p-msl.akamaized.net/hls/live/2000341/test/master.m3u8

Very often the VLCJ player playing video starts at 144p quality which is bad. If after that start the video again, then the quality becomes 360p. When I switched the screen to the TV, it began to show video with 360p quality more often.

Also, before that, I created an application in C # with a VLC player. There, the video was launched at 144p quality, then after a while the quality changed to 720p automatically.

I run VLCJ without parameters, according to the most basic example

How to make sure that the best quality is chosen?

3

There are 3 best solutions below

0
Dmitriy On BEST ANSWER

I just solved my problem. I looked at what version of VLC is used when running vlc.dotnet.forms... VLC version is 3.0.17.4. I used VLC version 3.0.9.2 with vlcj. I ran vlcj with VLC 3.0.17.4 and the video started as 144p and then changed to 1080p! The problem was in the VLC version. So this is a real solution to the problem.

7
Mick On

The reason most players start at a low bit rate is to allow a quick start up initially, and they will then switch to a higher bit rate as the progress and assuming the device and network conditions support the higher bit rate.

You can see this behaviour on most premium streaming services.

Update - see discussion below and the separate answer from caprice for the correct approach for vlcj - the track API returns a single track rather than the list of individual rendition subtracks.

Original answer - see update above:

If you want to select the track yourself programatically you can do that in most players also. The syntax for VLCJ is:

mediaPlayer.setVideoTrack(newVideoTrack);

There is more detail, including how to query the available tracks, at this link here: https://capricasoftware.co.uk/projects/vlcj-3/tutorials/media-info

4
caprica On

There is no specific native API to deal with this, but you can do it with the media options parameter when you play media:

mediaPlayer.media().play(
  "https://cph-p2p-msl.akamaized.net/hls/live/2000341/test/master.m3u8",
  ":adaptive-logic=highest"
);

There are options available other than "highest":

  • predictive
  • nearoptimal
  • rate
  • fixedrate
  • lowest
  • highest

Use vlc -H and search for "adaptive" to find these values in the command-line help.

If you don't want to pass it as a media option each time you play media, you can set it on the MediaPlayerFactory (the syntax is slightly different):

MediaPlayerFactory factory = new MediaPlayerFactory("--adaptive-logic=highest");

To confirm this works, I used the stream URL from the posted question.

Without this setting it starts in 144p and later switches up to 1080p. With this setting it immediately starts 1080p playback.

Note that options passed in this way are unsupported and may change with any new release of VLC.