Unit1.pas
Return to Top  Previous Page  Next Page
{
Simple AVI Tags Editor - example of use of abcAVI DLL.  
Copyright (C) 2002 by Alexander Sorkin aka Kibi.  

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.  

19.07.2002 
Alexander Sorkin aka Kibi 
Authors homepage: http://kibizoid.da.ru 
abcAVI software homepage: http://abcavi.tk
}

{$A+,B-,C+,D+,E-,F-,G+,H+,I+,J+,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}

{$MINSTACKSIZE $00004000}

{$MAXSTACKSIZE $00100000}

{$IMAGEBASE $00400000}

{$APPTYPE GUI}

unit Unit1;

interface

uses Classes, Controls, OleServer, StdCtrls, Forms, ComCtrls,
  Dialogs, Buttons, Sysutils, abcAVI_TLB;

Const Tag_Names: array [0
..IDT_max] of string = (
   '[INAM] Title'
,'[IART] Director','[ICOP] Copyright','[IPRD] Product','[ICRD] Creation Date',
   '[IGNR] Genre'
,'[ISGN] Second Genre','[ISBJ] Subject','[IKEY] Keywords','[ICMT] Comment',
   '[IWRI] Writer'
,'[IPRO] Producer','[IPDS] Production Designer','[ICNM] Cinematographer','[IEDT] Editor',
   '[IMUS] Composer'
,'[ICDS] Costume Designer','[ISTD] Production Studio','[ICNT] Country','[ICMS] Comissioned By',
   '[IDST] Distributor'
,'[ILNG] Language','[IRTD] Rating','[ISTR] Starring','[ISFT] Software',
   '[IDIT] Digitation Date'
,'[IENG] Enginer','[ITCH] Encoder','[IWEB] Internet Address','[IPRT] Part',
   '[IFRM] Part From'
,'[ISRF] Source Form','[IMED] Medium','[ISRC] Source','[IARL] Archival Location',
   '[IMIU] More Info URL'
,'[IMIT] More Info Text','[IDIM] Dimensions','[ISHP] Sharpness','[IPLT] Pallete',
   '[ILGT] Lightness'
,'[IDPI] Resolution','[ICRP] Croped','[ILGU] Logo URL','[ILIU] Logo Icon URL',
   '[IWMU] Watermark URL'
,'[IMBI] Banner Image URL','[IMBU] Banner URL','[ICAS] Default Audio Stream','[IAS1] Language of stream 1',
   '[IAS2] Language of stream 2'
,'[IAS3] Language of stream 3','[IAS4] Language of stream 4','[IAS5] Language of stream 5','[IAS6] Language of stream 6',
   '[IAS7] Language of stream 7'
,'[IAS8] Language of stream 8','[IAS9] Language of stream 9','[ISMP] SMPTE time code','[IBSU] Base URL',
   '[IENC] Encoder'
,'[IRIP] Ripper'
   );
type
  TForm1 = class(TForm)
    OpenDialog1: TOpenDialog;
    btn_open: TBitBtn;
    btn_save: TBitBtn;
    Avi_info: TMemo;
    StatusBar1: TStatusBar;
    GroupBox1: TGroupBox;
    Label1: TLabel;
    lbl_inam: TLabel;
    lbl_iart: TLabel;
    lbl_icop: TLabel;
    edt_inam: TEdit;
    edt_iart: TEdit;
    edt_icop: TEdit;
    ExtendedAVITags1: TExtendedAVITags;
    procedure btn_openClick(Sender: TObject);
    procedure btn_saveClick(Sender: TObject);
  private
    { Private declarations }

  public
    { Public declarations }

  end;

var
  Form1: TForm1;
  aviinfo:OleVariant;

implementation

{$R *.DFM}


procedure TForm1.btn_openClick(Sender: TObject);
var filename:olevariant;
    errorstring:string;
    error:Hresult;
    x:integer;
begin
    if OpenDialog1.Execute then begin // execute file open dialog

        avi_info.Lines.Clear;
        filename:=OpenDialog1.FileName; // get the file name

        with ExtendedAVITags1 do begin // show read values

           error:=ReadAVITags(filename,PM_Ignore_Errors,1
,aviinfo);
           errorstring:=ErrorCodeToStr(error); // decode error code

           statusbar1.SimpleText:=format('%s (%s)'
,[OpenDialog1.FileName,errorstring]);// show the filename + error
           if error=PE_parse_ok then begin
              edt_inam.text:=GetInfo(aviinfo,IDI_INFO_Tags,IDT_INAM); // get value

              edt_iart.text:=GetInfo(aviinfo,IDI_INFO_Tags,IDT_IART);
              edt_icop.text:=GetInfo(aviinfo,IDI_INFO_Tags,IDT_IART);
              avi_info.Lines.BeginUpdate;
              avi_info.Lines.Add('********* INFO Tags *********'
);
              for x:=0
 to IDT_max do begin
                 if GetInfo(aviinfo,IDI_INFO_Tags,x)<>''

                    then avi_info.Lines.Add(format('%s: %s'
,[Tag_Names[x],GetInfo(aviinfo,IDI_INFO_Tags,x)]));
              end;
              avi_info.Lines.EndUpdate;
              btn_save.Enabled:=true; //enable save button

           end;
        end;
    end;
end;

procedure TForm1.btn_saveClick(Sender: TObject);
var error:HResult;
    errorstring:String;
begin
    with ExtendedAVITags1 do begin
       SetInfo(aviinfo,IDI_INFO_Tags,IDT_INAM,edt_inam.text); // set tag's values

       SetInfo(aviinfo,IDI_INFO_Tags,IDT_IART,edt_iart.text);
       SetInfo(aviinfo,IDI_INFO_Tags,IDT_ICOP,edt_icop.text);
    end;
    error:=ExtendedAVITags1.WriteAVITags(OpenDialog1.FileName, aviinfo);
    errorstring:=ExtendedAVITags1.ErrorCodeToStr(error); // decode error code

    statusbar1.SimpleText:=format('%s (%s)'
,[OpenDialog1.FileName,errorstring]);// show the filename + error
end;
end.