type
PInputOptions = ^TInputOptions;
TInputOptions = record
FileName: string;
FileFormat: string;
TimeStart: Integer;
ProgramID: Integer;
ExtOptions: string;
end;
TOptionTargetType = (ttIgnore, ttVCD, ttSVCD, ttDVD);
TOptionNormType = (ntAuto, ntPAL, ntNTSC);
TOptionNormDefault = ntPAL..ntNTSC;
TStreamInfo = packed record
TimeStamp: TDateTime;
Year: Integer;
Track: Integer;
Title: array[0..512-1] of AnsiChar;
Author: array[0..512-1] of AnsiChar;
Copyright: array[0..512-1] of AnsiChar;
Comment: array[0..512-1] of AnsiChar;
Album: array[0..512-1] of AnsiChar;
Genre: array[0..32-1] of AnsiChar;
end;
POutputOptions = ^TOutputOptions;
TOutputOptions = record
FileName: string;
FileExt: string;
FileFormat: string;
PacketSize: Integer;
MuxRate: Integer;
MuxDelay: Single;
MuxPreload: Single;
AudioCodec: string;
DisableAudio: Boolean;
AudioVolume: Integer;
AudioChannels: Integer;
AudioSampleRate: Integer;
AudioBitrate: Integer;
AudioBitRateTolerance: Integer;
AudioLanguage: string;
AudioSyncMethod: Integer;
AudioTag: string;
VideoCodec: string;
DisableVideo: Boolean;
FrameRate: string;
FrameSize: string;
FrameAspectRatio: string;
CropTop: Integer;
CropBottom: Integer;
CropLeft: Integer;
CropRight: Integer;
PadTop: Integer;
PadBottom: Integer;
PadLeft: Integer;
PadRight: Integer;
PadColor: TColor;
GroupPictureSize: Integer;
VideoBitrate: Integer;
VideoMaxRate: Integer;
VideoMinRate: Integer;
VideoBitRateTolerance: Integer;
VideoBufSize: Integer;
VideoSyncMethod: Integer;
VideoTag: string;
VideoFilters: string;
DisableSubtitle: Boolean;
SubtitleLanguage: string;
CopyTimestamp: Boolean;
TimeLength: Integer;
Info: TStreamInfo;
TargetType: TOptionTargetType;
NormType: TOptionNormType;
NormDefault: TOptionNormDefault;
CustomHook: Boolean;
BeforeHook: Boolean;
VideoHookPTSs: string;
ExtOptions: string;
end;
TLogLevel = (llQuiet,
llError,
llInfo,
llDebug,
llAll);
TBeforeHookEvent = procedure(const AIndex: Integer; const APTS: Int64;
var AHookAction: THookAction) of object;
TCustomHookEvent = procedure(const AIndex: Integer; ABitmap: TBitmap;
const AFrameNumber: Integer; const APTS: Int64;
var AUpdate, AStopHook: Boolean) of object;
TLogEvent = procedure(const AIndex: Integer; const ALogLevel: TLogLevel;
const AMsg: string) of object;
TProgressEvent = procedure(const AIndex, AFrameNumber, AFPS, ACurrentDuration: Integer;
const AQuality, ABitRate: Single; const ACurrentSize: Int64;
const ATotalOutputDuration: Integer) of object;
TTerminateEvent = procedure(const AIndex: Integer; const AFinished, AException: Boolean;
const AMessage: string) of object;
TConvertPriority = tpIdle..tpNormal;
TCustomFFmpegVCL = class(TComponent)
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function LoadAVLib(const APath: string; const AWithVerNum: Boolean): Boolean;
procedure UnloadAVLib;
function AddInputFile(const AFileName: string;
const AOptions: PInputOptions = nil): Integer; overload;
function AddInputFile(const AFileName: string;
const AExtOptions: string): Integer; overload;
function AddInputFile(const AInputIndex: Integer; const AFileName: string;
const AOptions: PInputOptions = nil): Boolean; overload;
function AddInputFile(const AInputIndex: Integer; const AFileName: string;
const AExtOptions: string): Boolean; overload;
function AddInputSubtitle(const AInputIndex: Integer; const AFileName: string;
const AOptions: PInputOptions = nil): Boolean;
function SetOutputFile(const AInputIndex: Integer; const AFileName: string;
const AOptions: POutputOptions = nil): Boolean; overload;
function SetOutputFile(const AInputIndex: Integer; const AFileName: string;
const AExtOptions: string): Boolean; overload;
function AddInputStream(const AStream: TStream; const APrivateData: string;
const AOptions: PInputOptions = nil): Integer;
function SetOutputStream(const AInputIndex: Integer; const AStream: TStream;
const APrivateData: string; const AOptions: POutputOptions = nil): Boolean;
procedure ClearInputFiles;
procedure RemoveInputFile(const AInputIndex: Integer);
procedure StartConvert(const AThreadCount: Integer = 0);
procedure BreakConverting;
procedure PauseConverting;
procedure ResumeConverting;
procedure SetLicenseKey(const AKey: AnsiString; const ASeed: LongWord;
const AHex: Boolean = True);
property AVProbe: TAVProbe read FAVProbe;
property AVFileInfo[Index: Integer]: TAVProbe read GetAVProbes;
property LastErrMsg: string read FLastErrMsg;
property FilesCount: Integer read GetFilesCount;
property InputFiles[Index: Integer]: PAVFormatContext read GetInputFiles;
property InputOptions[Index: Integer]: TInputOptions read GetInputOptions;
property OutputOptions[Index: Integer]: TOutputOptions read GetOutputOptions;
property FFmpegs[Index: Integer]: TFFmpeg read GetFFmpegs;
property LogLevel: TLogLevel read FLogLevel write SetLogLevel default llInfo;
property ProgressInterval: Integer read FProgressInterval write SetProgressInterval
default CReportInterval;
property ThreadPriority: TConvertPriority read FThreadPriority write FThreadPriority
default tpNormal;
property Version: string read GetVersion;
property OnBeforeHook: TBeforeHookEvent read FOnBeforeHook write FOnBeforeHook;
property OnCustomHook: TCustomHookEvent read FOnCustomHook write FOnCustomHook;
property OnLog: TLogEvent read FOnLog write FOnLog;
property OnProgress: TProgressEvent read FOnProgress write FOnProgress;
property OnTerminate: TTerminateEvent read FOnTerminate write FOnTerminate;
published
property About: string read FAbout write FAbout;
end;
TFFmpegVCL = class(TCustomFFmpegVCL)
published
property LogLevel;
property ProgressInterval;
property ThreadPriority;
property Version;
property OnBeforeHook;
property OnCustomHook;
property OnLog;
property OnProgress;
property OnTerminate;
end;
procedure InitInputOptions(P: PInputOptions);
procedure InitOutputOptions(P: POutputOptions);
implementation
procedure InitInputOptions(P: PInputOptions);
begin
with P^ do
begin
FileName := '';
FileFormat := '';
TimeStart := -1;
ProgramID := -1;
ExtOptions := '';
end;
end;
procedure InitOutputOptions(P: POutputOptions);
begin
with P^ do
begin
FileName := '';
FileExt := '';
FileFormat := '';
PacketSize := -1;
MuxRate := -1;
MuxDelay := -1;
MuxPreload := -1;
AudioCodec := '';
DisableAudio := False;
AudioVolume := -1;
AudioChannels := -1;
AudioSampleRate := -1;
AudioBitrate := -1;
AudioBitRateTolerance := -1;
AudioLanguage := '';
AudioSyncMethod := 0;
AudioTag := '';
VideoCodec := '';
DisableVideo := False;
FrameRate := '';
FrameSize := '';
FrameAspectRatio := '';
CropTop := -1;
CropBottom := -1;
CropLeft := -1;
CropRight := -1;
PadTop := -1;
PadBottom := -1;
PadLeft := -1;
PadRight := -1;
PadColor := clBlack;
GroupPictureSize := -1;
VideoBitrate := -1;
VideoMaxRate := -1;
VideoMinRate := -1;
VideoBitRateTolerance := -1;
VideoBufSize := -1;
VideoSyncMethod := -1;
VideoTag := '';
VideoFilters := '';
DisableSubtitle := False;
SubtitleLanguage := '';
CopyTimestamp := False;
TimeLength := -1;
FillChar(Info, SizeOf(TStreamInfo), 0);
Info.TimeStamp := -1;
Info.Year := -1;
Info.Track := -1;
TargetType := ttIgnore;
NormType := ntAuto;
NormDefault := ntPAL;
CustomHook := False;
BeforeHook := False;
VideoHookPTSs := '';
ExtOptions := '';
end;
end;