如何在代码中访问到Premiere中的旧版标题数据?
使用extendscript无法直接访问到下图中的字符串“abcdefg”,该如何做?
每一个Preimere工程文件实际上都是一个压缩包,可以使用解压软件直接打开,提取到解压的文件之后,使用记事本打开,会得到一串xml文件,经过查找与判定,我们要找的字符串在这一段代码中
但它是被使用base64编码过后,如何解码操作?
运行下面这一段代码,它可以实现访问PR工程中的旧版标题的字符串
import java.util.zip.Inflater
import java.nio.*
def tx = new XmlSlurper(false,true,true)
tx.setFeature("http://apache.org/xml/features/disallow-doctype-decl", false)
tx.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false)
def pr = new XmlSlurper()
def prx = pr.parse(new File("test1"))
String decompress2(byte[] compressed) {
// Decompress the bytes
if (compressed.length <= 32)
return new String(compressed, "unicode");
xmlout = new ByteArrayOutputStream (10000)
Inflater decompresser = new Inflater();
decompresser.setInput(compressed, 32, compressed.length - 32);
do {
byte[] result = new byte[1000];
int resultLength = decompresser.inflate(result);
xmlout.write(result, 0, resultLength)
} while (!decompresser.finished())
finalSize = decompresser.bytesWritten
println " Final Length = $finalSize"
decompresser.end();
return new String(xmlout.toByteArray(), 0, finalSize as Integer, "unicode")
}
projData = prx.'**'.findAll { it.@Encoding == 'base64' }
projData.each {
try{
println it.name()
println it.attributes()
bdat = (it.toString()).decodeBase64()
if (it.name() == "ImporterPrefs") {
itemData = decompress2 (bdat)
if (itemData.size() > 32) {
txml = tx.parseText( itemData )
txtml = txml.'**'.findAll {txtN -> txtN.name() == 'TRString'}
println itemData
println "============"
println txml
txtml.each {println it}
} else {
println "Short Data Item: $itemData"
}
} else {
println "Base64 content: ${new String(bdat, "utf-8")}"
}
} catch ( x ) {
println x
}
}
注意,这是使用groovy编写,需要先安装Java虚拟机,再安装groovy,配置好环境变量
将此代码保存为“hello.groovy”,之后,在cmd命令下运行
groovy hello.groovy
得到结果:
C:\Users\fengda>groovy hello.groovy
ImporterPrefs
[Encoding:base64, BinaryHash:6d87c8aa-4a43-b4f0-76aa-d33200000c72]
Final Length = 25026
abcdefg