Contenu | Rechercher | Menus

Annonce

Si vous avez des soucis pour rester connecté, déconnectez-vous puis reconnectez-vous depuis ce lien en cochant la case
Me connecter automatiquement lors de mes prochaines visites.

À propos de l'équipe du forum.

#1 Le 13/02/2007, à 01:16

Kuroro20

Bibliotheque pour lire des videos en C

Salut a tous,

Voila je voudrais vous demander si vous conaissiez des libs qui me permettrait la lecture de fichiers videos.
J'aimerais bien que la librairie soit documentée, portable, (windows/linux).

Et si vous avez des adresses de sites qui expliquent comment fonctionne la lecture de video (comment fonctionnent les fonctions des libs qui permettent de lire les videos en gros), je suis preneur.

Bien sur anglais ou francais ne me gene pas.

Merci d'avance pour vos reponses.

#2 Le 13/02/2007, à 01:21

Link31

Re : Bibliotheque pour lire des videos en C

Regarde du côté de Xine-lib.

Hors ligne

#3 Le 13/02/2007, à 02:25

Kuroro20

Re : Bibliotheque pour lire des videos en C

Merci tongue

Alors j'ai maté et fait le tour du site et la O_o. Pas habitué a ca, les seules lib que j'ai etudie jusqu'a la sont Fmod et GTK+  avec pas mal de tuto et une doc reunissant les fonctions. Et la beh ca m'a l'air moins accessible du coup.

La seule partie qui a l'air interessant pour un debutant est le hackers guide  sauf qu'il inclut des lib venant de X11, etant donné que j'ai pas encore regarde plus precisement je me demande si ces libs permettent juste la mise en place de l'interface graphique , ou sont indispensable a la lecture video.

De plus je pense que ces libs n'existent pas sous windows, ou sinon je ne connais pas les equivalents.
Pareil pour l'installation de la lib,sous ubuntu pas de pb mais sous windows, beh j'ai du mal a piger le truc.
Mais bon on est sur un fofo ubuntu tongue, je vais pas m'amuser a poser des questions sur l'install d'une lib sur windows

#4 Le 13/02/2007, à 04:00

Link31

Re : Bibliotheque pour lire des videos en C

#  MS Windows (partially working and committed to CVS)

Il suffit juste d'attendre un peu que Xine devienne compatible avec w$. En attendant tu peux coder sous Linux, ça ne sera pas perdu.

Xine est une bibliothèque permettant de lire plein de formats vidéo, y compris en streaming. Il y a un peu de code à intégrer dans ton programme pour pouvoir l'utiliser, mais rien d'insurmontable. Si tu n'as pas déjà une interface graphique, tu peux utiliser Xine dans sa propre fenêtre.

Un petit exemple pour commencer :

muxine.c :

/*
** Copyright (C) 2003 Daniel Caujolle-Bert <segfault@club-internet.fr>
**  
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**  
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**  
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**  
* $Id: muxine.c,v 1.4 2005/09/12 00:47:03 miguelfreitas Exp $
*/
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <sys/time.h>

#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>

#include <xine.h>
#include <xine/xineutils.h>

#ifndef VERSION
#define VERSION                   "0.0.6"
#endif

static xine_t              *xine;
static xine_stream_t       *stream;
static xine_video_port_t   *vo_port;
static xine_audio_port_t   *ao_port;
static xine_event_queue_t  *event_queue;

static Display             *display;
static int                  screen;
static Window               window;
static int                  xpos, ypos, width, height;
static double               pixel_aspect;
static int                  running = 0;

#define INPUT_MOTION (ExposureMask | ButtonPressMask | KeyPressMask | \
                      ButtonMotionMask | StructureNotifyMask |        \
                      PropertyChangeMask | PointerMotionMask)

static void dest_size_cb(void *data, int video_width, int video_height, double video_pixel_aspect,
			 int *dest_width, int *dest_height, double *dest_pixel_aspect)  {

  *dest_width        = width;
  *dest_height       = height;
  *dest_pixel_aspect = pixel_aspect;
}

static void frame_output_cb(void *data, int video_width, int video_height,
			    double video_pixel_aspect, int *dest_x, int *dest_y,
			    int *dest_width, int *dest_height, 
			    double *dest_pixel_aspect, int *win_x, int *win_y) {
  *dest_x            = 0;
  *dest_y            = 0;
  *win_x             = xpos;
  *win_y             = ypos;
  *dest_width        = width;
  *dest_height       = height;
  *dest_pixel_aspect = pixel_aspect;
}

static void event_listener(void *user_data, const xine_event_t *event) {
  switch(event->type) { 
  case XINE_EVENT_UI_PLAYBACK_FINISHED:
    running = 0;
    break;
  }
}
  
