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

This forum is about all development around libVLC.
klchin
Blank Cone
Blank Cone
Posts: 18
Joined: 16 Jul 2009 18:19

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

Postby klchin » 24 Jul 2009 10:53

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.

kryptonite
Blank Cone
Blank Cone
Posts: 52
Joined: 22 May 2009 12:01

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

Postby kryptonite » 24 Jul 2009 11:04

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.

klchin
Blank Cone
Blank Cone
Posts: 18
Joined: 16 Jul 2009 18:19

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

Postby klchin » 24 Jul 2009 11:20

Hi Kryptonite,

Thx for you hints, will try it now.

klchin
Blank Cone
Blank Cone
Posts: 18
Joined: 16 Jul 2009 18:19

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

Postby klchin » 24 Jul 2009 11:28

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.

kryptonite
Blank Cone
Blank Cone
Posts: 52
Joined: 22 May 2009 12:01

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

Postby kryptonite » 27 Jul 2009 09:17

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.

klchin
Blank Cone
Blank Cone
Posts: 18
Joined: 16 Jul 2009 18:19

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

Postby klchin » 27 Jul 2009 12:23

Thx for your feedback.

Dwarf_ink
New Cone
New Cone
Posts: 2
Joined: 20 Sep 2021 21:09

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

Postby Dwarf_ink » 20 Sep 2021 21:15

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?

Dwarf_ink
New Cone
New Cone
Posts: 2
Joined: 20 Sep 2021 21:09

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

Postby Dwarf_ink » 22 Sep 2021 19:48

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;


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 27 guests