libav-wasm 0.6.0 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -61
- package/build/libav.wasm +0 -0
- package/package.json +41 -41
package/README.md
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
# LibAV WASM
|
|
2
|
-
|
|
3
|
-
This library can be used to remux from MKV -> MP4, it could technically do any remux but i haven't had the need for it, create an issue if you'd like it.
|
|
4
|
-
|
|
5
|
-
[src/test.ts](https://github.com/Banou26/libav-wasm/blob/main/src/test.ts)
|
|
6
|
-
Contains a full example of a MKV video player
|
|
7
|
-
|
|
8
|
-
Basic usage
|
|
9
|
-
```ts
|
|
10
|
-
const remuxer = await makeRemuxer({
|
|
11
|
-
// the path at which the wasm file is getting served
|
|
12
|
-
publicPath: new URL('/dist/', new URL(import.meta.url).origin).toString(),
|
|
13
|
-
// url of the worker file of libavWASM
|
|
14
|
-
workerUrl: new URL('../build/worker.js', import.meta.url).toString(),
|
|
15
|
-
// reads will be done in 2.5mb chunks
|
|
16
|
-
bufferSize: 2_500_000,
|
|
17
|
-
// byte length of the video file
|
|
18
|
-
length: contentLength,
|
|
19
|
-
// fetch returning a ReadableStream
|
|
20
|
-
getStream: async (offset, size) =>
|
|
21
|
-
fetch(
|
|
22
|
-
VIDEO_URL,
|
|
23
|
-
{
|
|
24
|
-
headers: {
|
|
25
|
-
Range: `bytes=${offset}-${size ? Math.min(offset + size, contentLength) - 1 : ''}`
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
).then(res => res.body)
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
// returns the header of the video with all the metadata
|
|
32
|
-
const header = await remuxer.init()
|
|
33
|
-
|
|
34
|
-
// Returns a chunk that looks like {
|
|
35
|
-
// offset: number,
|
|
36
|
-
// buffer: Uint8Array,
|
|
37
|
-
// pos: number,
|
|
38
|
-
// pts: number, // timestamp
|
|
39
|
-
// duration: number
|
|
40
|
-
// }
|
|
41
|
-
// buffer can be appended to the MediaSource API(MSE API)
|
|
42
|
-
const chunk = await remuxer.read()
|
|
43
|
-
|
|
44
|
-
// allows you to seek to timestamp and start reading from there
|
|
45
|
-
const seekChunk = await remuxer.seek(number)
|
|
46
|
-
// ...
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
## Intellisense
|
|
51
|
-
To have C++ autocompletion, put a ffmpeg repo clone folder in the root
|
|
52
|
-
`git clone https://github.com/FFmpeg/FFmpeg` & `git clone https://github.com/emscripten-core/emscripten`
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
## Issues to fix / features to implement
|
|
57
|
-
- Try to play around with `sourceBuffer.timestampOffset = res.pts` and always increasing timestamps to not have to re-init on backwards seeks
|
|
58
|
-
- Transcoding
|
|
59
|
-
- Base transcoding off of https://cconcolato.github.io/media-mime-support/#audio_codecs
|
|
60
|
-
<!-- https://www.ffmpeg.org/doxygen/trunk/remuxing_8c-example.html -->
|
|
61
|
-
<!-- https://github.com/leandromoreira/ffmpeg-libav-tutorial -->
|
|
1
|
+
# LibAV WASM
|
|
2
|
+
|
|
3
|
+
This library can be used to remux from MKV -> MP4, it could technically do any remux but i haven't had the need for it, create an issue if you'd like it.
|
|
4
|
+
|
|
5
|
+
[src/test.ts](https://github.com/Banou26/libav-wasm/blob/main/src/test.ts)
|
|
6
|
+
Contains a full example of a MKV video player
|
|
7
|
+
|
|
8
|
+
Basic usage
|
|
9
|
+
```ts
|
|
10
|
+
const remuxer = await makeRemuxer({
|
|
11
|
+
// the path at which the wasm file is getting served
|
|
12
|
+
publicPath: new URL('/dist/', new URL(import.meta.url).origin).toString(),
|
|
13
|
+
// url of the worker file of libavWASM
|
|
14
|
+
workerUrl: new URL('../build/worker.js', import.meta.url).toString(),
|
|
15
|
+
// reads will be done in 2.5mb chunks
|
|
16
|
+
bufferSize: 2_500_000,
|
|
17
|
+
// byte length of the video file
|
|
18
|
+
length: contentLength,
|
|
19
|
+
// fetch returning a ReadableStream
|
|
20
|
+
getStream: async (offset, size) =>
|
|
21
|
+
fetch(
|
|
22
|
+
VIDEO_URL,
|
|
23
|
+
{
|
|
24
|
+
headers: {
|
|
25
|
+
Range: `bytes=${offset}-${size ? Math.min(offset + size, contentLength) - 1 : ''}`
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
).then(res => res.body)
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
// returns the header of the video with all the metadata
|
|
32
|
+
const header = await remuxer.init()
|
|
33
|
+
|
|
34
|
+
// Returns a chunk that looks like {
|
|
35
|
+
// offset: number,
|
|
36
|
+
// buffer: Uint8Array,
|
|
37
|
+
// pos: number,
|
|
38
|
+
// pts: number, // timestamp
|
|
39
|
+
// duration: number
|
|
40
|
+
// }
|
|
41
|
+
// buffer can be appended to the MediaSource API(MSE API)
|
|
42
|
+
const chunk = await remuxer.read()
|
|
43
|
+
|
|
44
|
+
// allows you to seek to timestamp and start reading from there
|
|
45
|
+
const seekChunk = await remuxer.seek(number)
|
|
46
|
+
// ...
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
## Intellisense
|
|
51
|
+
To have C++ autocompletion, put a ffmpeg repo clone folder in the root
|
|
52
|
+
`git clone https://github.com/FFmpeg/FFmpeg` & `git clone https://github.com/emscripten-core/emscripten`
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
## Issues to fix / features to implement
|
|
57
|
+
- Try to play around with `sourceBuffer.timestampOffset = res.pts` and always increasing timestamps to not have to re-init on backwards seeks
|
|
58
|
+
- Transcoding
|
|
59
|
+
- Base transcoding off of https://cconcolato.github.io/media-mime-support/#audio_codecs
|
|
60
|
+
<!-- https://www.ffmpeg.org/doxygen/trunk/remuxing_8c-example.html -->
|
|
61
|
+
<!-- https://github.com/leandromoreira/ffmpeg-libav-tutorial -->
|
package/build/libav.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "libav-wasm",
|
|
3
|
-
"version": "0.6.
|
|
4
|
-
"main": "build/index.js",
|
|
5
|
-
"files": [
|
|
6
|
-
"build"
|
|
7
|
-
],
|
|
8
|
-
"types": "build/index.d.ts",
|
|
9
|
-
"type": "module",
|
|
10
|
-
"scripts": {
|
|
11
|
-
"dev": "npm i ./dist && concurrently \"npm run dev-wasm-cmd\" \"npm run dev-web\" \"npm run worker-build-dev\"",
|
|
12
|
-
"dev-wasm-cmd": "nodemon -e cpp --exec \"npm run make-docker\"",
|
|
13
|
-
"dev-wasm": "concurrently \"nodemon -e cpp --exec \\\"npm run make-docker\\\"\"",
|
|
14
|
-
"build-worker": "vite build --config vite-worker.config.ts",
|
|
15
|
-
"make-docker": "docker-compose run libav-wasm make",
|
|
16
|
-
"docker-clean": "docker compose up --remove-orphans",
|
|
17
|
-
"dev-web": "vite --port 1234",
|
|
18
|
-
"vite-build": "vite build",
|
|
19
|
-
"vite-build-dev": "vite build --watch",
|
|
20
|
-
"worker-build-dev": "nodemon -e ts --watch src/worker --exec \"npm run build-worker\"",
|
|
21
|
-
"build": "npm run copy-package && npm run make-docker && npm i ./dist && vite build && npm run build-worker && npm run types && npm run copy-wasm && npm remove libav",
|
|
22
|
-
"types": "tsc",
|
|
23
|
-
"copy-package": "copyfiles -u 2 ./src/build-config/package.json dist",
|
|
24
|
-
"copy-wasm": "copyfiles -u 1 dist/*.wasm build && shx mv ./build/worker/index.d.ts ./build/worker.d.ts && shx rm -rf ./build/worker",
|
|
25
|
-
"preview": "vite preview"
|
|
26
|
-
},
|
|
27
|
-
"devDependencies": {
|
|
28
|
-
"@rollup/plugin-commonjs": "^24.0.1",
|
|
29
|
-
"concurrently": "^7.6.0",
|
|
30
|
-
"copyfiles": "^2.4.1",
|
|
31
|
-
"nodemon": "^2.0.22",
|
|
32
|
-
"shx": "^0.3.4",
|
|
33
|
-
"typescript": "^5.7.3",
|
|
34
|
-
"vite": "^6.1.0"
|
|
35
|
-
},
|
|
36
|
-
"dependencies": {
|
|
37
|
-
"@types/emscripten": "^1.40.0",
|
|
38
|
-
"osra": "^0.1.2",
|
|
39
|
-
"p-queue": "^7.3.0"
|
|
40
|
-
}
|
|
41
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "libav-wasm",
|
|
3
|
+
"version": "0.6.2",
|
|
4
|
+
"main": "build/index.js",
|
|
5
|
+
"files": [
|
|
6
|
+
"build"
|
|
7
|
+
],
|
|
8
|
+
"types": "build/index.d.ts",
|
|
9
|
+
"type": "module",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"dev": "npm i ./dist && concurrently \"npm run dev-wasm-cmd\" \"npm run dev-web\" \"npm run worker-build-dev\"",
|
|
12
|
+
"dev-wasm-cmd": "nodemon -e cpp --exec \"npm run make-docker\"",
|
|
13
|
+
"dev-wasm": "concurrently \"nodemon -e cpp --exec \\\"npm run make-docker\\\"\"",
|
|
14
|
+
"build-worker": "vite build --config vite-worker.config.ts",
|
|
15
|
+
"make-docker": "docker-compose run libav-wasm make",
|
|
16
|
+
"docker-clean": "docker compose up --remove-orphans",
|
|
17
|
+
"dev-web": "vite --port 1234",
|
|
18
|
+
"vite-build": "vite build",
|
|
19
|
+
"vite-build-dev": "vite build --watch",
|
|
20
|
+
"worker-build-dev": "nodemon -e ts --watch src/worker --exec \"npm run build-worker\"",
|
|
21
|
+
"build": "npm run copy-package && npm run make-docker && npm i ./dist && vite build && npm run build-worker && npm run types && npm run copy-wasm && npm remove libav",
|
|
22
|
+
"types": "tsc",
|
|
23
|
+
"copy-package": "copyfiles -u 2 ./src/build-config/package.json dist",
|
|
24
|
+
"copy-wasm": "copyfiles -u 1 dist/*.wasm build && shx mv ./build/worker/index.d.ts ./build/worker.d.ts && shx rm -rf ./build/worker",
|
|
25
|
+
"preview": "vite preview"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@rollup/plugin-commonjs": "^24.0.1",
|
|
29
|
+
"concurrently": "^7.6.0",
|
|
30
|
+
"copyfiles": "^2.4.1",
|
|
31
|
+
"nodemon": "^2.0.22",
|
|
32
|
+
"shx": "^0.3.4",
|
|
33
|
+
"typescript": "^5.7.3",
|
|
34
|
+
"vite": "^6.1.0"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@types/emscripten": "^1.40.0",
|
|
38
|
+
"osra": "^0.1.2",
|
|
39
|
+
"p-queue": "^7.3.0"
|
|
40
|
+
}
|
|
41
|
+
}
|