Commit Graph
145 Commits
Author SHA1 Message Date
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 6d5bd58ae8 Add support for header removal content compression in Matroska 2025-09-17 23:09:04 +02:00
Vanilagy c5523516c7 Add fastStart: 'reserve' option (closes #119) 2025-09-17 12:26:24 +02:00
Vanilagy 530ccd7523 Drag 0-duration VideoFrame duration to null (fixes #116) 2025-09-16 15:50:14 +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 b9f7ab2fa2 Skip HEVC RASL slices following a decoder reset 2025-09-09 13:09:41 +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 bd99d8f28f Add metadata tests, fix a few bugs 2025-09-05 21:42:26 +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 ef95960e13 Add support for unsized sources, add ReadableStreamSource, fix WAVE packet lookup 2025-09-02 16:39:38 +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 641cdd02e3 Add new slice-based reader system, port all demuxers to new reader system, add optimized BlobSource 2025-08-28 17:24:31 +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 803e58a0d2 Add internalCodecId field 2025-08-23 16:24:36 +02:00
Vanilagy bb1b20afa7 Add track name support 2025-08-23 15:33:44 +02:00
Vanilagy 2d62395fc0 Fix faulty faulty lookup table logic (addresses #70) 2025-08-22 14:20:57 +02:00
Vanilagy bb9554df60 Handle ISOBMFF boxes with no size 2025-08-20 15:12:25 +02:00
Vanilagy f4b97c1731 Make mfra box lookup more resilient 2025-08-20 14:33:26 +02:00
Vanilagy 5782219941 Add Matroska resync logic for malformed files, add RVE sponsor 2025-08-20 13:38:54 +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 e0a4169bf8 Handle missing starting key sample in ISOBMFF 2025-08-12 09:29:57 +02:00
Vanilagy 1492fd5c6f Add workaround for Chromium range request caching bug 2025-08-11 18:14:02 +02:00
Vanilagy 47c955524f Rework MP3 reading pattern 2025-08-11 02:50:13 +02:00
Vanilagy 11c15c2392 Add track-specific conversion options, fix esbuild race condition 2025-08-11 00:00:04 +02:00
Vanilagy 56ae97f994 Fix decoded frame timestamps (#49) 2025-08-10 19:26:41 +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 597b68b299 Add support for Matroska lacing, fix packet lookup logic 2025-08-08 17:10:03 +02:00
Vanilagy d38ad22559 Big realtime playback refactor
- Added Worker- or AudioContext-based fallbacks in case MediaStreamTrackProcessor is not available
- Fixed fMP4-streamed files not playing in Safari
- Added better error handling for MediaStream sources
- Improved the live recording example to be more robust
2025-07-27 12:13:03 +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 cf0bbe896a Add longer variant to VideoSample.draw 2025-07-15 11:49:33 +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
Vanilagy 1b382d3e57 Improve unsupported encoder configuration error messages 2025-07-07 11:21:42 +02:00
Vanilagy f675966004 Metamuxer -> Mediabunny 2025-06-16 15:55:38 +02:00
Vanilagy 05881ff1f5 Add support for PCM codecs in MP4, add 64-bit float PCM support 2025-06-16 10:49:55 +02:00
Vanilagy fa3f4b0052 Document conversion API 2025-06-08 22:42:23 +02:00