删除 EDL 文本文件的元素,对其他部分执行算术运算
Remove elements of an EDL text file, perform arithmetic on other parts
我有一个简单格式的文本文件(编辑决策列表),其中包含几行数字(时间码帧速率 25),后跟几行属性(名称等)。
最终我想:
检索以 * FROM CLIP NAME:
开头的行和上面的 row/line(时间码)。这一行是Timecodes,有4组数字,每组表示为00:00:00:00-或HH:MM:SS:FF或小时、分钟、秒、帧。然后我丢弃所有其他东西。
使用前 2 个数字组(它们是开始时间和结束时间)导出 duration。
然后将 duration 附加到剪辑名称行。
将文件另存为 "SourceFileName".txt(原文件为 .edl,因此不会被覆盖)。
因为我的帧速率是每秒 25 帧,所以我希望将每个组分解为 帧数 。
我希望将时间码转换为每秒 25 帧:
- 帧时基的小时数 (25fps) 1 小时 = 1*60*(60*25) = 9000
- 分钟到帧时基 (25fps) 1 分钟 = 1*(60*25) = 1500
- 秒到帧时基 (25fps) 1 秒 = 1*25f
这将使一组 00:02:20:01 = 3501 帧
- 3501 整数除法 // 25 fps = 140 秒
3501取模(%) 25=1帧余数
140/60 = 2 分钟
- 140%60 = 20 秒
然后我会用第二组减去第一组来找出差异。一旦我得到差异,我将帧计数重新组合为时间码,只是颠倒数学。
我不知道如何指定名称行,然后使用 4 组中的前 2 组抓取前面的行进行算术运算。
到目前为止(不远)我只为用户建立了一种在桌面上定义源文件的方法。
Option Explicit
Dim fso, oFile, y
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")
UPDATE:修改后的脚本,但我什至无法将所选行及其 start/end 值
Option Explicit
Dim fso, oFile, y, re, prev, line, matches
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
'do stuff here
Set re = New RegExp
re.Pattern = "C (\d{2}:\d{2}:\d{2}:\d{2}) (\d{2}:\d{2}:\d{2}:\d{2})"
matches = re.Execute(prev)
'print each pair of prev & Pattern match
prev = (line) & (matches)
wscript.echo prev
'don't know how to use submatch values
End If
Loop
示例 .edl 文件:
TITLE: test logan
* 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
我必须在 VBScript 中执行此操作,以便我们可以 运行 在不同用户的 Windows 桌面上使用它。我们无法从命令提示符安装其他可执行文件或 运行。我没有管理员安装权限。
读取文件时记住单独变量中的上一行:
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, 19) = "* FROM CLIP NAME: " Then
'do stuff here
End If
prev = line
Loop
使用 regular expression 提取开始和结束时间戳。
Set re = New RegExp
re.Pattern = " (\d{2}:\d{2}:\d{2}:\d{2}) (\d{2}:\d{2}:\d{2}:\d{2})"
Set matches = re.Execute(prev)
时间戳可用作 matches
的第一个和第二个子匹配项。
但是请注意,输入文件中的某些 FROM CLIP NAME
行前面似乎没有时间戳行,因此您需要处理它。
我有一个简单格式的文本文件(编辑决策列表),其中包含几行数字(时间码帧速率 25),后跟几行属性(名称等)。
最终我想:
检索以
* FROM CLIP NAME:
开头的行和上面的 row/line(时间码)。这一行是Timecodes,有4组数字,每组表示为00:00:00:00-或HH:MM:SS:FF或小时、分钟、秒、帧。然后我丢弃所有其他东西。使用前 2 个数字组(它们是开始时间和结束时间)导出 duration。
然后将 duration 附加到剪辑名称行。
将文件另存为 "SourceFileName".txt(原文件为 .edl,因此不会被覆盖)。
因为我的帧速率是每秒 25 帧,所以我希望将每个组分解为 帧数 。
我希望将时间码转换为每秒 25 帧:
- 帧时基的小时数 (25fps) 1 小时 = 1*60*(60*25) = 9000
- 分钟到帧时基 (25fps) 1 分钟 = 1*(60*25) = 1500
- 秒到帧时基 (25fps) 1 秒 = 1*25f
这将使一组 00:02:20:01 = 3501 帧
- 3501 整数除法 // 25 fps = 140 秒
3501取模(%) 25=1帧余数
140/60 = 2 分钟
- 140%60 = 20 秒
然后我会用第二组减去第一组来找出差异。一旦我得到差异,我将帧计数重新组合为时间码,只是颠倒数学。
我不知道如何指定名称行,然后使用 4 组中的前 2 组抓取前面的行进行算术运算。
到目前为止(不远)我只为用户建立了一种在桌面上定义源文件的方法。
Option Explicit
Dim fso, oFile, y
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")
UPDATE:修改后的脚本,但我什至无法将所选行及其 start/end 值
Option Explicit
Dim fso, oFile, y, re, prev, line, matches
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
'do stuff here
Set re = New RegExp
re.Pattern = "C (\d{2}:\d{2}:\d{2}:\d{2}) (\d{2}:\d{2}:\d{2}:\d{2})"
matches = re.Execute(prev)
'print each pair of prev & Pattern match
prev = (line) & (matches)
wscript.echo prev
'don't know how to use submatch values
End If
Loop
示例 .edl 文件:
TITLE: test logan * 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
我必须在 VBScript 中执行此操作,以便我们可以 运行 在不同用户的 Windows 桌面上使用它。我们无法从命令提示符安装其他可执行文件或 运行。我没有管理员安装权限。
读取文件时记住单独变量中的上一行:
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, 19) = "* FROM CLIP NAME: " Then
'do stuff here
End If
prev = line
Loop
使用 regular expression 提取开始和结束时间戳。
Set re = New RegExp
re.Pattern = " (\d{2}:\d{2}:\d{2}:\d{2}) (\d{2}:\d{2}:\d{2}:\d{2})"
Set matches = re.Execute(prev)
时间戳可用作 matches
的第一个和第二个子匹配项。
但是请注意,输入文件中的某些 FROM CLIP NAME
行前面似乎没有时间戳行,因此您需要处理它。