1

I have an app in vb.net (winForms) that I want to play a valid TS with the video & audio PIDs. It works fine if I stream it using TCP/UDP protocol from the app itself, but I want to do it without doing a network stream.

I see this can be doing using StreamMediaInput, but I don't know how to do it.

I have this:

Private Sub WriteStream(ByVal Data() As Byte, ByVal len As Integer)
 'Data() array is the video TS (MPEG-2) (188 bytes len)
 vlc_memorystream.Write(Data, 0, len)
End Sub

Doing stream to TCP to a libvlcsharp is ok, how I can doing it directly passing the Data() array to libvlcsharp?

Thank you.

https://github.com/videolan/libvlcsharp

Edit:

I am able to watch the stream putting this line inside the sub:

vlc_memorystream.Write(Data, 0, len)

The problem is the buffer. It plays well few seconds and then it stops playback. How I can handle this?

cbn
  • 21
  • 1
  • 1
  • 5

2 Answers2

1

As explained here : https://code.videolan.org/videolan/LibVLCSharp/-/issues/526#note_294698 , a MemoryStream won't do it as libvlc reads the data faster than they arrive and assumes the stream is finished.

You need to either implement a Stream that blocks the Read() call until data is available (or use an existing Stream implementation), or use your own MediaInput for that.

I have implemented such media input here : https://github.com/jeremyVignelles/libvlcsharp-nonfree-samples

cube45
  • 3,429
  • 2
  • 24
  • 35
0

you can Use this code in C# for LibVLC:

MemoryStream stream = ...
mediaPlayer.Play(new Media(libVLC, new StreamMediaInput(stream)));
Elyas Nategh
  • 540
  • 6
  • 5