Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
ea9b050
Preserve rotation when calling `.toVideoFrame()`
JonnyBurger Nov 6, 2025
f0d0e51
Inherit rotation from VideoFrame when constructing VideoSample from it
JonnyBurger Nov 6, 2025
4f7a980
Fix VideoSample drawing when the underlying VideoFrame is rotated, fi…
Vanilagy Nov 11, 2025
d447958
Merge branch 'main' into fork-branch
Vanilagy Nov 11, 2025
c11912c
Merge pull request #212 from JonnyBurger/apply-rotation-to-videoframe
Vanilagy Nov 11, 2025
7fd2ec6
WIP
Vanilagy Nov 14, 2025
bd9d351
WIP 2
Vanilagy Nov 14, 2025
408b4e4
WIP
Vanilagy Nov 19, 2025
52d7ba0
Merge branch 'main' into cursors
Vanilagy Nov 26, 2025
f86294b
BIG cursor progress
Vanilagy Nov 27, 2025
48abcb2
Merge branch 'main' into cursors
Vanilagy Dec 12, 2025
0f015d8
Add AudioSampleCursor, make sample cursor error behavior more explici…
Vanilagy Dec 14, 2025
fbcb4dc
By the creators of AsyncMutex3
Vanilagy Dec 14, 2025
9222d94
Make cursor initialization instant, fix some code
Vanilagy Dec 15, 2025
f045e59
Implement sample cursor reset()
Vanilagy Dec 15, 2025
d44b8bd
Clone samples when reused with autoClose: false
Vanilagy Dec 15, 2025
3bd227b
Change pump reuse rule: enforce queued commands are resolved in the o…
Vanilagy Dec 17, 2025
8267d01
Rename and extract function
Vanilagy Dec 17, 2025
48c8b38
Add InputDisposedError throwing to PacketReader
Vanilagy Dec 17, 2025
9dbab13
Add input type validation
Vanilagy Dec 17, 2025
8815eab
Add nextKey, better define waitUntilIdle, fix some bugs
Vanilagy Dec 18, 2025
75af91f
Validate nextKey behavior for audio tracks
Vanilagy Dec 18, 2025
de82f6f
SampleCursor code cleanup & couple of more fixes
Vanilagy Dec 18, 2025
3fa95cb
Update media player example to use cursors, fix some cursor bugs, add…
Vanilagy Dec 20, 2025
ece27cc
Update thumbnail generation example to use cursors
Vanilagy Dec 21, 2025
00efb69
Fully update MP3 demuxer to use new packet reading system & mutex, ad…
Vanilagy Dec 21, 2025
6722592
Migrate fragmented MP4 reading to new packet system, add tests for it…
Vanilagy Dec 21, 2025
3285d5e
Migrate Matroska demuxer to new packet system
Vanilagy Dec 21, 2025
b2c86ec
Migrate WAVE demuxer to new packet system
Vanilagy Dec 21, 2025
0768f61
Migrate ADTS demuxer to new packet system
Vanilagy Dec 21, 2025
bc1511a
Migrate Ogg demuxer to new packet system, improve Ogg demuxer perform…
Vanilagy Dec 22, 2025
4f8c883
Migrate FLAC demuxer to new packet system, move computeDuration impl …
Vanilagy Dec 22, 2025
58d73b7
Make more use of sequenceNumber in getNextPacket
Vanilagy Dec 22, 2025
e56e754
Formatting
Vanilagy Dec 22, 2025
eed49ee
Remove media sinks, adapt conversion code and computePacketStats to u…
Vanilagy Dec 28, 2025
0530c91
Remove setTimestamp for AudioSample, add override options to its clon…
Vanilagy Dec 28, 2025
405c91b
Fix tests
Vanilagy Dec 28, 2025
04b5cd8
Merge remote-tracking branch 'origin/v2' into cursors
Vanilagy Dec 29, 2025
22dbf4b
Remove code
Vanilagy Dec 29, 2025
a614aee
Fix type errors
Vanilagy Dec 29, 2025
d1dee61
Add missing license headers
Vanilagy Dec 29, 2025
0ad41a0
Fix lint warnings
Vanilagy Dec 29, 2025
5b6b097
Merge branch 'main' into v2
Vanilagy Dec 29, 2025
ab4ef82
Merge branch 'v2' into cursors
Vanilagy Dec 29, 2025
c2cfbbc
Fix type errors
Vanilagy Dec 29, 2025
e9952a5
CI lint fix?
Vanilagy Dec 29, 2025
87d4c5b
Bundle to ES2021
Vanilagy Dec 29, 2025
72de8da
Give ResultValue return type proper names, document ResultValue
Vanilagy Dec 29, 2025
aafb928
Remove older mutexes (mutices??)
Vanilagy Dec 29, 2025
8467a9d
Name call serializers differently
Vanilagy Dec 30, 2025
ba26367
PacketReader read -> get method naming
Vanilagy Dec 30, 2025
51b9de1
Move PacketReader elsewhere
Vanilagy Dec 30, 2025
f8212c3
Fix lint error
Vanilagy Dec 30, 2025
7c4217d
Merge pull request #262 from Vanilagy/cursors
Vanilagy Dec 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions dev/convert.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
}),
output,
audio: (_, n) => ({
codec: 'opus',
discard: n > 1,
//codec: 'opus',
//codec: 'opus',
Expand Down Expand Up @@ -100,7 +101,12 @@
},
*/
video: () => ({
//discard: true,
allowRotationMetadata: false,
forceTranscode: true,
width: 320,
frameRate: 3,
//frameRate: 30,
//width: 720,
//frameRate: 30,
//bitrate: Mediabunny.QUALITY_VERY_LOW,
Expand Down Expand Up @@ -180,8 +186,8 @@
}
},
trim: {
start: 0,
end: 4
start: 590,
//end: 590
},
});
console.log(conversion);
Expand Down
119 changes: 110 additions & 9 deletions dev/demux.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,123 @@
const file = fileInput.files[0];
const input = new Mediabunny.Input({
formats: Mediabunny.ALL_FORMATS,
source: new Mediabunny.BlobSource(file),
source: new Mediabunny.BufferSource(await file.arrayBuffer()),
});

