gpt4 book ai didi

javascript - 如何在node js中解压缩.prproj文件(premiere pro项目)?

转载 作者:行者123 更新时间:2023-12-01 00:49:11 46 4
gpt4 key购买 nike

Premiere pro 文件 (.prproj) 是 xml 的压缩文件。如果我在 mac 上使用 unzip 实用程序,我可以解压它们。但是当我尝试在 Node 中执行此操作时,我没有成功。

我在 npm 上尝试了一些流行的解压缩模块,但没有一个起作用。

示例:

const decompressUnzip = require('decompress-unzip')()

const main = async () => {
const file = fs.readFileSync(path.join(__dirname, 'test-project.prproj'))
console.log(file) // <Buffer 1f 8b 08 00 00 00 00 00 00 0a ec bd 6d 93 9c 38 b6 2e fa 79 f6 af c8 e8 1b d1 fd e5 90 c5 fb 4b bb a7 3b ec 2a 7b ba ce 94 db 15 ae 6a f7 39 e7 ce 8d ... >
const files = await decompressUnzip(file)
console.log(files) // []
}
main()

我相信 1f 8b 08 00 00 是 gzip,不确定这是否有区别。

这是文件https://www.mediafire.com/file/uzw7as8hntokst2/test-project._prproj/file

最佳答案

1f 8b 08 是 gz 压缩文件的开头。 decompress-unzip 是一个解压缩 zip 文件而不是 gz 压缩数据的模块。

您可以使用内置 Node zlib.gunzip解压缩该数据。

const fs = require('fs')
const zlib = require('zlib')
const path = require('path')

function main () {
const file = fs.readFileSync(path.join(__dirname, 'test-project.prproj'))
const files = zlib.gunzipSync(file)

console.log(files.toString())
}
main()

作为任意解决方案:

const { promisify } = require('util')
const readFile = promisify(require('fs').readFile)
const gunzip = promisify(require('zlib').gunzip)
const path = require('path')

async function main () {
const file = await readFile(path.join(__dirname, 'test-project.prproj'))
const files = await gunzip(file)

console.log(files.toString())
}
main()

关于javascript - 如何在node js中解压缩.prproj文件(premiere pro项目)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57121715/

46 4 0
文章推荐: javascript - 将列表传递给 View 后如何转换列表的 C# 列表?
文章推荐: javascript - Vue.js:如何修复 'b-modal' 未在自定义组件中显示
文章推荐: javascript - 类型错误 : Cannot assign to read only property 'exports' of object '#' in ReactJS