55 lines
1.7 KiB
PHP
55 lines
1.7 KiB
PHP
<?php
|
|
|
|
use swf2ass\ass\ASSEventTime;
|
|
|
|
require_once __DIR__ . "/vendor/autoload.php";
|
|
|
|
$width = 1280;
|
|
$height = 720;
|
|
$ar = $width / $height;
|
|
$frameRate = 1000;
|
|
$frameDurationMs = (1 / $frameRate) * 1000;
|
|
|
|
echo <<<ASSHEADER
|
|
[Script Info]
|
|
; Script generated by swf2ass timing test
|
|
; https://git.gammaspectra.live/WeebDataHoarder/swf2ass
|
|
ScriptType: v4.00+
|
|
WrapStyle: 0
|
|
ScaledBorderAndShadow: yes
|
|
YCbCr Matrix: PC.709
|
|
PlayResX: {$width}
|
|
PlayResY: {$height}
|
|
|
|
[Aegisub Project Garbage]
|
|
Last Style Storage: f
|
|
Video File: ?dummy:{$frameRate}:10000:{$width}:{$height}:160:160:160:c
|
|
Video AR Value: {$ar}
|
|
|
|
[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: f,Arial,20,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,0,0,7,0,0,0,1
|
|
|
|
[Events]
|
|
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
|
|
|
|
ASSHEADER;
|
|
|
|
|
|
|
|
$frameDuration = 3;
|
|
for($frame = 0; $frame < ($frameRate * 10); $frame += $frameDuration){
|
|
$line = new \swf2ass\ass\ASSLine();
|
|
$line->layer = [$frame];
|
|
$line->objectId = 0;
|
|
$line->start = $frame;
|
|
$line->end = $frame + $frameDuration - 1;
|
|
$line->name = "{$line->start}->{$line->end}";
|
|
$line->style = "f";
|
|
$assEventTime = new ASSEventTime($line->start, $line->end - $line->start + 1, $frameDurationMs);
|
|
$start = $assEventTime->getMillisecondsFromStartOffset(2) - 1;
|
|
$end = $assEventTime->getMillisecondsFromStartOffset(2);
|
|
$l = $line->encode($frameDurationMs) . "{\\an7\\move(300,300,400,400,{$start},{$end})}Frame $frame @ $frameRate fps";
|
|
|
|
echo $l . "\n";
|
|
} |