-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain2.php
118 lines (90 loc) · 2.48 KB
/
main2.php
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
<?php
require_once("lib/sub_generator.php");
require_once("lib/result_analyzer.php");
require_once("lib/core.php");
$input = "
1 30.94 [1]
2 31.289 [1]
3 31.286 [1]
4 31.383 [1]
5 31.535 [1]
6 31.423 [1]
7 31.126 [1]
8 31.867 [1]
9 32.058 [1]
10 31.211 [1]
11 31.341 [1]
12 31.329 [1]
13 31.13 [1]
14 30.97 [1]
15 31.553 [1]
16 31.457 [1]
17 31.716 [1]
18 30.842 [1]
19 30.908 [1]
";
function get_result_data($input) {
$retval = array();
$lines = explode("\n", $input);
foreach ($lines as $line) {
$line = trim($line);
$elements = preg_split("/\s/", $line);
if (sizeof($elements)==3) {
array_push($retval, $elements);
//echo var_dump($elements);
}
}
return $retval;
}
function get_ass_content($result) {
$retval = "
[Script Info]
; Script generated by Aegisub 3.0.2
; http://www.aegisub.org/
Title:
Original Script:
Script Updated By: version 2.8.01
ScriptType: v4.00+
Collisions: Normal
PlayDepth: 0
Timer: 100,0000
Video Aspect Ratio: c1.77778
Video Zoom: 6
Scroll Position: 0
Active Line: 0
Video Zoom Percent: 0.5
Video File:
YCbCr Matrix: TV.601
[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: DefaultVCD,Segoe UI Mono,8,&H33FFFFFF,&H00B4FCFC,&H01000008,&H80000008,-1,0,0,0,100,100,0,0,1,1,0,9,5,5,5,0
[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
";
$start_time = 0;
$end_time = 9.109;
$tags = "\\an7\\fscx150\\fscy150\\fnQuartz MS";
$sub_line = "";
foreach ($result as $result_line) {
$start_time = $end_time;
$end_time = $start_time + floatval($result_line[1]);
$str_start_time = get_time($start_time);
$str_end_time = get_time($end_time);
$retval .= "Dialogue: 0,{$str_start_time},{$str_end_time},DefaultVCD,NTP,0,0,10,,{{$tags}}{$sub_line}\n";
$sub_line .= "{$result_line[1]}\\N";
echo var_dump($sub_line);
}
//last lap
$str_start_time = get_time($end_time);
$str_end_time = get_time($end_time+20);
$retval .= "Dialogue: 0,{$str_start_time},{$str_end_time},DefaultVCD,NTP,0,0,10,,{{$tags}}{$sub_line}\n";
return $retval;
}
$result_data = get_result_data($input);
$ass_output = get_ass_content($result_data);
if (1) {
$fp = fopen("test.ass", "w");
fwrite($fp, $ass_output);
fclose($fp);
}
//sub_generator($result_data, $race_name, $video_race_start_time, $race_length, $output_filename);