-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunitdvdinfo1.pas
119 lines (101 loc) · 2.67 KB
/
unitdvdinfo1.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
unit unitdvdinfo1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
Spin;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
Memo1: TMemo;
SpinEdit1: TSpinEdit;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDropFiles(Sender: TObject; const FileNames: array of String);
private
{ private declarations }
execpath, FileName: string;
procedure DoCommand(const fname:string; no: integer);
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
uses
unit2;
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
ExecPath:= ExtractFilePath(ParamStrUTF8(0));
SpinEdit1.Value:= 0;
Button1.Enabled:= ParamCount > 0;
if ParamCount > 0 then DoCommand(ParamStrUTF8(1), 0);
end;
procedure TForm1.FormDropFiles(Sender: TObject; const FileNames: array of String
);
begin
DoCommand(FileNames[0], 0);
Button1.Enabled:= True;
end;
function DeleteEscapeSequence(const s: string): string;
var
i: Integer;
begin
Result:= '';
i:= 1;
while i <= Length(s) do begin
if s[i] = #$1B then begin
while (s[i] <> 'm') and (i <= Length(s)) do Inc(i);
end else
Result:= Result + s[i];
Inc(i);
end;
end;
procedure TForm1.DoCommand(const fname:string; no: integer);
var
cmd: string;
proc: TPipeProcExec;
ss: UTF8String;
begin
FileName:= fname;
Label1.Caption:= FileName;
Memo1.Lines.BeginUpdate;
try
Memo1.Clear;
//cmd:= '"' + ExecPath + 'mplayer.exe"' +
// ' -speed 100 -vo null -ao null -frames 1 -identify' +
// ' -dvd-device "' + FileName + '" dvd://' + IntToStr(no);
cmd:= '"' + ExecPath + 'lsdvd.exe"' +
' -x -Ox "' + FileName + '" -t ' + IntToStr(no);
proc:= TPipeProcExec.Create;
try
proc.WaitTime:= 1;
proc.Cmds.Add(cmd);
proc.Start;
while not proc.Done do Sleep(1);
ss:= AnsiToUtf8(proc.OutputMsgs[0]);
// lsDVDのバグ?対策
ss:= StringReplace(ss, '&', '&', [rfReplaceAll]);
//ss:= StringReplace(ss, '<', '<', [rfReplaceAll]);
//ss:= StringReplace(ss, '>', '>', [rfReplaceAll]);
ss:= StringReplace(ss, '''', ''', [rfReplaceAll]);
Memo1.Lines.Add(ss);
finally
//proc.Terminate;
//proc.WaitFor;
FreeAndNil(proc);
end;
finally
Memo1.Lines.EndUpdate;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
DoCommand(FileName, SpinEdit1.Value);
end;
end.