Page 1 of 1

Play stream using VLC Mesdia Player

Posted: 21 Feb 2019 07:05
by chamanlata
I am just using this code to play a stream .but this code is not running please help

Code: Select all

libvlc_instance_t * inst; libvlc_media_player_t *mp; libvlc_media_t *m; /* Load the VLC engine */ inst = libvlc_new (0, NULL); /* Create a new item */ m = libvlc_media_new_path (inst, "rtp://10.0.0.1:5100/Video2"); //m = libvlc_media_new_path (inst, "/path/to/test.mov"); mp = libvlc_media_player_new_from_media (m); libvlc_media_player_play (mp);

Re: Play stream using VLC Mesdia Player

Posted: 21 Feb 2019 10:27
by unidan
Hi, what do you mean by "it's not running" ?

Re: Play stream using VLC Mesdia Player

Posted: 21 Feb 2019 11:29
by chamanlata
Hi,
Now my code is working fine and video is playing successfully .but the issue now is that it just play the video for the time dfepend on Sleep function.How can I play it without sleep function until it is finished
libvlc_instance_t * inst;
libvlc_media_player_t *mp;
libvlc_media_t *m;

/* Load the VLC engine */
inst = libvlc_new (0, NULL);

/* Create a new item */
m = libvlc_media_new_path (inst, "rtp://10.0.0.1:5100/Video2");
//m = libvlc_media_new_path (inst, "/path/to/test.mov");

mp = libvlc_media_player_new_from_media (m);

libvlc_media_player_play (mp);
Sleep(30000)

Re: Play stream using VLC Mesdia Player

Posted: 21 Feb 2019 13:41
by unidan
You have to add a callback to wait for the end, block your thread on a semaphore and release it in the callback.

check these functions:
https://www.videolan.org/developers/vlc ... 082b38948e
https://www.videolan.org/developers/vlc ... fd2387f2cc
https://www.videolan.org/developers/vlc ... c56f4cf766

Re: Play stream using VLC Mesdia Player

Posted: 26 Feb 2019 11:40
by chamanlata
Hi @unidan
when I am using the stream like for mms:// or with rtsp:// they all are worked fine but if I am using rtp stream then got the error"VLC is unable to play invalid mrl"
Please help !!
m = libvlc_media_new_path (inst, "rtp://@10.0.0.1:5100/Video2");

Re: Play stream using VLC Mesdia Player

Posted: 26 Feb 2019 11:59
by unidan
Please give more logs. Does it works with VLC ?

Re: Play stream using VLC Mesdia Player

Posted: 27 Feb 2019 04:39
by chamanlata
These are the logs whenever I am trying to use the play any RTP address.

[032569dc] main demux error: socket bind error (Cannot assign requested address)
[032569dc] main demux error: socket bind error (Cannot assign requested address)
[030305bc] main input error: open of `rtp://@10.0.0.1:5100/Video2' failed
[030305bc] main input error: Your input can't be opened
[030305bc] main input error: VLC is unable to open the MRL 'rtp://@10.0.0.1:5100/Video2'.

Re: Play stream using VLC Mesdia Player

Posted: 27 Feb 2019 09:49
by chubinou
Hi,

Is 10.0.0.1 the address of your player? RTP works by opening a port on your client and waiting for the server to send you packets on this port.

RTP address are usually something like rtp://my.ip.add.ress:port/

Re: Play stream using VLC Mesdia Player

Posted: 27 Feb 2019 12:07
by chamanlata
rtp://10.0.0.1:5100/Video2 is the address from where I have to receive the Live stream in VLC.But I am Not able to do that.
I already open the port No 5100 and I also tried with the format rtp://@:5100\Video2 but it is also not working?

Re: Play stream using VLC Mesdia Player

Posted: 27 Feb 2019 14:38
by chubinou
How is your streamer configured?

either it sends you the stream in unicast (or broadcast) to your player (then you can use rtp://@:5100)
or it sends the stream to a multicast address (ie: 239.0.0.1), then you should put rtp://239.0.0.1:5100/

Re: Play stream using VLC Mesdia Player

Posted: 28 Feb 2019 06:05
by chamanlata
Yes, It is worked For me. Thank you for your time RTP://@:5100