Reputation: 2592
In a C# application I use LibVLC via NuGet packages.
I have created a MemoryStream and gave it to Media:
MemoryStream buffer = new MemoryStream();
bool playing = false;
public void dataArrived(byte[] d) {
buffer.Write(d, 0, d.Length);
if (!playing) {
playing = true;
mediaPlayer.Play(new Media(LibVLC, buffer));
}
}
Now dataArrived
is called when data is arrived from the network (this is a live stream).
Data is a valid mp4 stream (fragmented, plays nicely in HTML5 Video).
However VLC is not displaying it. In the log I see a lot of messages about prefetch:
prefetch stream debug: end of stream
VLC can read and dump the boxes, however there is a message (debug, not error!) which might be interesting:
mp4 demux debug: unrecognized major media specification (iso5).
Then there is another interesting batch of messages:
mp4 demux warning: cannot select track[Id 0x1]
main input debug: EOF reached
main decoder debug: killing decoder fourcc `h264'
main decoder debug: removing module "avcodec"
main demux debug: removing module "mp4"
mp4 demux debug: freeing all memory
main input debug: Program doesn't contain anymore ES
Is there some trick (config) for LibVLC to play fragmented mp4 on the fly (data is not available in advance)?
Or maybe MemoryStream
is a wrong choice for this purpose?
Upvotes: 1
Views: 1043
Reputation: 3979
The MemoryStream is not a good fit for a live stream, because it signals the end of the stream, because it can't know that new data will be added later.
Use your own implementation of Stream
or create your own MediaInput
.
Be careful, you seem to use an older version of LibVLCSharp. The newer API does not use a Stream directly, but needs a MediaInput to work.
If you manage to make it work, would you like to submit a live stream sample at LibVLCSharp? This is a feature that we are asked about.
Upvotes: 1