Sign in to follow this  
Followers 0
YoseMite

subtitle tool

5 posts in this topic

Hi!

I'm working on a subtitle tool so that you easy can synchronise subtitles.

The 'problem' is that the subtitle file has a start-stop time.

Here's a sample:

1
00:00:33,810 --> 00:00:37,210
This a subtitle

2
00:00:37,811 --> 00:00:41,211
Subtitle2

3
00:00:44,712 --> 00:00:48,212
Another subtitle...

Now I would get the start and the end time.

But how can I get only the start and end time? :D

I made a sample:

While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
        
$start = StringLeft($line, 12)
$stop = StringRight($line, 12)

MsgBox(0, "Start time:", $var)
MsgBox(0, "End time:", $var2)
Wend

The problem is that he also read the other chars.

(-->, 1, 2, 3, This a subtitle, Subtitle2, Another subtitle...), )

I hope that you can help me! :)

Share this post


Link to post
Share on other sites



Hi,

try stringBetween.

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

I'm not totally sure I got what you were asking... but I'm assuming you meant you only want to pick up the start time and end time not the 1, 2, this is a subtitle... etc.

This code will only work if the subtitle structure is like you have in your example (see below)

1

00:00:33,810 --> 00:00:37,210

This a subtitle

2

00:00:37,811 --> 00:00:41,211

Subtitle2

3

00:00:44,712 --> 00:00:48,212

I have that called file.txt and here is the script I used

#include <array.au3>

$file = FileOpen("file.txt", 0)
$fileread = FileRead($file)
$array = StringSplit($fileread, @LF, 1)
FileClose($file)
_ArrayDisplay($array, "")

For $i = 2 To UBound($array) Step 4
    $start = StringLeft($array[$i], 12)
    $stop = StringRight($array[$i], 12)
    MsgBox(0, "Start time:", $start)
    MsgBox(0, "End time:", $stop)
Next

Hope that helps!

Andrew


While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

This is exactly what I mean!

Thank you, it works great! :)

I get some error:

Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.

Edited by YoseMite

Share this post


Link to post
Share on other sites

HI,

#include <array.au3>

$file = FileOpen("11.txt", 0)
$fileread = FileRead($file)
$array = StringSplit($fileread, @LF, 1)
FileClose($file)
_ArrayDisplay($array, "")

For $i = 2 To UBound($array) - 1
    If StringInStr($array[$i], ":") <> 0 Then
        MsgBox(0, "Start time:", StringLeft($array[$i], 12))
        MsgBox(0, "End time:", StringRight($array[$i], 12))
    EndIf
Next

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0