Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Software-Projekte der Mitglieder (https://www.delphipraxis.net/26-software-projekte-der-mitglieder/)
-   -   AVISYNTH_C Port (https://www.delphipraxis.net/62011-avisynth_c-port.html)

Amnon82 29. Jan 2006 17:27


AVISYNTH_C Port
 
Myrsloik hat AVISYNTH_C nach Delphi portiert. In der Source sind auch 2 Beispiel-DLLs enthalten. Somit ist es nun auch möglich Filter für AVISynth in Delphi leichter zu coden.

Hier noch mal der original Text zu diesem Port:
Zitat:

Myrsloik: One day I got bored and tried to do a conversion. It failed. Then I continued just to not let the computer win (then they'll think they can win every time) and finished it after figuring out how records are passed.

This should allow you to write filters in delphi and free pascal using the avisynth_c interface. It was tested with delphi 7 and free pascal 2.0 but will probably work in earlier versions of both. A conversion of the invert sample from avisynth_c is also included to show how it's used.
Hier die Download-Links zu der Source:

avisynth_pascal v3

Myrsloik hat noch ein paar Beispiele gecodet. Somit ist es einfacher für Euch avisynth_c in Euer Programm einzubauen.

Wie man AVISYNTH_C in Delphi benützt:
Delphi-Quellcode:
uses avisynth_c

var avsval:AVS_Value;
begin
  if OpenDialog1.Execute then
  begin
    //call avisouce with the selected filename
    avsval:=avs_invoke(env,'AVISource',avs_new_value_string(PChar(OpenDialog1.FileName)));

    //check for errors, only AVS_Values containing clips need to be freed
    //which it won't here if it's an error
    if avs_is_error(avsval) then
      raise EAviSynthCException.Create(avs_as_error(avsval));

    //get a clip from the AVS_Value
    clip:=avs_take_clip(avsval,env);

    //release the AVS_Value since it contained a clip, releasing an AVS_Value
    //without a clip does nothing
    avs_release_value(avsval);

    //get video information and adjust window
    vi:=avs_get_video_info(clip);

    TrackBar1.Max:=vi.num_frames-1;
    ClientWidth:=vi.width;
    ClientHeight:=vi.height+TrackBar1.Height;

    with Image1.Picture.Bitmap do
    begin
      Width:=vi.width;
      Height:=vi.height;

      if avs_is_rgb32(vi) then
        PixelFormat:=pf32bit
      else if avs_is_rgb24(vi) then
        PixelFormat:=pf24bit
    end;

    TrackBar1Change(nil);
  end;
end;
Beispiele von Myrsloik

Garfield 20. Feb 2006 13:52

Re: AVISYNTH_C Port
 
Sieht interessant aus. Ist leider noch nicht ganz vollständig. Wenn zum Beispiel der Decompressor fehlt, bekommt man eine Schutzverletzung in der User32.dll.

Nachtrag: Der Fehler tritt bei der Function ext_avs_invoke auf.

Garfield 11. Mär 2006 13:36

Re: AVISYNTH_C Port
 
Zitat:

Zitat von Garfield
Wenn zum Beispiel der Decompressor fehlt, bekommt man eine Schutzverletzung in der User32.dll.

Es funktioniert, wenn man das AVS nach *Source und Import parst und die Mediadatei anstelle des Scriptes angibt.

Ein Beispiel:

Das Script enthält die Textzeile
Code:
AVISource ("D:\Beispiel.avi")
Nach dem Parsen hat man die Variablen mit den Werten
Delphi-Quellcode:
Source_Funktion := 'AVISource';
Source_Datei   := 'D:\Beispiel.avi';
Dann heißt der Aufruf
Delphi-Quellcode:
avsval := avs_invoke (env,
                      PChar(Source_Funktion),
                      avs_new_value_string(PChar(Spurce_Datei)));
Bei Myrsloik's avisynth_pascal_v4 bekommt man nicht auswertbare Fehlermeldungen aber das Bild mit der Fehlermeldung.

Nachtrag:

http://yatta.mellbin.org/misc/avisynth_pascal_v4.rar
http://yatta.mellbin.org/misc/old/av..._pascal_v3.zip

Amnon82 17. Mär 2006 18:22

Re: AVISYNTH_C Port
 
Du kannst den Fehler als Text oder Video darstellen.

Hier mein altes Sample: Sample für v3

Errorcode von v4:

Delphi-Quellcode:
procedure CheckForErrors(v: AVS_Value);
begin
  if avs_is_error(v) then
    raise EAviSynthCException.Create(avs_as_error(v));
end;
Errorcode von v3:

Delphi-Quellcode:
EAviSynthCException = class(Exception);

if avs_is_error(avsval) then
      raise EAviSynthCException.Create(avs_as_error(avsval));
Wenn man v schreibt wirds ein Video. Wenn man avsval lässt kommt der string.

Garfield 25. Mär 2006 06:51

Re: AVISYNTH_C Port
 
Hallo Amnon82,

die Schutzverletzung in der User32.Dll trat nur bei der Verwendung von 'AVISource' auf. Allerdings nicht bei jeder Compilation. Ist kein Decompressor vorhanden, sondern nur ein DirectShowFilter, kann man anstelle von AVISource DirectShowSource verwenden.

Alternativ zur Auswertung von avs_is_error(v) bietet sich avsval.vtype an. Bei 'c' wurde ein Clip gefunden und man bekommt über avsval.vclip den Pointer. Bei 'e' liegt ein Fehler vor und man bekommt über avsval.vstring die Fehlermeldung.

Sinnvoll erscheint mir, zuerst die Funktion 'Import' zu verwenden. Dabei sollte man sicherstellen, dass nur Textdateien geladen werden. Bei der Verwendung einer Avidatei kann es eine Weile dauern, bis diese geladen ist.


Alle Zeitangaben in WEZ +1. Es ist jetzt 09:08 Uhr.

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