Commit Graph
1243 Commits
Author SHA1 Message Date
77e70f9090 Add BufferTarget.onFinalize, OutputOptions.onFinalize, ConcurrentRunner (#349)
* Add BufferTarget.onFinalize option for awaitable async action on finalize

The `finalized` event fires synchronously and its return value is ignored,
making it unsuitable for use cases where the muxer should wait (e.g.
uploading the buffer to S3, R2, or other object stores that require a
known Content-Length and therefore can't stream via StreamTarget).

Adds a new `BufferTargetOptions` type with an `onFinalize` callback that
the muxer awaits before resolving. Matches the existing callback pattern
used by `HlsOutputFormatOptions.onSegment`, `onMaster`, etc.

When used with PathedTarget, this provides proper backpressure: the next
segment won't start being produced until the previous one has finished
uploading, keeping memory bounded regardless of video length.

- Adds `BufferTargetOptions` type, exported from the package root
- `BufferTarget` constructor now accepts optional options (backward compatible)
- `_finalize()` awaits `onFinalize` before emitting the `finalized` event
- Adds runtime validation for non-function callbacks
- Updates "Upload to a server" docs in writing-hls.md with S3 pattern
- Documents `onFinalize` in writing-media-files.md BufferTarget section
- Adds tests for callback invocation, async awaiting, backward compat, and validation

* Add ConcurrentRunner, add OutputOptions.onFinalize, adjust docs accordingly, clean up tests

* give me more control baby

* forgot to tell about it

* polish guide and js docs

* vanilagy says remove this, docs will reveal it

---------

Co-authored-by: Vanilagy <[email protected]>
2026-04-17 18:42:09 +02:00
Vanilagy 9a7120f5f4 Add per-playlist "mutices" for HLS muxer 2026-04-17 18:35:33 +02:00
Vanilagy 2ab6bbe3d1 Bruh 2026-04-17 15:16:08 +02:00
Vanilagy 670664c76a Add thoughts 2026-04-17 15:06:27 +02:00
Vanilagy c8c8cf214c Add first timestamp cache for performance 2026-04-17 15:06:18 +02:00
Vanilagy 7d9c063105 Small commit 2026-04-17 09:34:06 +02:00
Vanilagy 189d6851a6 Bump to beta 3 v1.42.0-beta.3 2026-04-16 18:29:45 +02:00
Vanilagy 95e9dc5210 MORE CODE REVIEW 2026-04-16 18:27:51 +02:00
Vanilagy b85ecd3109 Code review fixes 2026-04-16 17:43:12 +02:00
Vanilagy aadfa77489 Modify README 2026-04-16 16:23:59 +02:00
Vanilagy 6dc4c2d499 More doc adjustments, some type adjustments 2026-04-16 16:19:08 +02:00
Vanilagy 5465602344 Add "Writing HLS" documentation, refine other stuff 2026-04-16 14:53:48 +02:00
Vanilagy 56b25fbdf8 Add onSegmentPopped, add more tests, improve validation, improve M3U8 grammar 2026-04-16 14:48:57 +02:00
Vanilagy f99adf2208 Optimize media tag codec parsing, add a test for it, extract tag strings into constants 2026-04-16 11:31:43 +02:00
Vanilagy 2d0aac3208 Fix HLS demuxer parsing bug, extract HLS mime type out, add TargetRequest.mimeType 2026-04-16 10:53:36 +02:00
Vanilagy d68c9c4fb1 Add M3U8 syntax highlighting in docs 2026-04-15 17:28:06 +02:00
Vanilagy 6a54ad8a5b Add docs for reading HLS 2026-04-15 16:47:54 +02:00
Vanilagy 7080b79a2a Update docs a bunch, fix some typos 2026-04-15 14:36:53 +02:00
Vanilagy 606ee87822 Remove InputTrack[] option for ConversionOptions.tracks 2026-04-15 10:30:26 +02:00
Vanilagy 42d0c22f5a Bump beta version v1.42.0-beta.2 2026-04-15 09:17:25 +02:00
Vanilagy 8241820a4f Remove unnecessary sync getters 2026-04-15 09:16:40 +02:00
Vanilagy 62ac6d9dae Change error wording 2026-04-15 08:27:34 +02:00
Vanilagy d9f12c0c7a PLEASE BE FIXED 2026-04-14 21:49:15 +02:00
Vanilagy a3767af141 Fix HLS muxer audio segmentation bug, fix conversion tests failing in CI 2026-04-14 21:40:07 +02:00
Vanilagy 6410ea9f42 Make Conversion API copy input pairability graph by default, fix HLS muxer rotation bug, remove onfinalized callback 2026-04-14 21:14:58 +02:00
Vanilagy 53f05afbd8 Add ability to group output tracks in Conversion API 2026-04-14 20:41:05 +02:00
Vanilagy e8ba0544d1 Unexpected .only modifier 2026-04-14 16:29:19 +02:00
Vanilagy 2f576aa486 Add fan-out API to Conversion API, fix erroneous track count validation 2026-04-14 16:27:02 +02:00
Vanilagy cbbd9bd7fc Pin to a different npm version v1.42.0-beta.1 2026-04-14 11:57:58 +02:00
Vanilagy 18ca50d5c4 Remove npm update 2026-04-14 11:51:20 +02:00
Vanilagy 100a93bba1 Fix YAML syntax error 2026-04-14 11:45:05 +02:00
Vanilagy fa8f86e1fe Bump to beta version, adjust release script to accept beta versions 2026-04-14 11:40:28 +02:00
Vanilagy c6e505a6fe Make default keyFrameInterval 2 seconds to align with default HLS segment duration 2026-04-13 17:47:48 +02:00
Vanilagy 2a2b6450c9 Add better doc blocks, special deprecated logic for API doc generation, add multi-tiered SegmentedInput hydration for reducing file request count, ditch VirtualInputFormat indirection 2026-04-13 17:25:46 +02:00
Vanilagy 9969b92d51 Specify AAC codec in conversion code in AAC extension readme (closes #348) 2026-04-10 16:48:29 +02:00
Vanilagy 051578c2ca Remove input track descriptors, add async getters on tracks for everything, deprecate old sync getters 2026-04-10 16:23:17 +02:00
Vanilagy aa810fc433 Fix SourceRef race conditions, fix "source" and "target" getter returning unused instances, add missing validation, make "getDurationFromMetadata" only exist on tracks, fix examples, expand media player to support live playback, change the signatures of some Input APIs 2026-04-10 13:38:14 +02:00
Vanilagy 0813bcab28 Add missing doc blocks for everything, add PathedTarget and PathedSource, few other changes & fixes 2026-04-09 15:22:45 +02:00
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 fdb5f4102f Add new createInputFrom helper function 2026-04-08 14:52:27 +02:00
Vanilagy bee1518100 Add TrackDescriptor concept 2026-04-08 12:21:08 +02:00
Vanilagy b532714926 Merge branch 'main' into hls 2026-04-01 17:20:46 +02:00
Vanilagy 735a6622a2 Merge branch 'main' into release 2026-04-01 17:20:33 +02:00
Vanilagy e183e5022e Add new sponsors 2026-04-01 17:20:18 +02:00
Vanilagy 27ec0cfec1 Update todo 2026-04-01 17:17:22 +02:00
Vanilagy 3c0a6fc299 Fix failing tests, add missing license headers 2026-04-01 16:39:42 +02:00
Vanilagy 5bba924ce5 Add PacketRetrievalOptions to decoded media sinks, allowing configuration of skipLiveWait (fixes #342) 2026-04-01 16:20:56 +02:00
Vanilagy b86e527dc6 Add audio resampling, remixing and processing options to AudioEncodingConfig, small AudioResampler adjustments, add more tests 2026-04-01 15:46:02 +02:00
Vanilagy 1c08589021 Add "force" transform option, formalize that transformations bake in rotation 2026-04-01 14:34:05 +02:00
Vanilagy 024660773b Add video frame preprocessing to VideoEncodingConfig & VideoEncoderWrapper 2026-04-01 13:30:34 +02:00