Commit Graph
78 Commits
Author SHA1 Message Date
Vanilagy 7d053ae50d Add ConversionOptions.tracks, add better converstion start timestamp computation, optimize endPacket logic, utilize metadata duration for progress callback for better performance 2026-04-08 17:07:02 +02:00
Vanilagy 3e87d747e6 Add HLS master playlist generation, add multi-playlistadd output track grouping, add multi-playlist HLS files, add configurable playlist and segment names, add TrackDisposition.primary 2026-03-24 15:53:21 +01:00
Vanilagy 587e98391e Merge branch 'main' into hls 2026-03-19 16:52:00 +01:00
Vanilagy 0d50526ff6 Fix incorrectly-written video rotation metadata even when rotation is baked into the video (fixes #329) 2026-03-19 14:25:40 +01:00
Vanilagy e42fc85f19 Merge branch 'main' into hls 2026-03-13 17:07:31 +01:00
Vanilagy 35e16ca23e Fix incorrect GOP timestamp verification logic for first GOP (fixes #321) 2026-03-13 10:45:34 +01:00
Vanilagy e8df451bf5 Add support for live HLS streams, add playlist refresh logic, add live input tracks 2026-03-12 15:54:19 +01:00
6a11a1302c Fix CTS=0 in fragmented fMP4 with multiple tracks (#317)
* Fix CTS=0 in fragmented fMP4 with multiple tracks

When muxing fragmented MP4 with both video and audio tracks,
compositionTimeOffset (CTS) was zero for all video samples, causing
B-frame content to display in decode order instead of presentation
order (visible judder).

Root cause: During finalize(), interleaveSamples(true) triggers
finalizeFragment() via the cross-track keyframe check in
addSampleToTrack. This writes the trun box before processTimestamps
has computed correct decodeTimestamp values, so CTS = PTS - DTS = 0.

Fix: Call processTimestamps() for all tracks at the start of
finalizeFragment(). This is safe because processTimestamps is a no-op
when the timestampProcessingQueue is empty.

Video-only fragmented muxing was unaffected because the single-track
case never triggers the cross-track keyframe check during
interleaveSamples.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* Fix the problem at the actual root

* Oopsie doopsie

---------

Co-authored-by: Claude Opus 4.6 <[email protected]>
Co-authored-by: Vanilagy <[email protected]>
2026-03-06 09:56:53 +00:00
Vanilagy bb4749cd8d Add support for reading/writing non-square pixel video frames (fixes #309) 2026-02-25 17:16:33 +01:00
Vanilagy ddc826e6e3 MPEG-TS muxer: Write out DTS for video tracks (fixes buggy QuickTime behavior) 2026-02-16 15:30:23 +01:00
Vanilagy a97200f3f0 Add @mediabunny/ac3 extension package 2026-02-12 18:31:59 +01:00
Vanilagy 4fae45ec40 Allow negative trim ranges for conversion, add OutputFormat.supportsTimestampedMediaData 2026-02-11 15:56:51 +01:00
Vanilagy 24af125415 Make Conversion.cancel() cause execute() to throw (closes #271) 2026-01-12 15:13:00 +01:00
Vanilagy cc649ba192 Add allowRotationMetadata video conversion option (see #247) 2025-12-11 14:41:00 +01:00
Vanilagy e33e9f13fe Fix missing VideoSample.close() calls in CanvasSink conversion path 2025-11-12 10:05:41 +01:00
Vanilagy 23f814679e Modify audio encoder to fill gaps between timestamps with silence to ensure AV sync (fixes #176) 2025-11-11 18:03:28 +01:00
Vanilagy 3db4aa8b91 Fixed doubly stacked rotation correction when converting rotated video with a custom process function (fixes #218) 2025-11-11 11:05:15 +01:00
Vanilagy 5039c730bf Fix MediaStreamTracks not being stopped inside of the worker (fixes #204) 2025-11-02 13:00:38 +01:00
Vanilagy e880f54553 Add custom processing to Conversion API 2025-10-17 14:52:13 +02:00
Vanilagy a1008b8088 Fix invalid crop region for rotated video samples (fixes #151) 2025-09-26 16:31:24 +02:00
Vanilagy be151d3494 Add isValid field to Conversion if output track counts haven't been reached, improve error messages to be more clear (closes #148) 2025-09-26 13:11:35 +02:00
Vanilagy 1b8e4f9f4b Add alpha option to Conversion API 2025-09-26 11:12:48 +02:00
Vanilagy eb1ce86187 Fix faulty MP3 bitrate and frame size calculation (fixes #134) 2025-09-19 13:20:36 +02:00
420423bc0f feat: Add support for custom MP4 metadata with mdta format (#132)
* feat: Add support for custom MP4 metadata with mdta format

- Add metadataFormat option ('mdir' | 'mdta') to IsobmffOutputFormatOptions
- Implement complete mdta format with keys box generation
- Enable custom metadata fields readable by ffmpeg/ffprobe
- Maintain backward compatibility with default mdir format

* Refactor ISOBMFF metadata tag writing logic

* Autism

---------

Co-authored-by: tanfu <[email protected]>
Co-authored-by: Vanilagy <[email protected]>
2025-09-18 23:41:08 +02:00
d426d36386 FLAC container support (#95)
* add a test

* recognize as input format

* scaffold flac demuxer

* implement getting metadata

* Implement mime type

* read all metadata + deduplicate stubs

* Read first packet

* copyright headers

* read the first packet

* Get entire first packet, work on advancing

* iterate over all samples

* testable with bun

* stub out metadata support

* parse descriptive metadata

* All in 1 file

seems more appropriate to the philosophy

* some parameters are not needed anymore all within 1 class

* skip over bytes we are sure are not the syncword

* run prettier

* timestamp is determined based on passed blocks, not maximumBlockSize

* no binary search needed!

* simplifications

* Finish demuxer reading sequentially

* more tests + add a file with a seektable

* don't throw if (this.audioInfo.minimumBlockSize !== this.audioInfo.maximumBlockSize

* Add docs

* Update format compatibility table

* Simplification

* confirm conversion is working

* Finish

* Resolve TODO comment

* Support images (read-only)

* Returning description as Uint8Array

* Cleanup of demuxer

* Misc renames

* Object on same line

* Resolve first batch of comments

* Throw errors on corrupt blocks, correctly use requestSlice()

* Fix description field

* Explain why last frame is a bit shorter

* Add FLAC to README

* Put track backings below demuxer

* convert to methods

* Reorder container checking

* getBlockSize() -> readBlockSize()

* bitStream -> bitstream

* better naming for bytes

* use .skip()

* Don't return blockSize twice in readFlacFrameHeader

* Use enum + switch to distinguish Flac block types

* Use else-if

* Use else-if

* Compressed switch statement

* readCodedNumber

* Update flac-misc.ts

* We don't need the bits variable at all

* reorder functions in flac-demuxer

* Handle gracefully not being able to load another sample

* Update flac-demuxer.ts

* blockingbit null

* use async instead of promise.resolve

* use binary search

* Replace recursion with while loop

* Add mutex to getPacket()

* Load more data not in getPacketAtIndex, but outside

* Apply suggestion from @Vanilagy

Co-authored-by: David P. <[email protected]>

* computeDuration() reads last packet

* Update flac-demuxer.ts

* share vorbis comment reading logic

* reuse vorbis comment writing logic, set vendor always to "Mediabunny"

* flush after writign

* Use FileSlice.tempFromBytes

* assert !== null

* fixing nitpicks

* apply suggestions

* fix ogg

* We are now muxing images

* apply suggestion

* Update src/flac/flac-muxer.ts

Co-authored-by: David P. <[email protected]>

* apply suggestion

* readSampleRate()

* seek outside writeHeader()

* mention vorbis metadata +  add to metadatatags comment

* should be able to -> can

* Add test in metadata tags

* Add test for packets being byte identical after remuxing

* compare to null

* no casting to uint8array

* make test pass

* Update flac-muxer.ts

* Call validateAudioChunkMetadata() and validateAndNormalizeTimestamp()

* `onFrame` option

* emit frames using onFrame

* Run prettier over files

* Fix FLAC PICTURE block logic, small other changes

* Update docs

* Remove .only modifier

* fix remuxing and add test

* Don't throw error if parsing fails in header, since hitting a syncword might just be coincidential

* Fix remaining type errors

---------

Co-authored-by: David P. <[email protected]>
2025-09-18 21:05:09 +02:00
Vanilagy 407dd05953 Make Matroska block decoding lazy 2025-09-18 10:00:03 +02:00
Vanilagy fcec67645a Allow object for tags field in conversion 2025-09-16 15:10:16 +02:00
Vanilagy eba1f360d5 Clean up cropping logic 2025-09-12 16:48:35 +02:00
Vanilagy 6f06631355 Use decoder information for resampler sample rate, fix Opus sample rate to 48 kHz everywhere 2025-09-10 23:03:20 +02:00
Vanilagy f3613b7260 Fix null sample in encoder support checking logic in Conversion API (#90) 2025-09-06 12:00:46 +02:00
Vanilagy b58476b1b0 Renaming 2025-09-05 18:59:13 +02:00
Vanilagy dd7804e5ab Add metadata read/write support for WAVE 2025-09-05 16:31:26 +02:00
Vanilagy d3a030c307 Add metadata read/write support for Ogg 2025-09-05 15:39:29 +02:00
Vanilagy 6d32de0fb1 Add metadata read/write support for Matroska 2025-09-05 13:41:09 +02:00
Vanilagy efa933863d Add metadata read/write support to ISOBMFF, add more metadata fields, add raw metadata support 2025-09-04 21:28:23 +02:00
Vanilagy 034a7254d2 Merge branch 'main' into metadata 2025-09-03 21:12:16 +02:00
Vanilagy 55dd8cdb4c Add NullTarget 2025-09-02 17:20:09 +02:00
Vanilagy 4b3fb34a95 Fix running = false being set too late for ReadOrchestrator workers (fixes #84) 2025-09-02 16:21:39 +02:00
Vanilagy c82ebb93da Add lyrics field to metadata 2025-08-26 17:36:49 +02:00
Vanilagy fb0c41aa09 Implement MP3 metadata (ID3v1/2) read & write 2025-08-25 17:43:40 +02:00
Vanilagy 63b8190185 Add logic for encoding video frames that change size over time (#63) 2025-08-24 16:37:03 +02:00
Vanilagy f4b97c1731 Make mfra box lookup more resilient 2025-08-20 14:33:26 +02:00
Ally 1ce5e108a7 Implement ADTS muxer :3 2025-08-17 16:14:15 +02:00
Vanilagy 7e546c2cc7 Fix sample closing before it reaches the custom encoder 2025-08-12 15:36:17 +02:00
Vanilagy 11c15c2392 Add track-specific conversion options, fix esbuild race condition 2025-08-11 00:00:04 +02:00
Vanilagy cbb2681d33 Create @mediabunny/mp3-encoder, restructure and extend build system 2025-08-10 00:45:30 +02:00
Vanilagy 1fe115ac83 Implement frame rate adjustment logic for Conversion API, fix source not being closed 2025-08-08 18:39:08 +02:00
Vanilagy 5e933d9362 Add packet type derivation logic, new verifyKeyPackets options, new determinePacketType method 2025-07-24 16:09:01 +02:00
Vanilagy 4b12468008 Add support for reading and writing RF64 WAVE files 2025-07-18 16:48:23 +02:00
Vanilagy 84c9d37cb7 Revise build step and dist structure for better Webpack, CJS and pnpm support 2025-07-09 11:53:19 +02:00