Page 1 of 1
Reading media data from custom sources
Posted: 01 Mar 2015 15:08
by realnc
Hello.
I'm trying to port some code from gstreamer to libVLC, and I'm not able to find a way to play media (video, in my case) from custom data sources. The use case is playing one video that is embedded in a file that contains several videos. Imagine:
Code: Select all
cat video1.mkv > video.dat
cat video2.mkv >> video.dat
...
cat video999.mkv >> video.dat
For example, I'd like to play the second video inside the video.dat file (the start offset inside the file and total length is bytes is known in advance.) In gstreamer, appsrc is used for that, with appropriate callbacks that feed bytes to gstreamer and seek around in the "virtual file" (which is a subset of the total file.)
Is that possible with libVLC?
Re: Reading media data from custom sources
Posted: 01 Mar 2015 15:58
by Jean-Baptiste Kempf
Yes, but not easily. You can use imem for this, but it's not very well stabilized, for lack of users.
Re: Reading media data from custom sources
Posted: 01 Mar 2015 16:05
by realnc
imem seems to require timing information about the video which I don't know anything about and for which I'd need libVLC in the first place (chicken and egg problem.)
So I guess the answer is "not possible at this time?"
Re: Reading media data from custom sources
Posted: 01 Mar 2015 16:15
by Jean-Baptiste Kempf
Oh, I see.
Then, you should do a custom stream filter module, like the RAR one.
Re: Reading media data from custom sources
Posted: 02 Mar 2015 11:32
by realnc
Somehow I missed that part of libVLC completely.
Thank you very much!
Re: Reading media data from custom sources
Posted: 02 Mar 2015 11:52
by Jean-Baptiste Kempf
Technically, it is a libVLCcore plugin you need to write
Re: Reading media data from custom sources
Posted: 02 Mar 2015 12:22
by realnc
I'm currently reading
the module guide and studying the vlc-2.2.0/modules/access/rar/ sources. I hope that's the correct starting point
In my case, the data will be coming from a FILE* pointer (or a filename, if that's not possible.) So I guess the correct starting point in this case would be the VLC plugin that handles normal file reading? Not sure where that is located yet. I assume that I would then request my custom plugin specifically (so that the normal file reading plugin isn't used,) pass the appropriate options to it (offset of the video and its length in bytes) and then call one of the libvlc_media_new_*() functions (also not sure which one yet
) I never worked with libVLC before, so I need to get familiar with the API first
Re: Reading media data from custom sources
Posted: 02 Mar 2015 14:40
by realnc
I'm not able to load my test module. Or rather "builtin", as it's compiled directly into my application. How does that work? It seems I need to somehow register the module with libVLC, so that it knows its name, but I can't see how.
A simple test:
Code: Select all
static int Open(vlc_object_t* vlcObj)
{
printf("*** TEST MODULE LOADING\n");
return VLC_EGENERIC;
}
static void Close(vlc_object_t *)
{ }
vlc_module_begin()
vlc_module_set(VLC_MODULE_NAME, "just_a_test");
set_shortname("just_a_test")
set_description("Just a test")
set_capability("access", 0)
set_callbacks(Open, Close)
set_category(CAT_INPUT)
set_subcategory(SUBCAT_INPUT_ACCESS)
vlc_module_end()
I would assume that this module would get loaded when I call:
Code: Select all
libvlc_media_new_location(vlcInstance, "just_a_test://foobarbaz");
But it's not finding it. Which makes sense, since it doesn't know anything about it. Is there a register function somewhere?