int main(int argc, char **argv) {
  char              configfile[2048];
  x11_visual_t      vis;
  double            res_h, res_v;
  char             *vo_driver    = "auto";
  char             *ao_driver    = "auto";
  char             *mrl = NULL;
  int               i;

  printf("muxine (xine  player) v%s\n"
	 "(c) 2003 by Daniel Caujolle-Bert <f1rmb@users.sourceforge.net>.\n", VERSION);

  if(argc <= 1) {
    printf("specify one mrl\n");
    return 0;
  }
  
  if(argc > 1) {
    for(i = 1; i < argc; i++) {
      if(!strcmp(argv[i], "-vo")) {
	vo_driver = argv[++i];
      }
      else if(!strcmp(argv[i], "-ao")) {
	ao_driver = argv[++i];
      }
      else if((!strcmp(argv[i], "-h")) || (!strcmp(argv[i], "--help"))) {
	printf("Options:\n");
	printf("  -ao <ao name>           Audio output plugin name (default = alsa).\n");
	printf("  -vo <vo name>           Video output plugin name (default = Xv).\n");
	return 0;
      }      
      else {
	mrl = argv[i];
      }
    }
  }
  else
    mrl = argv[1];

  if(!XInitThreads()) {
    printf("XInitThreads() failed\n");
    return 0;
  }

  xine = xine_new();
  sprintf(configfile, "%s%s", xine_get_homedir(), "/.xine/config");
  xine_config_load(xine, configfile);
  xine_init(xine);
 
  if((display = XOpenDisplay(getenv("DISPLAY"))) == NULL) {
    printf("XOpenDisplay() failed.\n");
    return 0;
  }
    
  screen       = XDefaultScreen(display);
  xpos         = 0;
  ypos         = 0;
  width        = 320;
  height       = 200;

  XLockDisplay(display);
  window = XCreateSimpleWindow(display, XDefaultRootWindow(display),
			       xpos, ypos, width, height, 1, 0, 0);
  
  XSelectInput (display, window, INPUT_MOTION);

  XMapRaised(display, window);
  
  res_h = (DisplayWidth(display, screen) * 1000 / DisplayWidthMM(display, screen));
  res_v = (DisplayHeight(display, screen) * 1000 / DisplayHeightMM(display, screen));
  XSync(display, False);
  XUnlockDisplay(display);

  vis.display           = display;
  vis.screen            = screen;
  vis.d                 = window;
  vis.dest_size_cb      = dest_size_cb;
  vis.frame_output_cb   = frame_output_cb;
  vis.user_data         = NULL;
  pixel_aspect          = res_v / res_h;

  if(fabs(pixel_aspect - 1.0) < 0.01)
    pixel_aspect = 1.0;
  
  if((vo_port = xine_open_video_driver(xine, 
				       vo_driver, XINE_VISUAL_TYPE_X11, (void *) &vis)) == NULL) {
    printf("I'm unable to initialize '%s' video driver. Giving up.\n", vo_driver);
    return 0;
  }
  
  ao_port     = xine_open_audio_driver(xine , ao_driver, NULL);
  stream      = xine_stream_new(xine, ao_port, vo_port);
  event_queue = xine_event_new_queue(stream);
  xine_event_create_listener_thread(event_queue, event_listener, NULL);

  xine_gui_send_vo_data(stream, XINE_GUI_SEND_DRAWABLE_CHANGED, (void *) window);
  xine_gui_send_vo_data(stream, XINE_GUI_SEND_VIDEOWIN_VISIBLE, (void *) 1);

  if((!xine_open(stream, mrl)) || (!xine_play(stream, 0, 0))) {
    printf("Unable to open mrl '%s'\n", mrl);
    return 0;
  }

  running = 1;

  while(running) {
    XEvent xevent;
    int    got_event;

    XLockDisplay(display);
    got_event = XPending(display);
    if( got_event )
      XNextEvent(display, &xevent);
    XUnlockDisplay(display);
    
    if( !got_event ) {
      xine_usec_sleep(20000);
      continue;
    }

    switch(xevent.type) {

    case Expose:
      if(xevent.xexpose.count != 0)
        break;
      xine_gui_send_vo_data(stream, XINE_GUI_SEND_EXPOSE_EVENT, &xevent);
      break;
      
    case ConfigureNotify:
      {
	XConfigureEvent *cev = (XConfigureEvent *) &xevent;
	Window           tmp_win;
	
	width  = cev->width;
	height = cev->height;
	
	if((cev->x == 0) && (cev->y == 0)) {
	  XLockDisplay(display);
	  XTranslateCoordinates(display, cev->window,
				DefaultRootWindow(cev->display),
				0, 0, &xpos, &ypos, &tmp_win);
	  XUnlockDisplay(display);
	}
	else {
	  xpos = cev->x;
	  ypos = cev->y;
	}
      }
      break;

    }
  }
  
  xine_close(stream);
  xine_event_dispose_queue(event_queue);
  xine_dispose(stream);
  if(ao_port)
    xine_close_audio_driver(xine, ao_port);  
  xine_close_video_driver(xine, vo_port);  
  xine_exit(xine);
  
  XLockDisplay(display);
  XUnmapWindow(display,  window);
  XDestroyWindow(display, window);
  XUnlockDisplay(display);
  
  XCloseDisplay (display);

  return 1;
}

Tu peux le compiler avec cette commande :
gcc -Wall -O2 `xine-config --cflags` `xine-config --libs` -I/usr/X11R6/include -L/usr/X11R6/lib -lX11 -lm -o muxine muxine.c

Hors ligne