Using libVLC ignores disabled hardware acceleration

This forum is about all development around libVLC.
yabbadidu
New Cone
New Cone
Posts: 7
Joined: 24 Jan 2019 09:45

Using libVLC ignores disabled hardware acceleration

Postby yabbadidu » 24 Jan 2019 10:34

I'm trying to perform some rtsp to webm transcoding using libVLC inside a c# project.
For some reasons, hardware acceleration is not working properly on my development machine (and apparently on 3 other machines, with various video cards, I have tested my solution on) ; I get the same situation if I try to do the transcoding directly from vlc.exe by calling it with

Code: Select all

vlc.exe rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov :network-caching=1000 :sout=#transcode{vcodec=VP80,vb=2000,acodec=vorb,ab=128,channels=2,samplerate=44100,scodec=none}:http{mux=webm,dst=:4000/stream} :no-sout-all :sout-keep"
This is the result
Image
On the other hand, if I add the --avcodec-hw=none parameter to the command line, it works flawlessly.

Now, my problem is that it appears that said parameter is ignored by libVNC. I have been using both Vlc.DotNet.Core and LibVLCSharp and in both cases I still get the hardware accelerated, green video; which brings me to think that somehow libVNC is ignoring the parameter? (looking at the source code, it appears it's overwriting the value with "" if libvlc_media_player_set_hwnd is being called, but I don't know if this is the case).
These are the logs I get, if they can be of help (not max verbosity)

Code: Select all

10:20:47.466|Info|Open 10:20:49.418|Warn|decoded zero sample 10:20:49.642|Info|Using D3D11VA (AMD Radeon HD 6570, vendor 1002(ATI), device 6759, revision 0) for hardware decoding
.

Is there something else I should be doing?
Thanks in advance

mfkl
Developer
Developer
Posts: 708
Joined: 13 Jun 2017 10:41

Re: Using libVLC ignores disabled hardware acceleration

Postby mfkl » 24 Jan 2019 10:48

Can you share your full c# code using libvlc please?
https://mfkl.github.io

yabbadidu
New Cone
New Cone
Posts: 7
Joined: 24 Jan 2019 09:45

Re: Using libVLC ignores disabled hardware acceleration

Postby yabbadidu » 24 Jan 2019 11:42

Sure, there you go

Code: Select all

private static DirectoryInfo VLCPATH = new DirectoryInfo( Path.Combine( Program.SERVICE_PATH, "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64" )); private static string[] VLCOPTIONS = new string[] { "--avcodec-hw=none" }; private static string SOURCE = "rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov"; private static string DESTINATION = @":sout=#transcode{vcodec=theo,vb=2000,acodec=vorb,ab=128,channels=2,samplerate=44100,scodec=none}:duplicate{dst=http{mux=ogg,dst=:$PORT$/stream},dst=file{dst=$FILE$}}"; private string[] _mediaOptions = new string[] { ":network-caching=1000", String.Empty, ":no-sout-all", ":sout-keep" }; // using LibVLCSharp public void StartStreamLibVLCSharp(string fileName, string port) { var vlc = new LibVLC(VLCOPTIONS); var mediaPlayer = new MediaPlayer(vlc); string filePath = String.Format("somefile-{0}.ogg", fileName); _mediaOptions[1] = DESTINATION.Replace("$PORT$", port).Replace("$FILE$", filePath); var media = new Media(vlc, SOURCE, Media.FromType.FromLocation); foreach (string opt in _mediaOptions) media.AddOption(opt); mediaPlayer.Play(media); } // using Vlc.DotNet.Core public void StartStreamVlcDotNet(string fileName, string port) { var vlc = new VlcMediaPlayer(VLCPATH, VLCOPTIONS); string filePath = String.Format("somefile-{0}.ogg", fileName); _mediaOptions[1] = DESTINATION.Replace("$PORT$", port).Replace("$FILE$", filePath); vlc.SetMedia(SOURCE, _mediaOptions); vlc.Play(); }

mfkl
Developer
Developer
Posts: 708
Joined: 13 Jun 2017 10:41

Re: Using libVLC ignores disabled hardware acceleration

Postby mfkl » 24 Jan 2019 12:44

By full I meant... full :-) upload your code on a git somewhere please.
https://mfkl.github.io

yabbadidu
New Cone
New Cone
Posts: 7
Joined: 24 Jan 2019 09:45

Re: Using libVLC ignores disabled hardware acceleration

Postby yabbadidu » 24 Jan 2019 14:43

Thanks, you can find a sample here then https://gitlab.com/SirePi/libvlc-test
You will need to grab manually VideoLAN.LibVLC.Windows from nuGet because, for some reasons, it seems it won't be restored in the target folder if it's already present in the packages' list when you first open the project.

