Delphi-PRAXiS
Seite 1 von 2  1 2      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Multimedia (https://www.delphipraxis.net/16-multimedia/)
-   -   TFilterGraph in einer DLL (https://www.delphipraxis.net/171362-tfiltergraph-einer-dll.html)

calibra301 2. Nov 2012 08:13

TFilterGraph in einer DLL
 
Hallo,

stehe vor einer Wand...Code der in einer Form-Anwendung funktioniert will nicht
so wie er soll wenn man ihn in eine DLL packt:

Delphi-Quellcode:
function PlayVideo:Boolean; stdcall;
begin

  Videoform:=TForm.Create(nil);
  Videoform.Left:=100; //Mon.Left - Videoform.Monitor.Left;
  Videoform.Top :=100; // Mon.Top - Videoform.Monitor.Top;
  Videoform.Width := 256;//screen.Monitors[0].Width;
  Videoform.Height:= 256;//screen.Monitors[0].height;
  Videoform.BorderStyle:=bsnone;
  Videoform.Color:=clblack;
  Videoform.Visible:=true;

  FilterGraph := TFilterGraph.Create(nil);
  FilterGraph.Mode := gmNormal;
  FilterGraph.Name := 'FilterGraph';

  VideoWindow := TVideoWindow.Create(nil);
  VideoWindow.Parent := Videoform;
  VideoWindow.Left := 10;
  VideoWindow.Top := 10;
  VideoWindow.FilterGraph := FilterGraph;
  VideoWindow.Name := 'form1';
  VideoWindow.VMROptions.Mode := vmrWindowed;
  VideoWindow.Visible := true;

  VideoWindow.FilterGraph := FilterGraph;
  VideoWindow.FilterGraph.Active := false;
  VideoWindow.FilterGraph.AutoCreate := false;
  VideoWindow.FilterGraph.GraphEdit := false;
  VideoWindow.FilterGraph.Mode := gmNormal;
  VideoWindow.FullScreen := false;
  VideoWindow.Mode := vmNormal;

  FilterGraph.stop;
  FilterGraph.Active := false;
  FilterGraph.ClearGraph;
  FilterGraph.Active := true;
  FilterGraph.RenderFile('C:\Test.avi');
  FilterGraph.Play;
end;
Beim FilterGraph.active:=true kommt eine AccessViolation...
Google fand im net nen Artikel von jemand mit dem selbem Problem, leider ohne
Lösung. System ist ein XP mit D6

Danke und Gruss
Guido

Bernhard Geyer 2. Nov 2012 08:50

AW: TFilterGraph in einer DLL
 
erzeugt mal dein auf dem Formular


Delphi-Quellcode:
 FilterGraph := TFilterGraph.Create(VideoForm);
 FilterGraph.parent := VideoForm;
 FilterGraph.HandleNeeded;

calibra301 2. Nov 2012 09:22

AW: TFilterGraph in einer DLL
 
Hallo,

FilterGraph := TFilterGraph.Create(VideoForm); <- Half nix..

Die Eigenschaften "Parent" und "HandleNeeded" kennt er nicht...



Gruss
Guido

lbccaleb 2. Nov 2012 10:28

AW: TFilterGraph in einer DLL
 
Du solltest mehr Code posten, zB. wie die DLL geladen wird. Wie die Function genau in der DLL deklariert ist und so weiter. Ausserdem solltest du ne genauere Fehlerbeschreibung geben. Wer kann denn schon was mit Accessviolation anfangen?

Bernhard Geyer 2. Nov 2012 10:33

AW: TFilterGraph in einer DLL
 
Zitat:

Zitat von calibra301 (Beitrag 1189466)
Hallo,

FilterGraph := TFilterGraph.Create(VideoForm); <- Half nix..

Die Eigenschaften "Parent" und "HandleNeeded" kennt er nicht...
Gruss
Guido

Dann probier die Anpassungen für VideoWindow

calibra301 2. Nov 2012 11:04

AW: TFilterGraph in einer DLL
 
Leider auch ne Niete.

Hier mal alles:
Delphi-Quellcode:
library MyVideo;

uses
  ShareMem ,Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,DSPack,dsutil,DirectShow9,ExtCtrls;


var
 FilterGraph : TFilterGraph;
 Videowindow : TVideowindow;
 Videoform:TForm;

function PlayVideo:Boolean; stdcall;
begin

  Videoform:=TForm.Create(nil);
  Videoform.Left:=100; //Mon.Left - Videoform.Monitor.Left;
  Videoform.Top :=100; // Mon.Top - Videoform.Monitor.Top;
  Videoform.Width := 256;//screen.Monitors[0].Width;
  Videoform.Height:= 256;//screen.Monitors[0].height;
  Videoform.BorderStyle:=bsnone;
  Videoform.Color:=clblack;
  Videoform.Visible:=true;

  FilterGraph := TFilterGraph.Create(nil);
  FilterGraph.Mode := gmNormal;
  FilterGraph.Name := 'FilterGraph';

  VideoWindow := TVideoWindow.Create(nil);
  VideoWindow.Parent := Videoform;
  VideoWindow.Left := 10;
  VideoWindow.Top := 10;
  VideoWindow.FilterGraph := FilterGraph;
  VideoWindow.Name := 'form1';
  VideoWindow.VMROptions.Mode := vmrWindowed;
  VideoWindow.Visible := true;

  VideoWindow.FilterGraph := FilterGraph;
  VideoWindow.FilterGraph.Active := false;
  VideoWindow.FilterGraph.AutoCreate := false;
  VideoWindow.FilterGraph.GraphEdit := false;
  VideoWindow.FilterGraph.Mode := gmNormal;
  VideoWindow.FullScreen := false;
  VideoWindow.Mode := vmNormal;

  FilterGraph.ClearGraph;
  FilterGraph.Active := false;
  FilterGraph.Active := true;
  FilterGraph.RenderFile('C:\Test.avi');
  FilterGraph.Play;

  PlayVideo:=true;
end;


exports
  PlayVideo;
begin

end.

Aufruf:
Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

  procedure PlayVideo; external 'Project1.dll'

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
 PlayVideo;
end;

Wie gesagt...als Form-Anwendung tuts der Code (mit **.create(self) );

Gruss
Guido

lbccaleb 2. Nov 2012 11:40

AW: TFilterGraph in einer DLL
 
Liste der Anhänge anzeigen (Anzahl: 1)
Also ich hab deine Version mal nachgestellt (Ohne Freigaben und der gleichen)
Und das funktioniert bei mir. Allerdings hab ich ne Video Datei genommen, die nicht im Hauptverzeichnis C: liegt.
Vllt. also ein Rechte Problem?
im bsp keine Videodatei angegeben...

calibra301 2. Nov 2012 12:18

AW: TFilterGraph in einer DLL
 
Dann wirds wohl ein lokales Problem sein.
Nach Neukompilierung knallte es an der selben Stelle. Filtergraph.aktive:=true;

Anderes Problem: FProt hat die Projekt1.exe aus deinem rar als W32Trojaner erkannt und
entsorgt...

Teste mal auf nem anderem PC

Gruss
Guido

EWeiss 2. Nov 2012 12:56

AW: TFilterGraph in einer DLL
 
Schau doch mal im Header der Datei ob das wirklich *.avi ist und nicht einfach
eine Datei die nach .avi umbenannt wurde.

Und nen Error Handler würde ich strengstens empfehlen.

PS:
Der Aufbau deiner DLL ist sehr gewöhnungsbedürftig
In PlayVideo sollte nichts anderes stehen als "Play;"

Delphi-Quellcode:
function PlayVideo(FilterGraph :TFilterGraph):Boolean; stdcall;
begin
  Result := false;

  if Assigned(FilterGraph) then
  begin
    FilterGraph.Play;
    result := true
  end;

end
try .. except finally nicht vergessen.

gruss

lbccaleb 2. Nov 2012 17:19

AW: TFilterGraph in einer DLL
 
@Emil: Nicht nur das!



Du solltest auch vor allem mal alles frei geben! Ich hab das in meiner oben geposteten Version nicht gemacht weil es nur schnell kopiert wurde.
Außerdem solltest du es vermeiden, die Befehle mehrere male zu Wiederholen. Auch wenn das nicht wirklich der Fehler zu deinem Problem ist.


Und wie Emil schon richtig gepostet hat, vor allem Kontrollieren, ob die Interfaces zugewiesen sind oder nicht. Denn wenn bei dir irgendwo beim laden der Datei oder gar beim initzialisien ein Fehler auftritt, bekommst du davon gar nichts mit und das Programm arbeitet lustig weiter deine Befehlsliste ab, obwohl vllt. nicht mal DirectShow zur verfügung steht. Aus welchem Grund auch immer...


Alle Zeitangaben in WEZ +1. Es ist jetzt 02:05 Uhr.
Seite 1 von 2  1 2      

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz