Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 09-03-2009
carmelina carmelina is offline
Miembro
 
Registrado: mar 2008
Posts: 34
Poder: 0
carmelina Va por buen camino
Captura limitada

Hola a todos;

Estoy haciendo un programa para mi proyecto fin de carrera en el que necesito grabar con la cámara web. Gracias a vuestra ayuda y a algo más de información que encontré por ahí tengo este código:
Código:
unit HiloGrabarCaptura;
interface
uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
   ExtCtrls, StdCtrls, FileCtrl;
type
  GrabarCaptura = class(TThread)
  private
    { Private declarations }
  protected
    procedure Execute; override;

  public
     hWndC : THandle;
  end;
implementation
uses Visualizacion;
{ Important: Methods and properties of objects in VCL can only be used in a
  method called using Synchronize, for example,
      Synchronize(UpdateCaption);
  and UpdateCaption could look like,
    procedure GrabarCaptura.UpdateCaption;
    begin
      Form1.Caption := 'Updated in a thread';
    end; }
{ GrabarCaptura }
const WM_USER = 1024;
const WM_CAP_START = WM_USER;
const WM_CAP_STOP = WM_CAP_START + 68;
const WM_CAP_DRIVER_CONNECT = WM_CAP_START + 10;
const WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 11;
const WM_CAP_SAVEDIB = WM_CAP_START + 25;
const WM_CAP_SEQUENCE = WM_CAP_START + 62;
const WM_CAP_SET_SEQUENCE_SETUP = WM_CAP_START + 64;
const WM_CAP_FILE_SET_CAPTURE_FILEA = WM_CAP_START + 20;
const WM_CAP_SET_SCALE= WM_CAP_START + 53;
const WM_CAP_SET_PREVIEW = WM_USER + 50 ;
const WM_CAP_SET_PREVIEW_RATE = WM_USER + 52 ;
const WM_CAP_GRAB_FRAME = WM_CAP_START + 60;
const WM_CAP_FILE_ALLOCATE = WM_CAP_START + 22;
function capCreateCaptureWindowA(lpszWindowName : PCHAR;   //funcion que crea
                                                           //la ventana de captura
  dwStyle : longint; x : integer; y : integer; nWidth : integer; nHeight : integer;
  ParentWin : HWND; nId : integer): HWND;
  STDCALL EXTERNAL 'AVICAP32.DLL';
 
procedure GrabarCaptura.Execute;
  { Place thread code here }
  var
 capavi: array[0..40] of char;
 captit: array[0..40] of char;
 apntr:                  pointer;
 asize:                  integer;
 path: String;
 carpeta: String;
 nombrevideo : String;
 idUser : String;
