retrieving codec information
Posted: 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.
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.