retrieving codec information

This forum is about all development around libVLC.
pbekaert
New Cone
New Cone
Posts: 9
Joined: 24 Jul 2009 18:35

retrieving codec information

Postby pbekaert » 28 Jul 2009 21:50

Dear all,

What is the preferred way of retrieving codec information in libvlc, such as (unscaled) video resolution, or frame rate?
I would like to know the unscaled video resolution in order to create a vmem video output with the native resolution of the video, avoiding image scaling.

I notice the qt4 interface (modules/gui/qt4/components/info_panels.cpp) retrieves codec information from an input_item_t (pp_categories member). However, the input_item_t object pointed to in my libvlc_media_t p_input_item member does not seem to contain any information, even while the video is playing and everything seems to have been initialized properly.

I expected the input_item_t i_es and pp_es members might have contained useful information as an alternative, but also these are
empty.

Where and when does the libvlc_media_t p_input_item object get initialized, or what other input_item_t shall be inspected?
Thanks in advance and best regards,

Philippe.


Fyi, this is my code:

Global variables (well ... member variables of a C++ class called VideoLANPlayer) :

struct libvlc_exception_t *ex;
struct libvlc_instance_t *vlc;
struct libvlc_media_t *m;
struct libvlc_media_player_t *mp;

void checkerr(void); // checks for vlc exception

Opening a file ( file name in char* mrl, vmem window width and height given in wwidth, wheight) :

if (!ex) ex = new libvlc_exception_t;
libvlc_exception_init(ex);

pixels = new unsigned char [wwidth*wheight*3];

char clock[64], cunlock[64], cdata[64];
char cwidth[32], cheight[32], cpitch[32];
char const *vlc_argv[] =
{
"--plugin-path", VLC_PLUGIN_PATH,
"--ignore-config", /* Don't use VLC's config files */
"--no-osd",
"--vout", "vmem",
"--vmem-width", cwidth,
"--vmem-height", cheight,
"--vmem-pitch", cpitch,
"--vmem-chroma", "RV24",
"--vmem-lock", clock,
"--vmem-unlock", cunlock,
"--vmem-data", cdata,
};
sprintf(clock, "%lld", (long long int)(intptr_t)_lock);
sprintf(cunlock, "%lld", (long long int)(intptr_t)_unlock);
sprintf(cdata, "%lld", (long long int)(intptr_t)this);
sprintf(cwidth, "%i", wwidth);
sprintf(cheight, "%i", wheight);
sprintf(cpitch, "%i", wwidth * 3);
int vlc_argc = sizeof(vlc_argv) / sizeof(*vlc_argv);

vlc = libvlc_new(vlc_argc, vlc_argv, ex); checkerr();
m = libvlc_media_new(vlc, mrl, ex); checkerr();
mp = libvlc_media_player_new_from_media(m, ex); checkerr();
libvlc_media_release(m); checkerr();


Retrieving information:

#include "vlc/src/control/media_internal.h"
#include "vlc/plugins/vlc_input_item.h"

input_item_t *it = m->p_input_item;

fprintf(stderr, "VideoLANPlayer:: media %s info: %d categories.\n", it->psz_uri, it->i_categories);
for (int i=0; i<it->i_categories; i++) {
info_category_t *ic = it->pp_categories;
fprintf(stderr, "%s:\n", ic->psz_name);
for (int j=0; j<ic->i_infos; j++) {
info_t *inf = ic->pp_infos[j];
fprintf(stderr, " %s: %s\n", inf->psz_name, inf->psz_value);
}
}

fprintf(stderr, "%d es.\n", it->i_es);

Output:

VideoLANPlayer:: media (null) info: 0 categories.
0 es.

Rémi Denis-Courmont
Developer
Developer
Posts: 15257
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: retrieving codec information

Postby Rémi Denis-Courmont » 29 Jul 2009 18:40

That's not going to work. By the time you learn the resolution, vmem will be initialized.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

pbekaert
New Cone
New Cone
Posts: 9
Joined: 24 Jul 2009 18:35

Re: retrieving codec information

Postby pbekaert » 31 Jul 2009 10:42

It seems that libvlc_video_get_width and libvlc_video_get_height return unscaled video resolution, solving the most important part of my problem ... BUT ... only after the first frame of the video has been produced. Before, these functions behave erroneously.

I understand these functions are depreciated in favor of some broader mechanism. What else do you recommend?

The rest is probably an ABI issue. Will check later.

Thanks for your reply,

Philippe.

pbekaert
New Cone
New Cone
Posts: 9
Joined: 24 Jul 2009 18:35

Re: retrieving codec information

Postby pbekaert » 31 Jul 2009 20:23

I appreciate this kind of subtle humor very much!
But it doesn't answer my question of course.
Best,

Philippe.

Rémi Denis-Courmont
Developer
Developer
Posts: 15257
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: retrieving codec information

Postby Rémi Denis-Courmont » 01 Aug 2009 10:00

As I said, there is no way to get the information before video decoder has declared the video format, which requires playback to be started.
In fact, with some formats, the video dimension can change... so fundamentally, there is no way to "fix" libvlc_video_get_*().

The problem comes entirely from the vmem plugin here. Other (not all) video outputs check the video dimensions before they when they are initialized; vmem does not.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 19 guests