begin

    strpcopy(capavi, videofilename);  { captured video file name }
    strpcopy(captit, 'My Own Capture Window');  { capture window }
  hWndC := capCreateCaptureWindowA(captit,WS_CHILD or WS_VISIBLE ,
  MisvideosSeguridad.Panel1.Left, MisvideosSeguridad.Panel1.Top,MisvideosSeguridad.Panel1.Width,MisvideosSeguridad.Panel1.Height,MisvideosSeguridad.Handle,0);
   If hWndC <> 0 Then  //Si la ventana de captura está creada
        SendMessage(hWndC, WM_CAP_DRIVER_CONNECT, 0, 0); //Conectamos los drivers
        apntr := addr(capavi);
        SendMessage(hWndC, WM_USER + 20, 0, longint(apntr));
 
        SendMessage(hWndc,WM_CAP_SET_SCALE,1,0);
        SendMessage(hwnDc,WM_CAP_SET_PREVIEW_RATE,33,0);//Establece 30 tramas por segundos en milisegundos: 1000ms/30=33ms
        SendMessage(hwnDc,WM_CAP_SET_PREVIEW,1,0); //Previsualiza
        apntr := addr(MisvideosSeguridad.CAP_PARAMS);
        asize := sizeof(MisvideosSeguridad.CAP_PARAMS);
        SendMessage(hWndC,WM_USER + 65, asize, longint(apntr));
        MisvideosSeguridad.CAP_PARAMS.fCaptureAudio := false;
        MisvideosSeguridad.CAP_PARAMS.fAbortLeftMouse:=false;        //http://www.gentle.it/alvise/AVICAP.TXT
        MisvideosSeguridad.CAP_PARAMS.FAbortRightMouse:=False;
        MisvideosSeguridad.CAP_PARAMS.fLimitEnabled:=true;
        //MisvideosSeguridad.CAP_PARAMS.wNumVideoRequested:=32;  Informarme
        MisvideosSeguridad.CAP_PARAMS.wTimeLimit:=word($0F);
        MisvideosSeguridad.CAP_PARAMS.wPercentDropForError := 1;
        MisvideosSeguridad.CAP_PARAMS.dwRequestMicroSecPerFrame := 33334;  //{ 30 fps    33
        //CAP_PARAMS.dwRequestMicroSecPerFrame := 41667; // 24 fps
       // MisvideosSeguridad.CAP_PARAMS.dwRequestMicroSecPerFrame:= 66667; // 15 fps     66
 //Establecemos los parámetros
        apntr := addr(MisvideosSeguridad.CAP_PARAMS);
        asize := sizeof(MisvideosSeguridad.CAP_PARAMS);
        SendMessage(hWndC, WM_USER + 64, asize, longint(apntr));

        if hWndC <> 0 then begin

        if not DirectoryExists('C:\Videos\') then    //Creo la carpeta donde guardar los ficheros
          if not   CreateDir('C:\Videos\') then
            raise Exception.Create('No puede crear la carpeta');
           IdUser:= MisvideosSeguridad.Edit3.Text;
           carpeta:= 'C:\Videos\'+IdUser;
         nombrevideo:=MisvideosSeguridad.Edit2.Text;

        if not DirectoryExists(carpeta) then    //Creo la carpeta donde guardar los ficheros para cada usuario
          if not   CreateDir(carpeta) then
            raise Exception.Create('No puede crear la carpeta');
               path:= 'C:\Videos\'+IdUser+'\'+nombrevideo+'.avi';
               MisvideosSeguridad.SaveDialog1.DefaultExt := 'avi';
               MisvideosSeguridad.SaveDialog1.Filter := 'AVI files (*.divx)|*.avi';
               MisvideosSeguridad.SaveDialog1.FileName:=path;
               SendMessage(hWndC,WM_CAP_FILE_SET_CAPTURE_FILEA,0,Longint(pchar(MisvideosSeguridad.SaveDialog1.FileName)));
               SendMessage(hWndC,WM_CAP_SEQUENCE, 0, 0);

        end;
     MisvideosSeguridad.Edit2.Clear;
     MisvideosSeguridad.Edit3.Clear;     

end;
end.
Bueno mi problema es que yo establezco el limite de tiempo con el parámetro arriba señalado mediantre negrita, si el tiempo es inferior a 4 minutos, esto trabaja estupendamente, pero si es superior cuando intento visualizar el video me dice que no se puede abrir porque el formato es erróneo. Esto por que puede ser?
Si alguien pudiese ayudarme os lo agradecería mucho.
Otro problema que me encuentro es que aunque lo he programado en un hilo para que la aplicación no se quede pillada, la verdad es que cuando empiezo a grabar ya no puedo hacer nada en mi aplicación hasta que la grabación termina. Sabeis por qué puede ser?
Un saludo y muchas gracias de antemano.
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Utilizar DB Access en cuenta limitada de windows xp JF Sebastian Conexión con bases de datos 4 14-03-2007 09:53:10
captura de pantalla magomalo C++ Builder 1 04-02-2007 01:25:17
Xp no permite activar servidor con cuenta limitada..! uper Windows 0 22-05-2006 16:58:37
Captura pantalla walito Gráficos 11 28-01-2006 01:37:05
Consulta Limitada JANDREGUE SQL 7 05-11-2004 17:29:19


La franja horaria es GMT +2. Ahora son las 08:03:05.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi