How does VLC handle HTTP streams?

This forum is about all development around libVLC.
heftylou
New Cone
New Cone
Posts: 3
Joined: 16 Aug 2018 03:22

How does VLC handle HTTP streams?

Postby heftylou » 16 Aug 2018 03:48

Hello, I'm currently trying to make an application that can display a live stream from a URL using HTTP. The actual stream is represented as a .ts file.

An example URL would be: "http://host.me:9999/streams/snek.ts"

I'm writing my program in Java, using vlcj and so far, this is the code I have so far: https://pastebin.com/dnqQ6Yt9

The thing is, it pauses... alot.

Now, I know I can change my code to be something like this:

Code: Select all

SwingUtilities.invokeLater(new Runnable() { public void run() { JFrame frame = new JFrame("A GUI"); frame.setBounds(100, 100, 600, 400); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); EmbeddedMediaPlayerComponent mediaPlayer = new EmbeddedMediaPlayerComponent(); frame.setContentPane(mediaPlayer); frame.setVisible(true); //play the StreamMedia object I've created //Play the URL directly instead of creating my own Media class mediaPlayer.getMediaPlayer().playMedia("MY URL"); } });
And that in-fact fixes my stuttering/pausing problem because VLC handles all the network stuff.

However, I also want to record the stream itself and by going this route, I won't be able to customize how VLC reads from the stream.

What am I missing in my original code that's preventing from having the smooth playback as passing in the URL directly?
I've tried buffered inputstreams, but things are read to quickly and it's back to square one with the stuttering.

I'm pretty new to the vlc community and vlcj so apologies if I'm missing obvious things. I also don't have much experience with http.

Thanks.

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

Re: How does VLC handle HTTP streams?

Postby Rémi Denis-Courmont » 16 Aug 2018 19:46

Your code is probably taking too long to return data, so the VLC buffers get empty.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

heftylou
New Cone
New Cone
Posts: 3
Joined: 16 Aug 2018 03:22

Re: How does VLC handle HTTP streams?

Postby heftylou » 16 Aug 2018 21:33

Any suggestions to avoid that?

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

Re: How does VLC handle HTTP streams?

Postby Rémi Denis-Courmont » 20 Aug 2018 17:26

Return data faster.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

heftylou
New Cone
New Cone
Posts: 3
Joined: 16 Aug 2018 03:22

Re: How does VLC handle HTTP streams?

Postby heftylou » 24 Aug 2018 03:09

The thing is I can't. I've given my current code and as far as I know, that's how you create an http connection.

My main question is how vlc itself handles an http link when opening media.

User avatar
InTheWings
Developer
Developer
Posts: 1275
Joined: 07 Aug 2013 13:15
VLC version: crashing
Operating System: Linux
Contact:

Re: How does VLC handle HTTP streams?

Postby InTheWings » 24 Aug 2018 10:52

The right question is: Is there a standard Header in HTTP to flag the content as Paced vs non Paced ?
:!: If you want your problem to be solved :
* First read troubleshooting guide VSG:Main
* Always provide verbose LOGS ! (command line or from gui)
* Always check your issue against a developer build from Nightly Build of VLC
* Tell us when your problem is solved !

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

Re: How does VLC handle HTTP streams?

Postby Rémi Denis-Courmont » 24 Aug 2018 16:07

My main question is how vlc itself handles an http link when opening media.
Well... it implements the HTTP protocol on client side using BSD sockets.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded


Return to “Development around libVLC”

Who is online

Users browsing this forum: Google [Bot], mfkl and 12 guests