const videoTrack = await input.getPrimaryVideoTrack();
const sink = new Mediabunny.EncodedPacketSink(videoTrack);
const audioTrack = await input.getPrimaryAudioTrack();

for await (const packet of sink.packets()) {
console.log(packet);
const iters = 250;
let total = 0;

for (let i = 0; i < iters; i++) {
const start = performance.now();
let count = 0;
const reader = new Mediabunny.PacketCursor(audioTrack);
await reader.iterate(() => count++);

console.log(count)

total += performance.now() - start;
}

alert(total / iters);

/*
const videoTrack = await input.getPrimaryVideoTrack();
const sink = new Mediabunny.EncodedPacketSink(videoTrack);
console.log(await cursor.seekTo(2.00));
console.log(await cursor.next());
console.log(await cursor.next());
*/

for await (const packet of sink.packets()) {
console.log(packet);
//console.log(await cursor.seekTo(4.9))
//console.log(await cursor.seekTo(5.1))
//return;

/*
const mh = [
cursor.seekTo(2.05),
//cursor.seekTo(4.9),
//cursor.seekTo(4.9),
//cursor.seekTo(4.9),
//cursor.seekTo(4.9),
//cursor.next(),
cursor.next(),
cursor.next(),
cursor.next(),
cursor.next(),
cursor.next(),
cursor.next(),
cursor.next(),
cursor.next(),
cursor.next(),
cursor.next(),
cursor.next(),
cursor.next(),
cursor.next(),
cursor.next(),
cursor.next(),
cursor.next(),
cursor.close(),
//cursor.next(),
//cursor.next(),
//cursor.next(),
//cursor.next(),
//cursor.close(),
//cursor.seekTo(2.10),
//cursor.seekTo(5),
//cursor.close(),
//cursor.seekTo(2.00),
];
*/

/*
for (const yo of mh) {
const samp = await yo;
console.log(samp)
samp?.close();
}

console.log("done")
*/

//console.log(await Promise.all(mh));

//console.log(await cursor.seekTo(2.05));
//console.log(await cursor.seekTo(2.10));
//console.log(await cursor.seekTo(10.2));
//console.log(await cursor.seekTo(5.2));

/*
setTimeout(async () => {
console.log("this")

}, 500);
*/


/*
const iters = 5;
let total = 0;

for (let i = 0; i < iters; i++) {
const file = fileInput.files[0];
const input = new Mediabunny.Input({
formats: Mediabunny.ALL_FORMATS,
source: new Mediabunny.BufferSource(await file.arrayBuffer()),
});

const audioTrack = await input.getPrimaryAudioTrack();
const cursor = new Mediabunny.PacketCursor(audioTrack);

await cursor.seekToStart();

const start = performance.now();
await cursor.iterate(() => {});
//alert(performance.now() - start)

total += performance.now() - start;
}

alert(total / iters);
*/

/*
Expand Down Expand Up @@ -110,6 +209,8 @@
total += end - start;
//console.log(total / file.size, end - start);
}
alert(elapsed / iters);


const videoTrack = await input.getPrimaryVideoTrack();
const sink = new Mediabunny.EncodedPacketSink(videoTrack);
Expand Down
5 changes: 3 additions & 2 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ export default withMermaid({
],
},
],
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
'/api': apiRoutes,
// Fails in CI without this
// eslint-disable-next-line @typescript-eslint/no-explicit-any
'/api': apiRoutes as any[],
},

socialLinks: [
Expand Down
13 changes: 13 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ export default tseslint.config(
'@typescript-eslint/require-await': 'off',
'@stylistic/yield-star-spacing': ['error', { before: false, after: true }],
'@typescript-eslint/no-unsafe-enum-comparison': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
// From https://typescript-eslint.io/rules/no-unused-vars/
"args": "all",
"argsIgnorePattern": "^_",
"caughtErrors": "all",
"caughtErrorsIgnorePattern": "^_",
"destructuredArrayIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"ignoreRestSiblings": true,
},
],
},
},
{
Expand Down
Loading
Loading