Page 1 of 1

Can not pass options to playlist.add()

Posted: 08 Feb 2017 17:25
by optimist_259
I need to embed vlc in my webpage to receive and play an udp audio stream.
This stream is a raw audio so some audio options need to be set.
However, function vlc.playlist.add(mrl, name, options) seems to ignore all options which is passed

Here is the code I use

Code: Select all

<embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org" version="VideoLAN.VLCPlugin.2" width="640" height="480" id="vlc"> </embed> <script type="text/javascript"> var options = new Array(" :demux=rawaud :rawaud-channels=2 :rawaud-samplerate=44100 :rawaud-fourcc=s16b"); vlc = document.getElementById("vlc"); var id = vlc.playlist.add("udp://@:2912/", "", options); vlc.playlist.playItem(id); </script>
With command line, audio is played correctly but it does nothing on my webpage.

If I use: vlc.playlist.add("udp/rawaud://@:2912/") I can hear something but it's not correctly decoded since other options can not be set.
Can someone help me?

vlc version: 2.2.2
browser-plugin-vlc version: 2.0.6-4
firefox version: 51.0.1

Re: Can not pass options to playlist.add()

Posted: 09 Feb 2017 11:19
by da2424
The syntax of the options array is incorrect. This should work:

Code: Select all

var options = new Array(":demux=rawaud", ":rawaud-channels=2", ":rawaud-samplerate=44100", ":rawaud-fourcc=s16b");

Re: Can not pass options to playlist.add()

Posted: 09 Feb 2017 12:48
by kodela
In my experience, both forms are possible. The VLC parsing the code as it needs it.

Re: Can not pass options to playlist.add()

Posted: 09 Feb 2017 14:09
by da2424
In my experience, both forms are possible. The VLC parsing the code as it needs it.
Yes, it's also possible to use a string with all the options included:

Code: Select all

var options = ":demux=rawaud :rawaud-channels=2 :rawaud-samplerate=44100 :rawaud-fourcc=s16b";
But if you use this in an array, VLC will not split the string into the options. (In ActiveX, this sample will currently work, because there is currently a bug, which will only parse the first array index)

Re: Can not pass options to playlist.add()

Posted: 09 Feb 2017 15:10
by kodela
But if you use this in an array, VLC will not split the string into the options. (In ActiveX, this sample will currently work, because there is currently a bug, which will only parse the first array index)
Thank you for the information!

Re: Can not pass options to playlist.add()

Posted: 09 Feb 2017 15:50
by optimist_259
The syntax of the options array is incorrect. This should work:

Code: Select all

var options = new Array(":demux=rawaud", ":rawaud-channels=2", ":rawaud-samplerate=44100", ":rawaud-fourcc=s16b");
I tried as you suggest but it does not work either.
I have also tried to pass only demux option

Code: Select all

var options = new Array(":demux=rawaud")
And I expect to have the same thing with

Code: Select all

vlc.playlist.add(udp/rawaud://@:2912)
but it does nothing. (above code give me some noise as vlc understands the demux is rawaud)
vlc plugin seems to ignore every options (my options) when it is passed in function playlist.add()

Re: Can not pass options to playlist.add()

Posted: 09 Feb 2017 21:41
by da2424
I have now tested it.
The script is correct, but the options are blocked. A part of the logs:

Code: Select all

core input error: unsafe option "demux" has been ignored for security reasons core input error: unsafe option "rawaud-channels" has been ignored for security reasons core input error: unsafe option "rawaud-samplerate" has been ignored for security reasons core input error: unsafe option "rawaud-fourcc" has been ignored for security reasons
I don't know when an option is declared as safe in the plugins, respectively libvlc.

But if you use this in an array, VLC will not split the string into the options. (In ActiveX, this sample will currently work, because there is currently a bug, which will only parse the first array index)
Thank you for the information!
No problem ;)
I have added a code example in the documentation to show both possibilities of use.

Re: Can not pass options to playlist.add()

Posted: 09 Feb 2017 22:46
by Jean-Baptiste Kempf
Hmm, that's not good, indeed

Re: Can not pass options to playlist.add()

Posted: 10 Feb 2017 08:11
by da2424
Hmm, that's not good, indeed
You mean that "rawaud-channels", "rawaud-samplerate" and "rawaud-fourcc" should be safe?

Re: Can not pass options to playlist.add()

Posted: 10 Feb 2017 14:11
by Jean-Baptiste Kempf
Hmm, that's not good, indeed
You mean that "rawaud-channels", "rawaud-samplerate" and "rawaud-fourcc" should be safe?
Maybe, yes.

Re: Can not pass options to playlist.add()

Posted: 12 Feb 2017 14:27
by Jean-Baptiste Kempf
This will be fixed for 3.0

Re: Can not pass options to playlist.add()

Posted: 16 Feb 2017 17:56
by optimist_259
So it's indeed an issue in plugin vlc.
Anyway, to avoid issue, I convert audio source to wav format so that I can launch plugin vlc without arguments

Thank everybody.

Re: Can not pass options to playlist.add()

Posted: 15 Feb 2018 19:11
by zirote69
This will be fixed for 3.0
I installed VLC v3.0.0 and activex inside still not working parameter options on Visual Studio 2010.

Anybody knows a sample code to record RTSP streaming to local file using ActiveX?

Here is my code:

Code: Select all

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim idVideo As Long 'ID para controlar qué posición en la lista ocupa el stream de video seleccionado. Dim Voptions As Object Voptions = Split("--sout=#duplicate{dst=display,dst=std{access=file,mux=ps,dst=""d:\\video.mpg""}}|", "|") With Me.AxVLCPlugin21 '.video.aspectRatio = "16:9" '.video.deinterlace.enable ("yadif") .Toolbar = False .playlist.items.clear() idVideo = .playlist.add("rtsp://192.168.10.171:554/stream2", "", Voptions(0)) .playlist.playItem(idVideo) End With End Sub
Thanks

Re: Can not pass options to playlist.add()

Posted: 20 Feb 2018 14:20
by Jean-Baptiste Kempf
This will be fixed for 3.0
I installed VLC v3.0.0 and activex inside still not working parameter options on Visual Studio 2010.

Anybody knows a sample code to record RTSP streaming to local file using ActiveX?

Here is my code:

Code: Select all

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim idVideo As Long 'ID para controlar qué posición en la lista ocupa el stream de video seleccionado. Dim Voptions As Object Voptions = Split("--sout=#duplicate{dst=display,dst=std{access=file,mux=ps,dst=""d:\\video.mpg""}}|", "|") With Me.AxVLCPlugin21 '.video.aspectRatio = "16:9" '.video.deinterlace.enable ("yadif") .Toolbar = False .playlist.items.clear() idVideo = .playlist.add("rtsp://192.168.10.171:554/stream2", "", Voptions(0)) .playlist.playItem(idVideo) End With End Sub
Thanks
Sout is not supported in ActiveX, of course.