1

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?

Dmitriy
  • 375
  • 1
  • 18

3 Answers3

1

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

Mick
  • 24,231
  • 1
  • 54
  • 120
  • Thanks for the answer. The fact is that VLC in C# worked just like that. It started in low quality and switched to higher quality almost immediately. But in Java and Javafx it doesn't work that way. It turns on in low quality and it does not get better. It will only get better if you run the same hls stream again. I would like it to switch itself, without my intervention. – Dmitriy Oct 05 '22 at 21:49
  • Maybe there is some setting for VLC that sets it to automatically improve quality when possible? – Dmitriy Oct 05 '22 at 21:58
  • Is this on the same device and network - I might be worth testing across several devices and networks. It definitely should switch ups to the best available rendition. – Mick Oct 06 '22 at 10:42
  • @caprica - to clarify, do you mean that vlcj does not start at a low bit rate and automatically increase or do you mean that it is not possible to select a track explicitly using the syntax above? – Mick Oct 06 '22 at 12:17
  • @caprica - ok, thanks. Any reason why it is not possible, as it seems from the documentation it should be and the approach is similar to that used in other players. Is it that the API is not currently supported, or do you mean that you would not be able to tell the bit rate of the tracks and hence it would be hard to decide which one to use? – Mick Oct 06 '22 at 12:28
  • 1
    @caprica - thanks for the detailed explanation, really useful. I'll update the answer and leave it here as useful background but print towards your one as the right approach. – Mick Oct 06 '22 at 13:37
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/248598/discussion-between-mick-and-caprica). – Mick Oct 06 '22 at 15:32
1

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.

caprica
  • 3,902
  • 4
  • 19
  • 39
  • Thanks for the answer. This is what I need. I don't know why my VLCJ player doesn't switch video to the best quality on its own. Always starts either 144r or 360r (very rarely). Using the '--adaptive-logic=highest' option, I managed to launch the video in the best quality, while it does not slow down, it plays perfectly, so it's strange for me that the player does not do this on its own. The 'predictive', 'nearoptimal', 'rate' options ran the video in 144p quality. You will have to add an item in the settings with a stream quality priority ... – Dmitriy Oct 06 '22 at 23:04
  • Is there a site where I can read about these parameters? vlc.exe -H didn't work for me. – Dmitriy Oct 06 '22 at 23:09
0

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.

Dmitriy
  • 375
  • 1
  • 18