create function to "LoadMediaFromBuffer"
frenos opened this issue · 2 comments
I would like to propose a new feature:
Create a function to load new media from a (go) []byte.
Background:
I'm creating a stream processor that gets a lot of short videos as bytes from a message queue, reads the metadata and writes that to another queue. libvlc-go is working great for this except one thing that is currently my bottleneck: I have to write all incoming blobs to a temporary file, process them and delete the temporary file. This causes a lot of unnecessary load on the disk.
Hi @frenos. Thank you for your interest in the library. This seems like a pretty useful feature.
libVLC does not make it easy to load media from byte streams. I need to implement the libvlc_media_new_callbacks binding in order to support this and probably an abstraction over io.ReadSeeker
to satisfy the callbacks libVLC requires, so it is not trivial.
However, this seems like a common use case, so it's definitely something I want to support. I'll start working on it when I get some free time. I'll let you know when this is done (most likely some time next week).
Hi @frenos. I added vlc.NewMediaFromReadSeeker
and Player.LoadMediaFromReadSeeker
in version 3.0.9.
You can use a bytes.Reader instance to create a ReadSeeker
from your byte data.
var videoBytes []byte
media, err := vlc.NewMediaFromReadSeeker(bytes.NewReader(videoBytes))
player.SetMedia(media)
or
var videoBytes []byte
media, err := player.LoadMediaFromReadSeeker(bytes.NewReader(videoBytes))