Скопируйте части EDL, рассчитайте длительность, но цикл не пройден - PullRequest
0 голосов
/ 21 мая 2018

У меня есть просто отформатированный текстовый файл (Edit Decision List) со строками чисел, за которыми следуют ряды свойств (имен и т. Д.).Для каждого совпадения я пытаюсь составить список из строки имени, за которой следует продолжительность (разница между временными метками).

В результате:

12 - Tech Sexy - D Cebert- FFP170 Dur: 00.38

До сих пор я

  1. установил способ определения пользователем исходного файла на своем рабочем столе.
  2. определенспособ сортировки временных отметок источника (по временной отметке, которая предшествует соответствующей строке имени).
  3. обнаружил разницу между первыми 2 временными отметками.

Но мой цикл, похоже, не работает,По крайней мере, я ожидаю увидеть список длительностей для каждой совпавшей строки отметки времени.

Сценарий на данный момент:

Option Explicit
'change system location to Germany, to simulate 24hour clock *no AM PM time
SetLocale "de-de"

Dim fso, oFile, y, re, prev, line, matches, time
Set fso = CreateObject("Scripting.FileSystemObject")

'get user to open file name
y = InputBox("name of file to save")

'next line opens a file with that name 
Set oFile = fso.OpenTextFile(y&".edl")

Do Until oFile.AtEndOfStream
    line = oFile.ReadLine
    'At this point the variable prev either is empty (during the first loop
    'cycle) or holds the content of the previous line.
    If Left(line, 21) = "*  FROM CLIP NAME:   " Then
        'Define search terms for each timecode element *this is not a result yet
        Dim re1
        re1 =".*?"  'Non-greedy match on filler
        Dim re2
        re2 ="((?:(?:[0-1][0-9])|(?:[2][0-3])|(?:[0-9])):(?:[0-5][0-9])(?::[0-5][0-9])?(?:\s?(?:am|AM|pm|PM))?)"  'HourMinuteSec 1
        Dim re3
        re3 =".*?"  'Non-greedy match on filler
        Dim re4
        re4 ="((?:(?:[0-1][0-9])|(?:[2][0-3])|(?:[0-9])):(?:[0-5][0-9])(?::[0-5][0-9])?(?:\s?(?:am|AM|pm|PM))?)"    'HourMinuteSec 2
        Dim re5
        re5 =".*?"  'Non-greedy match on filler
        Dim re6
        re6 ="((?:(?:[0-1][0-9])|(?:[2][0-3])|(?:[0-9])):(?:[0-5][0-9])(?::[0-5][0-9])?(?:\s?(?:am|AM|pm|PM))?)"    'HourMinuteSec 3
        Dim re7
        re7 =".*?"  'Non-greedy match on filler
        Dim re8
        re8 ="((?:(?:[0-1][0-9])|(?:[2][0-3])|(?:[0-9])):(?:[0-5][0-9])(?::[0-5][0-9])?(?:\s?(?:am|AM|pm|PM))?)"    'HourMinuteSec 4

        'add timecode search terms to a search pattern
        Dim r
        Set r = New RegExp
        r.Pattern = re1+re2+re3+re4+re5+re6+re7+re8
        r.IgnoreCase = True

        Dim m, timeDur, ts, Timeofday
        Set m = r.Execute(line)
        'loop through timecodes to find duration between first 2 entries
        If m.Item(0).SubMatches.Count > 0 Then
            Dim time1
            time1 = m.Item(0).SubMatches.Item(0)
            Dim time2
            time2 = m.Item(0).SubMatches.Item(1)
            Dim time3
            time3 = m.Item(0).SubMatches.Item(2)
            Dim time4
            time4 = m.Item(0).SubMatches.Item(3)

            'find duration/difference between first 2 times, in seconds
            timeDur=datediff("s", time1, time2)
            'format result to a serial time format eg. 00:00:00
            ts = TimeSerial(0, 0, timeDur)
            'print duration result, will need to append track info and repeat. Then save to file
            MsgBox (ts)
        End If
        MsgBox (ts)
    End If
Loop

Исходный файл:

* COMMENT:  CREATED BY GRASS VALLEY FOR EDIUS (CMX-3600) 
001  0000     A     C        00:00:04:23 00:00:42:04 00:00:00:00 00:00:37:06
* FROM CLIP NAME:  12 - Tech Sexy - D Cebert - FFP170
002  0000     A     C        00:00:20:01 00:00:31:23 00:01:29:24 00:01:41:21
* FROM CLIP NAME:  03 - Web Of Deceit (Main) - J Woodall - SFT164
003  0000     A     C        00:00:31:23 00:00:31:23 00:01:41:21 00:01:41:21
M2   0000        025.0              00:00:31:23
003  0000     A     D    025 00:00:31:09 00:00:54:12 00:01:41:21 00:02:04:24
* EFFECT NAME: CROSS DISSOLVE
* FROM CLIP NAME:  03 - Web Of Deceit (Main) - J Woodall - SFT164
* TO CLIP NAME:  03 - Web Of Deceit (Main) - J Woodall - SFT164
M2   0000        025.0              00:00:31:09
004  0000     A2    C        00:01:15:08 00:01:31:24 00:01:48:04 00:02:04:20
* FROM CLIP NAME:  12 - Environs A - T Juckes, S Kidd - SCDV354
005  0000     A2    C        00:00:11:12 00:00:30:05 00:02:06:24 00:02:25:17
* FROM CLIP NAME:  13 - Contagion (Main) - J Woodall - SFT164
006  0000     A2    C        00:00:06:13 00:00:56:09 00:02:27:04 00:03:17:00
* FROM CLIP NAME:  03 - Web Of Deceit (Main) - J Woodall - SFT164
007  0000     A2    C        00:00:56:09 00:00:56:09 00:03:17:00 00:03:17:00
M2   0000        025.0              00:00:56:09
007  0000     A2    D    025 00:00:55:08 00:01:54:03 00:03:17:00 00:04:15:20
* EFFECT NAME: CROSS DISSOLVE
* FROM CLIP NAME:  03 - Web Of Deceit (Main) - J Woodall - SFT164
* TO CLIP NAME:  03 - Web Of Deceit (Main) - J Woodall - SFT164
M2   0000        025.0              00:00:55:08
008  0000     A2    C        00:01:15:08 00:01:37:12 00:05:04:10 00:05:26:14
* FROM CLIP NAME:  12 - Environs A - T Juckes, S Kidd - SCDV354
009  0000     A2    C        00:00:00:00 00:00:26:19 00:06:00:08 00:06:27:02
* FROM CLIP NAME:  38 - Signs Of Pollution - W Plass - SCDV354
010  0000     A2    C        00:00:25:08 00:01:13:03 00:06:39:16 00:07:27:11
* FROM CLIP NAME:  38 - Signs Of Pollution - W Plass - SCDV354
011  0000     A2    C        00:01:13:03 00:01:13:03 00:07:27:11 00:07:27:11
M2   0000        025.0              00:01:13:03
011  0000     A2    D    025 00:01:48:22 00:02:04:09 00:07:27:11 00:07:42:23
* EFFECT NAME: CROSS DISSOLVE
* FROM CLIP NAME:  38 - Signs Of Pollution - W Plass - SCDV354
* TO CLIP NAME:  38 - Signs Of Pollution - W Plass - SCDV354
M2   0000        025.0              00:01:48:22
...