[WIP] Port MPEG-TS + Packed Audio AAC transmuxer from TypeScript to Rust (and thus from JS to WebAssembly) - #5
Open
peaBerberian wants to merge 2 commits into
Open
[WIP] Port MPEG-TS + Packed Audio AAC transmuxer from TypeScript to Rust (and thus from JS to WebAssembly)#5peaBerberian wants to merge 2 commits into
peaBerberian wants to merge 2 commits into
Conversation
peaBerberian
force-pushed
the
transmux-rs2
branch
4 times, most recently
from
April 23, 2023 19:23
80c14e2 to
6ee61f4
Compare
|
Kudos, SonarCloud Quality Gate passed!
|
peaBerberian
force-pushed
the
transmux-rs2
branch
2 times, most recently
from
May 3, 2026 12:49
4be9b7c to
d9a60bd
Compare
peaBerberian
force-pushed
the
transmux-rs2
branch
2 times, most recently
from
May 4, 2026 17:21
ae44904 to
39a9d8a
Compare
peaBerberian
force-pushed
the
transmux-rs2
branch
2 times, most recently
from
May 8, 2026 15:16
5c03377 to
6d9cd85
Compare
peaBerberian
force-pushed
the
main
branch
8 times, most recently
from
May 8, 2026 23:13
e62afa3 to
5946b81
Compare
peaBerberian
force-pushed
the
transmux-rs2
branch
from
May 10, 2026 21:05
6d9cd85 to
367033d
Compare
peaBerberian
force-pushed
the
main
branch
3 times, most recently
from
May 11, 2026 00:07
e7c304b to
ca45a51
Compare
peaBerberian
force-pushed
the
transmux-rs2
branch
2 times, most recently
from
May 14, 2026 20:14
725c384 to
5f67632
Compare
peaBerberian
force-pushed
the
transmux-rs2
branch
2 times, most recently
from
May 27, 2026 17:40
2269fe6 to
158bdf7
Compare
peaBerberian
force-pushed
the
main
branch
2 times, most recently
from
May 28, 2026 15:41
2e20d00 to
f9328e2
Compare
peaBerberian
force-pushed
the
transmux-rs2
branch
from
May 29, 2026 13:14
158bdf7 to
51cf062
Compare
peaBerberian
force-pushed
the
main
branch
3 times, most recently
from
May 29, 2026 15:08
9893405 to
6334ef2
Compare
peaBerberian
force-pushed
the
transmux-rs2
branch
from
May 29, 2026 17:14
51cf062 to
4891b7e
Compare
peaBerberian
force-pushed
the
main
branch
2 times, most recently
from
May 29, 2026 22:17
2bd3995 to
3176e63
Compare
peaBerberian
force-pushed
the
transmux-rs2
branch
from
May 30, 2026 22:27
4891b7e to
ce6f4af
Compare
peaBerberian
force-pushed
the
transmux-rs2
branch
from
May 30, 2026 22:29
ce6f4af to
0ed5a42
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.








NOTE: This PR is a work-in-progress still at the very beginning. Most of the code has been almost directly converted manually from TypeScript to Rust so some code may not look idiomatic yet (nor performant at all for that matter).
Transmuxing and the need for it
The HLS specification defines several allowed formats for media and initialization segments.
Among them, the
WaspHlsPlayersupports the three most frequent ones: fmp4, mpeg2-ts and packed audio AAC.The first one (fmp4) is very well supported amongst browser so may be pushed directly to the browser's
SourceBufferfor later decoding. However, support is very poor for the other two, leading us to need to transform that data before communicating it to the browser.That's where the "transmuxer" comes into play. In the
WaspHlsPlayerit takes either an mpeg2-ts or AAC formatted segment, and basically repackage it into an fmp4 segment for the browser.This is called transmuxing, an operation generally more performance-sensitive than others in an HLS web player and which also may handle huge chunks of memory - both areas where WebAssembly might be a better tool than JavaScript.
Previous state
For now,
WaspHlsPlayer's transmuxer is written in TypeScript.This is because it's a fork of mux.js's own transmuxer for reasons explained in the corresponding Pull Request.
On some segments (for example the content with 10 seconds segments found in the demo page), this transmuxer may take several hundreds of milliseconds to parse a single segment on the laptop I tested it on (Its performance is indistinguishable from the original transmuxer's one on that part).
This doesn't block the UI as transmuxing is performed in a WebWorker and thus concurrently, yet it may still be annoying, for example when playing low-latency contents (though when playing low-latency contents we do parse much shorter chunks of data) or when doing an operation - like a seek - where the faster the response, the better (here we might both block the seek operation due to a segment already being parsed, and postpone the next segment pushing)
Moreover, transmuxing is an operation handling huge chunks of data where I would prefer to have a better control on memory management.
This PR
Consequently, this PR tries to port our TypeScript transmuxer (from the
src/ts-transmuxdirectory) to Rust (in thesrc/rs-core/transmuxdirectory).This is a very long ongoing effort, and there's no guarantee that it will actually perform better than the previous one, but still seems like a logical next-step in theory.
As this project is mainly for fun anyway, I decided to go on with it.