Page 1 of 1

Delphi how to do a streaming from file, camera and etc.

Posted: 24 Jul 2009 10:53
by klchin
Hi,

I wanted to know is the any sample code or steps to do a stream/broadcast by using LibVCL ver 1.0.0?
I do search all the threads, did not found any clear sample for it. All of the samples used AddTarget for
ActiveX method.

Currently I used

a) libvlc_media_new
b) libvlc_media_player_new_from_media
c) libvlc_media_player_set_hwnd
d) libvlc_media_player_play

I was able to play a stream video by calling 'udp://:1234' via libvlc_media_new

How to sepecify the parameter like
:sout=#transcode{vcodec=h264,vb=800,scale=1,acodec=mp4a,ab=128,channels=2,samplerate=22500}:
duplicate{dst=std{access=udp,mux=ts,dst=127.0.0.1:1234},dst=display}

Should I call libvlc_media_add_option before libvlc_media_player_new_from_media or what function?

TQ.

Re: Delphi how to do a streaming from file, camera and etc.

Posted: 24 Jul 2009 11:04
by kryptonite
This is how I achieve it:

Code: Select all

libvlc_media_new libvlc_media_add_option libvlc_media_player_set_media libvlc_media_release libvlc_media_player_play
I guess there could be other ways.
However, when adding options, make sure you add one at a a time.

Re: Delphi how to do a streaming from file, camera and etc.

Posted: 24 Jul 2009 11:20
by klchin
Hi Kryptonite,

Thx for you hints, will try it now.

Re: Delphi how to do a streaming from file, camera and etc.

Posted: 24 Jul 2009 11:28
by klchin
Hi Kryptonite,

Again, Thx for your your help, it work for me.

BTW, what will be advantage or disadvantage of

1.a) libvlc_media_new
1.b) libvlc_media_player_new_from_media

compare to (as to your method)

2.a) libvlc_media_player_new
2.b) libvlc_media_new
2.c) libvlc_media_player_set_media

TQ.

Re: Delphi how to do a streaming from file, camera and etc.

Posted: 27 Jul 2009 09:17
by kryptonite
I don't think either method is advantageous as such. They are just different ways to get the mediaPlayer object.
You could use any, depending on your design & requirements.

Re: Delphi how to do a streaming from file, camera and etc.

Posted: 27 Jul 2009 12:23
by klchin
Thx for your feedback.

Re: Delphi how to do a streaming from file, camera and etc.

Posted: 20 Sep 2021 21:15
by Dwarf_ink
Hello!
I need to send my audio via udp.The command for VLC is:

Code: Select all

'-vvv "\audiofiles\play.mp3" :sout=#transcode{vcodec=none,acodec=mp3,ab=128,channels=1,samplerate=44100,scodec=none}:udp{mux=ts,dst=224.0.224.1:11997} :no-sout-all :sout-keep'
I use a sample from wiki: https://wiki.videolan.org/Using_libvlc_with_Delphi/
It works fine, but it can play only locale. How can I call the same options?

Re: Delphi how to do a streaming from file, camera and etc.

Posted: 22 Sep 2021 19:48
by Dwarf_ink
Solved!

Code: Select all

procedure TForm1.btnPlayClick(Sender: TObject); var opt:PAnsiChar; begin // create new vlc instance vlcInstance := libvlc_new(0, nil); // create new vlc media from file vlcMedia := libvlc_media_new_path(vlcInstance, '\ffmpeg\music.mp3'); // if you want to play from network, use libvlc_media_new_location instead // vlcMedia := libvlc_media_new_location(vlcInstance, 'udp://@225.2.1.27:5127'); opt := ':sout=#transcode{vcodec=none,acodec=mp3,ab=128,channels=2,'+ 'samplerate=44100,scodec=none}:standard{access=udp,mux=ts,'+ 'dst=224.0.224.1:11991}'; libvlc_media_add_option(vlcMedia, opt); // create new vlc media player vlcMediaPlayer := libvlc_media_player_new_from_media(vlcMedia); // now no need the vlc media, free it libvlc_media_release(vlcMedia); // play video in a TPanel, if not call this routine, vlc media will open a new window libvlc_media_player_set_hwnd(vlcMediaPlayer, Pointer(Panel1.Handle)); // play media libvlc_media_player_play(vlcMediaPlayer); end;