Other than that, just start the solution and open test.html with a browser (it contains 2 video tags, one for each library's streaming port)

Thanks again!

Rémi Denis-Courmont
Developer
Developer
Posts: 15069
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Using libVLC ignores disabled hardware acceleration

Postby Rémi Denis-Courmont » 24 Jan 2019 17:19

Stream output support in LibVLC does not exist (yet).
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

yabbadidu
New Cone
New Cone
Posts: 7
Joined: 24 Jan 2019 09:45

Re: Using libVLC ignores disabled hardware acceleration

Postby yabbadidu » 25 Jan 2019 11:29

Sorry, but I don't understand what you mean with your answer.. am I doing something wrong or something that shouldn't be there?
I was always under the impression that VLC is only a graphical wrapper around libVLC, so if it works with VLC, why can't it be done in libVLC?

Moriquendi
Blank Cone
Blank Cone
Posts: 74
Joined: 31 May 2011 16:22

Re: Using libVLC ignores disabled hardware acceleration

Postby Moriquendi » 28 Jan 2019 09:30

Sorry, but I don't understand what you mean with your answer.. am I doing something wrong or something that shouldn't be there?
I was always under the impression that VLC is only a graphical wrapper around libVLC, so if it works with VLC, why can't it be done in libVLC?
So was I. Unfortunately some parameters in libVLC is hard coded, so no matter which parameters you pass, it will always default to that value. You can try to recompile the source code (which may be a really tiresome process if you are a Windows user like me), but there is no guarantee it will do the trick for you. Anyway, good luck.

yabbadidu
New Cone
New Cone
Posts: 7
Joined: 24 Jan 2019 09:45

Re: Using libVLC ignores disabled hardware acceleration

Postby yabbadidu » 28 Jan 2019 11:48

The weird part is that, as I said in the opening post, it works from VLC so there must be a way to have it understand that variable but it seems to be ignored if called from the outside.

Rémi Denis-Courmont
Developer
Developer
Posts: 15069
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Using libVLC ignores disabled hardware acceleration

Postby Rémi Denis-Courmont » 28 Jan 2019 19:31

LibVLC ignores the user configuration.

This is very much by design - LibVLC developers and application developers reasonably expect the default settings for (almost) everything. You would not want to have to force the thousand or so parameters to their default value one by one, just in case the local user changed them.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

yabbadidu
New Cone
New Cone
Posts: 7
Joined: 24 Jan 2019 09:45

Re: Using libVLC ignores disabled hardware acceleration

Postby yabbadidu » 30 Jan 2019 09:22

To be honest, I'm a bit surprised by this answer.. I understand that you don't want to have to manually set all parameters to their default value, but at the same time, as a developer and user, I'd like to have my custom values to be taken into account. What's the point of having parameters otherwise?

Anyway, back to the drawing board then.
Thanks for the answers!

cube45
New Cone
New Cone
Posts: 8
Joined: 15 Feb 2018 21:32

Re: Using libVLC ignores disabled hardware acceleration

Postby cube45 » 30 Jan 2019 10:09

Rémi,
By "user configuration", you also mean with options passed to libvlc? Why can we pass other options when playing and not when using a stream out chain?

If nothing can be done there, is there a way @yabbadidu can get his/her video card blacklisted for hw acceleration? Or maybe is that a bug that needs to be fixed in a future VLC release?

yabbadidu
New Cone
New Cone
Posts: 7
Joined: 24 Jan 2019 09:45

Re: Using libVLC ignores disabled hardware acceleration

Postby yabbadidu » 30 Jan 2019 10:22

If nothing can be done there, is there a way @yabbadidu can get his/her video card blacklisted for hw acceleration?
Unfortunately I don't think this is a good solution, as although I am currently working on this specific video card, I can't be sure nor force the hardware configuration of the final production system - which could even work properly with hardware acceleration but I can't be sure of that so I have to plan defensively. Thanks for the support though :D

LuckyT
Blank Cone
Blank Cone
Posts: 10
Joined: 05 Dec 2018 01:14

Re: Using libVLC ignores disabled hardware acceleration

Postby LuckyT » 30 Jan 2019 17:27

Rémi,
By "user configuration", you also mean with options passed to libvlc? Why can we pass other options when playing and not when using a stream out chain?

If nothing can be done there, is there a way @yabbadidu can get his/her video card blacklisted for hw acceleration? Or maybe is that a bug that needs to be fixed in a future VLC release?
Right? I can understand ignoring the local user's settings but I cannot understand why parameters the developer passes would be ignored, ever. The Quadro's decoding chip cannot handle many videos at once and basically the same single chip is used on a huge range of cards so upgrading the card makes no difference. Potentially an easy fix by disabled hardware acceleration but I wasn't able to do so because this odd behavior. Seems like a bug.

Additionally I was able to disable acceleration in VLC Player itself just fine, this is a libvlc issue I think.

Rémi Denis-Courmont
Developer
Developer
Posts: 15069
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Using libVLC ignores disabled hardware acceleration

Postby Rémi Denis-Courmont » 30 Jan 2019 19:16

Rémi,
By "user configuration", you also mean with options passed to libvlc? Why can we pass other options when playing and not when using a stream out chain?
I believe that the libvlc_new() API documentation has a very clear answer to that question:
The list of valid arguments depends on the LibVLC version, the operating system and platform, and set of available LibVLC plugins. Invalid or unsupported arguments will cause the function to fail (i.e. return NULL). Also, some arguments may alter the behaviour or otherwise interfere with other LibVLC functions.
(...)
There is absolutely no warranty or promise of forward, backward and cross-platform compatibility with regards to libvlc_new() arguments. We recommend that you do not use them, other than when debugging.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

Rémi Denis-Courmont
Developer
Developer
Posts: 15069
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Using libVLC ignores disabled hardware acceleration

Postby Rémi Denis-Courmont » 30 Jan 2019 19:21

What's the point of having parameters otherwise?
Parameters are there for the VLC executable command line interface and nothing else. If you use them otherwise, you are on your own.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

Rémi Denis-Courmont
Developer
Developer
Posts: 15069
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Using libVLC ignores disabled hardware acceleration

Postby Rémi Denis-Courmont » 30 Jan 2019 19:24

I can understand ignoring the local user's settings but I cannot understand why parameters the developer passes would be ignored, ever.
I can think of a lot of reasons:
  • They might not apply to the use case.
  • They might no longer exist in a new version.
  • They might not be available within the installed LibVLC platform or set of plugins.
  • They might conflict with documented LibVLC API functionality.
  • They might be overriden by LibVLC internally as part of its documented APU functionality.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

robUx4
Developer
Developer
Posts: 250
Joined: 31 Jan 2005 13:50
VLC version: master
Operating System: Windows
Contact:

Re: Using libVLC ignores disabled hardware acceleration

Postby robUx4 » 11 Feb 2019 15:48

I don't understand the same app but it is possible to enable/disable `avcodec-hw` through libvlc. There are cases where it's not going to work though. For example if you use `libvlc_video_set_callbacks()` or `libvlc_media_player_set_hwnd()`.

When you create your media to play, you can add options, for example `media.addOption(":avcodec-hw=none")` in libvlcpp. You set it before starting playback of the media you want to play.

MikOfClassX
Blank Cone
Blank Cone
Posts: 48
Joined: 29 Dec 2018 10:23

Re: Using libVLC ignores disabled hardware acceleration

Postby MikOfClassX » 13 Feb 2019 08:59

Apparently, when you set video callbacks, your hw acceleration goes away.
Now, if only the API would give you access to var_SetString()... you could do something more "dev-side". At your own risk.


Code: Select all

void libvlc_video_set_callbacks( libvlc_media_player_t *mp, void *(*lock_cb) (void *, void **), void (*unlock_cb) (void *, void *, void *const *), void (*display_cb) (void *, void *), void *opaque ) { var_SetAddress( mp, "vmem-lock", lock_cb ); var_SetAddress( mp, "vmem-unlock", unlock_cb ); var_SetAddress( mp, "vmem-display", display_cb ); var_SetAddress( mp, "vmem-data", opaque ); var_SetString( mp, "avcodec-hw", "none" ); var_SetString( mp, "vout", "vmem" ); var_SetString( mp, "window", "dummy" ); }

Rémi Denis-Courmont
Developer
Developer
Posts: 15069
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Using libVLC ignores disabled hardware acceleration

Postby Rémi Denis-Courmont » 13 Feb 2019 19:32

That is by hardware design. Hardware acceleration outputs decoded frames into video memory that is not generally accessible to the CPU. And even when it is accessible, it is typically in some unusable hardware-specific tiled formats.

If you want hardware acceleration, do not use the video callbacks. It will most probably never be supported because hardware will probably never support it.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37519
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Using libVLC ignores disabled hardware acceleration

Postby Jean-Baptiste Kempf » 16 Feb 2019 11:08

For that, you'll need the new OpenGL callback, for 4.0
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

MikOfClassX
Blank Cone
Blank Cone
Posts: 48
Joined: 29 Dec 2018 10:23

Re: Using libVLC ignores disabled hardware acceleration

Postby MikOfClassX » 18 Feb 2019 09:24

GL callback ? Sounds good. Will it support RGBA pixel format ?

Rémi Denis-Courmont
Developer
Developer
Posts: 15069
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Using libVLC ignores disabled hardware acceleration

Postby Rémi Denis-Courmont » 18 Feb 2019 17:24

No. It will use opaque surfaces that are not CPU-accessible.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

doubleaa93
New Cone
New Cone
Posts: 2
Joined: 13 Dec 2018 17:12

Re: Using libVLC ignores disabled hardware acceleration

Postby doubleaa93 » 16 Apr 2019 17:18

I'm looking at the new OpenGL callback in 4.0 but I only get sound and a black screen. Is this feature ready or still in development?

I'm using example from https://github.com/videolan/vlc/blob/ma ... player.cpp

sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

Re: Using libVLC ignores disabled hardware acceleration

Postby sherington » 16 Apr 2019 18:36

Those new OpenGL callbacks did work for me last time I tried, maybe a month ago or so. I've had video playing in an LWJGL application (I use Java).


Return to “Development around libVLC”

Who is online

Users browsing this forum: Bing [Bot] and 2 guests