Reading media data from custom sources

This forum is about all development around libVLC.
realnc
Blank Cone
Blank Cone
Posts: 14
Joined: 28 Jul 2010 20:35
Operating System: Linux

Reading media data from custom sources

Postby realnc » 01 Mar 2015 15:08

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?

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Reading media data from custom sources

Postby Jean-Baptiste Kempf » 01 Mar 2015 15:58

Yes, but not easily. You can use imem for this, but it's not very well stabilized, for lack of users.
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

realnc
Blank Cone
Blank Cone
Posts: 14
Joined: 28 Jul 2010 20:35
Operating System: Linux

Re: Reading media data from custom sources

Postby realnc » 01 Mar 2015 16:05

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?"

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Reading media data from custom sources

Postby Jean-Baptiste Kempf » 01 Mar 2015 16:15

Oh, I see.

Then, you should do a custom stream filter module, like the RAR one.
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

realnc
Blank Cone
Blank Cone
Posts: 14
Joined: 28 Jul 2010 20:35
Operating System: Linux

Re: Reading media data from custom sources

Postby realnc » 02 Mar 2015 11:32

Somehow I missed that part of libVLC completely.

Thank you very much!

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Reading media data from custom sources

Postby Jean-Baptiste Kempf » 02 Mar 2015 11:52

Technically, it is a libVLCcore plugin you need to write :)
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

realnc
Blank Cone
Blank Cone
Posts: 14
Joined: 28 Jul 2010 20:35
Operating System: Linux

Re: Reading media data from custom sources

Postby realnc » 02 Mar 2015 12:22

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 :-P) I never worked with libVLC before, so I need to get familiar with the API first :-)

realnc
Blank Cone
Blank Cone
Posts: 14
Joined: 28 Jul 2010 20:35
Operating System: Linux

Re: Reading media data from custom sources

Postby realnc » 02 Mar 2015 14:40

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?


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 42 guests