forked from forks/ffprobe-wasm-npm
Compare commits
15 Commits
v0.3.0
...
4bc9acdada
| Author | SHA1 | Date | |
|---|---|---|---|
|
4bc9acdada
|
|||
|
f97fb957dc
|
|||
|
d9013772ef
|
|||
|
fad46dbae1
|
|||
|
98151ecaef
|
|||
|
efa4e6f0a2
|
|||
|
24a55c018f
|
|||
|
bc9e1670b2
|
|||
|
c0e13cdaa1
|
|||
|
3d1951c50a
|
|||
|
90864d1b05
|
|||
|
e7dbb8c0c9
|
|||
|
cece48aaeb
|
|||
|
5214d5c530
|
|||
|
ff2bef3e9c
|
2
.gitmodules
vendored
2
.gitmodules
vendored
@@ -1,3 +1,3 @@
|
||||
[submodule "ffprobe-wasm-app"]
|
||||
path = ffprobe-wasm-app
|
||||
url = https://github.com/alfg/ffprobe-wasm
|
||||
url = https://git.cislabs.de/cis-oss/ffprobe-wasm
|
||||
|
||||
3
build.sh
3
build.sh
@@ -12,14 +12,13 @@ cd ffprobe-wasm-app
|
||||
docker-compose run ffprobe-wasm make
|
||||
cd ..
|
||||
cp -R ffprobe-wasm-app/dist dist
|
||||
node scripts/replace.js
|
||||
cp src/*.d.* dist
|
||||
|
||||
# Build browser/node workers
|
||||
npm run build
|
||||
|
||||
# Remove unnecessary files
|
||||
rm dist/browser-vite.* dist/ffprobe-wasm.d.mts dist/ffprobe-wasm.mjs dist/worker-browser.*
|
||||
rm dist/browser-vite.* dist/worker-browser.*
|
||||
|
||||
# Copy files for npm publish
|
||||
cp package.json LICENSE README.md dist
|
||||
|
||||
Submodule ffprobe-wasm-app updated: d07d02b6e6...62ae9d08f0
2522
package-lock.json
generated
2522
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
23
package.json
23
package.json
@@ -1,13 +1,10 @@
|
||||
{
|
||||
"name": "ffprobe-wasm",
|
||||
"version": "0.3.0",
|
||||
"name": "@cis-oss/avprobe-wasm",
|
||||
"version": "0.3.2",
|
||||
"description": "ffprobe-like for browser and node, powered by WebAssembly",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/tfoxy/ffprobe-wasm"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/tfoxy/ffprobe-wasm/issues"
|
||||
"url": "https://git.cislabs.de/cis-oss/ffprobe-wasm-npm"
|
||||
},
|
||||
"keywords": [
|
||||
"ffprobe",
|
||||
@@ -15,7 +12,11 @@
|
||||
"ffmpeg",
|
||||
"video"
|
||||
],
|
||||
"author": "Tomás Fox <tomas.c.fox@gmail.com>",
|
||||
"author": {
|
||||
"name": "Alix von Schirp",
|
||||
"url": "https://b00tload.space",
|
||||
"email": "hi@b00tload.space"
|
||||
},
|
||||
"license": "MIT",
|
||||
"exports": {
|
||||
"node": "./node.mjs",
|
||||
@@ -31,8 +32,10 @@
|
||||
"vite": "vite build"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^17.0.21",
|
||||
"typescript": "^4.5.5",
|
||||
"vite": "^2.8.6"
|
||||
"@types/node": "^25.2.3",
|
||||
"typescript": "^5.9.3",
|
||||
"vite": "^7.3.1",
|
||||
"vite-plugin-top-level-await": "^1.6.0",
|
||||
"vite-plugin-wasm": "^3.5.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
const { readFile, writeFile } = require("fs/promises");
|
||||
const { dirname, resolve } = require("path");
|
||||
|
||||
main();
|
||||
|
||||
async function main() {
|
||||
const root = dirname(__dirname);
|
||||
|
||||
const wasmJsPath = resolve(root, "dist/ffprobe-wasm.mjs");
|
||||
|
||||
let content = await readFile(wasmJsPath, { encoding: "utf8" });
|
||||
|
||||
content = `\
|
||||
import initWasmInstance from "./ffprobe-wasm.wasm";
|
||||
const initWasm = (info) =>
|
||||
initWasmInstance(info).then((exports) => ({ instance: { exports } }));
|
||||
${content}`;
|
||||
|
||||
content = content.replace(`import.meta.url`, `''`);
|
||||
|
||||
content = content.replace(
|
||||
`instantiateAsync().catch(readyPromiseReject)`,
|
||||
`initWasm(info).then(receiveInstantiatedSource, readyPromiseReject)`
|
||||
);
|
||||
|
||||
await writeFile(wasmJsPath, content, { encoding: "utf8" });
|
||||
}
|
||||
@@ -92,7 +92,7 @@ export function createListener(
|
||||
function serializeStreams(streams: Vector<Raw<Stream>>) {
|
||||
return vectorToArray(streams).map((stream) => ({
|
||||
...stream,
|
||||
tags: dictionaryVectorToRecord(stream.tags),
|
||||
tags: (stream && stream.tags) ? dictionaryVectorToRecord(stream.tags) : {},
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -109,16 +109,19 @@ export function createListener(
|
||||
|
||||
const rawInfo = get_file_info(`/work/${fileName}`);
|
||||
|
||||
// Safety check on rawInfo itself
|
||||
if (!rawInfo) throw new Error("FFprobe failed to return file info");
|
||||
|
||||
return {
|
||||
streams: serializeStreams(rawInfo.streams),
|
||||
chapters: vectorToArray(rawInfo.chapters).map((chapter) => ({
|
||||
chapters: rawInfo.chapters ? vectorToArray(rawInfo.chapters).map((chapter) => ({
|
||||
...chapter,
|
||||
tags: dictionaryVectorToRecord(chapter.tags),
|
||||
})),
|
||||
tags: chapter.tags ? dictionaryVectorToRecord(chapter.tags) : {},
|
||||
})) : [],
|
||||
format: {
|
||||
...rawInfo.format,
|
||||
tags: dictionaryVectorToRecord(rawInfo.format.tags),
|
||||
},
|
||||
tags: (rawInfo.format && rawInfo.format.tags) ? dictionaryVectorToRecord(rawInfo.format.tags) : {},
|
||||
}
|
||||
};
|
||||
} finally {
|
||||
// Cleanup mount.
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { resolve } from "path";
|
||||
import { defineConfig } from "vite";
|
||||
import topLevelAwait from "vite-plugin-top-level-await";
|
||||
import wasm from "vite-plugin-wasm";
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
@@ -14,18 +16,16 @@ export default defineConfig({
|
||||
minify: false,
|
||||
sourcemap: true,
|
||||
},
|
||||
plugins: [
|
||||
|
||||
wasm(),
|
||||
topLevelAwait()
|
||||
],
|
||||
worker: {
|
||||
plugins: [
|
||||
{
|
||||
name: "append-source-url",
|
||||
generateBundle(options, bundle) {
|
||||
Object.entries(bundle).forEach(([file, output]) => {
|
||||
if (output.type === "chunk") {
|
||||
output.code += `\n//# sourceURL=${file}`;
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
plugins: () => [
|
||||
wasm(),
|
||||
topLevelAwait(),
|
||||
],
|
||||
format: "es"
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user