### Build a Muxer with TransAVormer Source: https://github.com/yahweasel/transavormer/blob/master/docs/API.md Demonstrates initializing a muxer transformation using a libav.js instance and an input file. ```javascript const libav = await LibAV.LibAV(); const out = await TransAVormer.build(libav, { type: "muxer", input: inputFile }); const rdr = out.stream.getReader(); while (true) { const rd = await rdr.read(); if (rd.done) break; // Do something with rd.value } libav.terminate(); ``` -------------------------------- ### Initialize Transcoding and Playback Source: https://github.com/yahweasel/transavormer/blob/master/demo/player.html Sets up the AudioContext, initializes the TransAVormer instance, and configures the seek bar for media playback. ```javascript (function() { const tav = TransAVormer; const fileBox = document.getElementById("file"); const canvas = document.getElementById("playerCanvas"); const seekBar = document.getElementById("seekBar"); fileBox.onchange = async function() { const file = fileBox.files[0]; if (!file) return; const ac = new AudioContext(); if (ac.state !== "running") ac.resume(); ac.destination.channelCount = ac.destination.maxChannelCount; const playback = await Weasound.createAudioPlayback(ac); (playback.unsharedNode() || playback.sharedNode()).connect(ac.destination); const ctx = canvas.getContext("2d"); const la = await LibAV.LibAV(); const out = await tav.build(la, { type: "play-normalizer", sampleRate: ac.sampleRate, channels: ac.destination.channelCount, input: { type: "demuxer", chunkSize: 1, input: file } }); // Set up the seek bar let seekTo = null; let seeking = false; let duration = 2; for (const stream of await out.streams) { if (stream.duration > duration) duration = stream.duration; } seekBar.max = Math.round(duration * 1000); seekBar.value = 0; seekBar.oninput = async () => { seekTo = seekBar.value / 1000; if (!seeking) { seeking = true; while (seekTo !== null) { const to = seekTo; seekTo = null; await out.sendCommands([{ c: "seek", time: to }]); await new Promise(res => setTimeout(res, 100)); } seeking = false; } }; const streams = out.stream.tee(); let videoOffset = null; let audioOffset = null; // Video playback (async function() { const rdr = streams[0].getReader(); while (true) { const rd = await rdr.read(); if (rd.done) break; for (const sf of rd.value) { const frame = sf.frame; if (frame.codedWidth || frame.width) { let image, frameTime; if (frame.codedWidth) { // WebCodecs image = frame; frameTime = frame.timestamp / 1000; } else { // libav.js image = frame.data; frameTime = frame.pts * frame.time_base_num / frame.time_base_den * 1000; } const now = performance.now(); let targetTime = now; if (audioOffset !== null) { targetTime = frameTime + audioOffset; } else if (videoOffset !== null) { targetTime = frameTime + videoOffset; } else { videoOffset = now - frameTime; } const delay = targetTime - now; if (delay > 100 || delay < -100) { videoOffset = now - frameTime; } if (delay > 0) { await new Promise(res => setTimeout( res, Math.min(delay, 100) )); } canvas.width = frame.codedWidth || frame.width; canvas.height = frame.codedHeight || frame.height; ctx.drawImage(image, 0, 0); image.close(); seekBar.value = Math.round(frameTime); } } } })(); // Audio playback (async function() { const rdr = streams[1].getReader(); while (true) { const rd = await rdr.read(); if (rd.done) break; for (const sf of rd.value) { const frame = sf.frame; const now = performance.now(); if (frame.sample_rate) { const frameTime = frame.pts * frame.time_base_num / frame.time_base_den * 1000; const delay = playback.play(frame.data); audioOffset = performance.now() + delay - frameTime; seekBar.value = Math.round(frameTime - delay); if (delay > 200) await new Promise(res => setTimeout(res, delay - 100)); } } } })(); } })(); ``` -------------------------------- ### Initialize a muxer Source: https://github.com/yahweasel/transavormer/blob/master/docs/API.md Create a muxer to output file streams. Set randomAccess to true for formats like mp4 that require it. ```javascript const out = await TransAVormer.build(libav, { type: "muxer", format: "matroska", // libavformat format name randomAccess: false, // Optional, may be true input: inputData }); ``` -------------------------------- ### TransAVormer.build (play-normalizer) Source: https://github.com/yahweasel/transavormer/blob/master/docs/API.md Initializes a playback normalizer to convert media frames into playback-optimized formats. ```APIDOC ## TransAVormer.build({ type: "play-normalizer" }) ### Description Creates a playback normalizer instance to convert video and audio frames into consistent formats suitable for playback. ### Parameters - **type** (string) - Required - Must be "play-normalizer". - **sampleRate** (number) - Required - The target sample rate for audio resampling. - **channels** (number) - Optional - The target number of channels for audio mixing or splitting. - **input** (object) - Required - The input data stream to be normalized. ### Request Example ```javascript const out = await TransAVormer.build(libav, { type: "play-normalizer", sampleRate: ac.sampleRate, channels: ac.destination.channelCount, input: inputData }); ``` ### Output Formats - **WebCodecs VideoFrames**: Returned if supported; identified by a `codedWidth` field. - **libav.js video frames**: Returned if WebCodecs is not supported; contains `ImageBitmap` data and identified by a `width` field. - **libav.js audio frames**: Planar floating-point data; identified by a `sampleRate` field. ``` -------------------------------- ### Initialize an Encoder Source: https://github.com/yahweasel/transavormer/blob/master/docs/API.md Creates an encoder instance using the 'encoder' initializer. Video and audio configurations can be provided via WebCodecs or lower-level libav settings. ```javascript const out = await TransAVormer.build(libav, { type: "encoder", videoConfig: { /* This is a WebCodecs video configuration, but the `width` and `height` * fields are optional, as they will be found from the input. If you * don't intend to handle video input, `videoConfig` can be elided. */ codec: "vp8" }, audioConfig: { /* This is a WebCodecs audio configuration. If you don't intend to * handle audio input, `audioConfig` can be elided. */ codec: "opus" }, input: inputData }); ``` -------------------------------- ### Initialize Playback Normalizer Source: https://github.com/yahweasel/transavormer/blob/master/docs/API.md Create a playback normalizer using the 'play-normalizer' type. Requires a sampleRate for audio resampling and optionally accepts channel counts. ```javascript const out = await TransAVormer.build(libav, { type: "play-normalizer", sampleRate: ac.sampleRate, channels: ac.destination.channelCount, input: inputData }); ``` -------------------------------- ### Execute TransAVormer Test Harness Source: https://github.com/yahweasel/transavormer/blob/master/tests/web-test.html Initializes the test harness, configures output redirection to the DOM, and executes the test suite with specific options. ```javascript (function() { const runTests = document.getElementById("runTests"); runTests.onclick = async function() { runTests.style.display = "none"; const harness = TransAVormerTestHarness; harness.print = text => { document.getElementById("stdout").innerText += text + "\n"; }; harness.printErr = text => { document.getElementById("stderr").innerText += text + "\n"; }; harness.printStatus = text => { document.getElementById("status").innerText = text; }; let suite; { const resp = await fetch("suite.json"); suite = await resp.json(); } await harness.loadTests(suite); harness.options.includeSlow = document.getElementById("includeSlow").checked; await harness.runTests([ null, {yesthreads: true}, {nowasm: true} ]); runTests.style.display = ""; }; })(); ``` -------------------------------- ### TransAVormer.build (Demuxer) Source: https://github.com/yahweasel/transavormer/blob/master/docs/API.md Initializes a demuxer to process an input file into a packet stream. ```APIDOC ## TransAVormer.build (Demuxer) ### Description Creates a demuxer instance to read packets from an input file. The demuxer outputs a stream of packet arrays. ### Parameters - **type** (string) - Required - Must be "demuxer". - **input** (File) - Required - The input file to be demuxed. - **chunkSize** (number) - Optional - Size in bytes of chunks sent through the stream. Defaults to 65536. - **libav** (Object) - Optional - A specific libav.js instance to use for the operation. ### Request Example const out = await TransAVormer.build(libav, { type: "demuxer", chunkSize: 65536, input: inputFile, libav: libav }); ``` -------------------------------- ### Transcoding to VP8 and Opus Source: https://github.com/yahweasel/transavormer/blob/master/README.md Shows how to nest an encoder configuration within the build function to transcode input media into specific video and audio codecs. ```javascript const muxer = await TransAVormer.build(libav, { type: "muxer", randomAccess: true, input: { type: "encoder", videoConfig: { codec: "vp8" }, audioConfig: { codec: "opus" }, input: inputFile } }); ``` -------------------------------- ### TransAVormer.build (Encoder) Source: https://github.com/yahweasel/transavormer/blob/master/docs/API.md Initializes an encoder instance to process video and audio streams. ```APIDOC ## TransAVormer.build (Encoder) ### Description Creates an encoder instance using the provided libav context and configuration. It supports WebCodecs configurations or lower-level libav.js configurations. ### Method Async Function ### Parameters - **libav** (Object) - Required - The libav context. - **options** (Object) - Required - Configuration object. - **type** (String) - Required - Must be "encoder". - **videoConfig** (Object) - Optional - WebCodecs video configuration. - **audioConfig** (Object) - Optional - WebCodecs audio configuration. - **libavVideoConfig** (Object) - Optional - Low-level libav video configuration. - **libavAudioConfig** (Object) - Optional - Low-level libav audio configuration. - **input** (Any) - Required - The input data source. ``` -------------------------------- ### Transmuxing file input with TransAVormer Source: https://github.com/yahweasel/transavormer/blob/master/demo/transmux.html Handles file selection, initializes LibAV, performs transmuxing to Matroska format, and creates a downloadable link for the resulting blob. ```javascript (function() { const tav = TransAVormer; const fileBox = document.getElementById("file"); fileBox.onchange = async function() { const file = fileBox.files[0]; if (!file) return; const la = await LibAV.LibAV(); const out = await tav.build(la, { type: "muxer", format: "matroska", input: file }); const outParts = []; const rdr = out.stream.getReader(); while (true) { const rd = await rdr.read(); if (rd.done) break; outParts.push(rd.value.data); } la.terminate(); const outBlob = new File(outParts, "out.mkv", {type: "video/x-matroska"}); const outURL = URL.createObjectURL(outBlob); const a = document.createElement("a"); a.style.display = "block"; a.href = outURL; a.innerText = "Output"; document.body.appendChild(a); } })(); ``` -------------------------------- ### TransAVormer.build (Filter) Source: https://github.com/yahweasel/transavormer/blob/master/docs/API.md Initializes a libavfilter component to apply filterchains to audio or video streams. ```APIDOC ## TransAVormer.build (type: "la-filter") ### Description Creates a libav filter instance. Supports filterchains for video and audio streams. ### Parameters - **type** (string) - Required - Must be "la-filter". - **input** (object) - Required - The input data. - **videoFilters** (string) - Optional - Filterchain string for video. - **videoIOSettings** (object) - Optional - FilterIOSettings for video output. - **audioFilters** (string) - Optional - Filterchain string for audio. - **audioIOSettings** (object) - Optional - FilterIOSettings for audio output. ### Request Example const out = await TransAVormer.build(libav, { type: "la-filter", videoFilters: "crop=320:240", videoIOSettings: {}, audioFilters: "volume=0.5", audioIOSettings: {}, input: inputData }); ``` -------------------------------- ### TransAVormer.build(libav, initializer) Source: https://github.com/yahweasel/transavormer/blob/master/docs/API.md The build function initializes a transformation pipeline. It requires a libav.js instance and an initializer object defining the transformation type and input source. ```APIDOC ## TransAVormer.build(libav, initializer) ### Description Initializes a media transformation pipeline. TransAVormer automatically discovers necessary intermediate stages (like demuxing or decoding) based on the provided input and desired output type. ### Parameters - **libav** (LibAV instance) - Required - An instance of libav.js. - **initializer** (Object) - Required - A descriptor object containing: - **type** (string) - The type of transformation (e.g., "muxer"). - **input** (Object|string) - The input source or another initializer stage. ### Request Example ```javascript const libav = await LibAV.LibAV(); const out = await TransAVormer.build(libav, { type: "muxer", input: inputFile }); ``` ### Response - **out** (Object) - Returns an object containing a `stream` property, which is a `ReadableStream` of the transformed data. ``` -------------------------------- ### Modular Transcoding Pipeline Implementation Source: https://github.com/yahweasel/transavormer/blob/master/demo/modular-transcode.html Handles file input, format detection, and the construction of a transcoding pipeline using LibAV and TransAVormer. ```javascript (function() { const tav = TransAVormer; const fileBox = document.getElementById("file"); fileBox.onchange = async function() { const file = fileBox.files[0]; if (!file) return; const header = await file.slice(0, 12).arrayBuffer(); const type = await AVGuesser.guess(header); const demuxer = await LibAV.LibAV({ variant: `demuxer-${type.format}` }); const la = await LibAV.LibAV(); const out = await tav.build(la, { type: "muxer", format: "matroska", input: { type: "encoder", videoConfig: { codec: "vp8" }, audioConfig: { codec: "opus" }, input: { type: "decoder", libav: demuxer, LibAV: LibAV, input: { type: "demuxer", libav: demuxer, input: file } } } }); const outParts = []; const rdr = out.stream.getReader(); while (true) { const rd = await rdr.read(); if (rd.done) break; outParts.push(rd.value.data); } la.terminate(); const outBlob = new File(outParts, "out.mkv", {type: "video/x-matroska"}); const outURL = URL.createObjectURL(outBlob); const a = document.createElement("a"); a.style.display = "block"; a.href = outURL; a.innerText = "Output"; document.body.appendChild(a); } })(); ``` -------------------------------- ### TransAVormer.build (muxer) Source: https://github.com/yahweasel/transavormer/blob/master/docs/API.md Creates a muxer for output file streams, supporting various libavformat formats. ```APIDOC ## TransAVormer.build (muxer) ### Description Initializes a muxer to create an output file stream. Supports random access for formats like mp4. ### Parameters - **type** (string) - Required - Must be "muxer" - **format** (string) - Required - The libavformat format name - **randomAccess** (boolean) - Optional - Set to true for formats requiring random access (e.g., mp4) - **input** (any) - Required - The input data source ``` -------------------------------- ### Initialize a LibAV Filter Source: https://github.com/yahweasel/transavormer/blob/master/docs/API.md Creates a filter instance using the 'la-filter' type. Supports defining filterchains for video and audio streams. ```javascript const out = await TransAVormer.build(libav, { type: "la-filter", videoFilters: "crop=320:240", videoIOSettings: { // Optional output parameters for video streams }, audioFilters: "volume=0.5" audioIOSettings: { // Optional output parameters for audio streams }, input: inputData }); ``` -------------------------------- ### Initialize a packet stream Source: https://github.com/yahweasel/transavormer/blob/master/docs/API.md Create a packet stream by providing codec parameters and a ReadableStream of packets. ```javascript const out = await TransAVormer.build(libav, { type: "packet-stream", streams: streams /* array of StreamParameters */, input: packetStream /* ReadableStream of Packet[] */ }); ``` -------------------------------- ### Initialize a Decoder Source: https://github.com/yahweasel/transavormer/blob/master/docs/API.md Creates a decoder instance using the 'decoder' type. The libav and LibAV fields are optional and support modular builds. ```javascript const out = await TransAVormer.build(libav, { type: "decoder", input: inputData, libav: libav, LibAV: LibAV }); ``` -------------------------------- ### TransAVormer.build (packet-stream) Source: https://github.com/yahweasel/transavormer/blob/master/docs/API.md Initializes a packet stream by providing codec parameters and a ReadableStream of packets. ```APIDOC ## TransAVormer.build (packet-stream) ### Description Creates a new packet stream instance using the provided libav.js codec parameters and a stream of packets. ### Parameters - **libav** (object) - Required - The libav.js instance. - **options** (object) - Required - Configuration object. - **type** (string) - Required - Must be "packet-stream". - **streams** (array) - Required - Array of StreamParameters. - **input** (ReadableStream) - Required - ReadableStream of Packet[] or number[] (pointers). ``` -------------------------------- ### TransAVormer.build (Decoder) Source: https://github.com/yahweasel/transavormer/blob/master/docs/API.md Initializes a decoder component to process packet streams or input files. ```APIDOC ## TransAVormer.build (type: "decoder") ### Description Creates a decoder instance to process input data. It accepts packet streams or input files as input. ### Parameters - **type** (string) - Required - Must be "decoder". - **input** (object) - Required - The input data (packet streams or input files). - **libav** (object) - Optional - A specific libav.js instance. - **LibAV** (object) - Optional - Entry point for loading modular decoder variants. ### Request Example const out = await TransAVormer.build(libav, { type: "decoder", input: inputData, libav: libav, LibAV: LibAV }); ``` -------------------------------- ### Transmuxing an MP4 file to Matroska Source: https://github.com/yahweasel/transavormer/blob/master/README.md Demonstrates using the build function to create a muxer for converting an input file to a different container format. ```javascript const libav = await LibAV.LibAV(); const muxer = await TransAVormer.build(libav, { type: "muxer", randomAccess: true, input: inputFile }); const rdr = muxer.stream.getReader(); const out = new FileWriter("out.mkv"); // Hypothetical output class while (true) { const rd = await rdr.read(); if (rd.done) { out.close(); break; } out.write(rd.value.data, rd.value.position); } libav.terminate(); ``` -------------------------------- ### TransAVormer.build (Packet Selector) Source: https://github.com/yahweasel/transavormer/blob/master/docs/API.md Initializes a packet selector to filter specific streams from the input. ```APIDOC ## TransAVormer.build (Packet Selector) ### Description Creates a packet selector to filter and keep specific streams from a demuxer input. ### Method Async Function ### Parameters - **libav** (Object) - Required - The libav context. - **options** (Object) - Required - Configuration object. - **type** (String) - Required - Must be "packet-selector". - **selection** (Number|String|Object) - Required - Defines which streams to keep (e.g., "v0", "a", or index). - **input** (Object) - Required - The input source, typically a demuxer. ``` -------------------------------- ### Transcoding media files with TransAVormer Source: https://github.com/yahweasel/transavormer/blob/master/demo/filter.html Initializes a file input handler that processes a selected file through a LibAV-based filter pipeline and generates a Matroska output file. ```javascript (function() { const tav = TransAVormer; const fileBox = document.getElementById("file"); fileBox.onchange = async function() { const file = fileBox.files[0]; if (!file) return; const la = await LibAV.LibAV(); const out = await tav.build(la, { type: "muxer", format: "matroska", input: { type: "encoder", videoConfig: { codec: "vp8" }, audioConfig: { codec: "opus" }, input: { type: "la-filter", videoFilters: "crop=320:240:0:0", audioFilters: "volume=0.25", input: file } } }); const outParts = []; const rdr = out.stream.getReader(); while (true) { const rd = await rdr.read(); if (rd.done) break; outParts.push(rd.value.data); } la.terminate(); const outBlob = new File(outParts, "out.mkv", {type: "video/x-matroska"}); const outURL = URL.createObjectURL(outBlob); const a = document.createElement("a"); a.style.display = "block"; a.href = outURL; a.innerText = "Output"; document.body.appendChild(a); } })(); ``` -------------------------------- ### sendCommands(commands: Command[]) Source: https://github.com/yahweasel/transavormer/blob/master/docs/STREAM-COMMANDS.md Sends an array of commands to the output stream, which are forwarded backwards through the pipeline. Returns an array of command results. ```APIDOC ## sendCommands(commands: Command[]) ### Description Sends an array of commands to the output stream to alter pipeline behavior. Commands are forwarded backwards through the entire pipeline. ### Parameters - **commands** (Array) - Required - An array of command objects, each containing at least a 'c' field identifying the command type. ### Response - **results** (Array) - An array of objects containing: - **c** (string) - The command name. - **ran** (boolean) - True if the command was interpreted by any element in the pipeline. - **success** (boolean) - True if the command executed successfully or was not interpreted. - **diagnostic** (any[]) - Optional diagnostic information if execution failed. ``` -------------------------------- ### Initialize a Packet Selector Source: https://github.com/yahweasel/transavormer/blob/master/docs/API.md Creates a packet selector using the 'packet-selector' initializer to filter specific streams from an input source. ```javascript const out = await TransAVormer.build(libav, { type: "packet-selector", selection: "v0", input: { type: "demuxer", ... } }); ``` -------------------------------- ### Initialize a Demuxer Source: https://github.com/yahweasel/transavormer/blob/master/docs/API.md Creates a demuxer instance to process input files. The chunkSize parameter controls the byte size of packet chunks sent through the stream. ```javascript const out = await TransAVormer.build(libav, { type: "demuxer", chunkSize: 65536, input: inputFile, libav: libav }); ``` -------------------------------- ### Initialize a custom frame stream Source: https://github.com/yahweasel/transavormer/blob/master/docs/API.md Use the frame-stream type to provide custom codec parameters and frames in libav.js or WebCodecs format. ```javascript const out = await TransAVormer.build(libav, { type: "frame-stream", streams: streams /* array of StreamParameters */, input: packetStream /* ReadableStream of StreamFrame[] */ }); ``` -------------------------------- ### TransAVormer.build (frame-stream) Source: https://github.com/yahweasel/transavormer/blob/master/docs/API.md Creates a custom frame stream using provided codec parameters and frames. ```APIDOC ## TransAVormer.build (frame-stream) ### Description Allows creation of custom packet frames using libav.js or WebCodecs formats. ### Parameters - **type** (string) - Required - Must be "frame-stream" - **streams** (array) - Required - Array of StreamParameters - **input** (ReadableStream) - Required - ReadableStream of StreamFrame[] ``` -------------------------------- ### TransAVormer.build (frame-selector) Source: https://github.com/yahweasel/transavormer/blob/master/docs/API.md Creates a stream selector for frames to avoid extra processing steps. ```APIDOC ## TransAVormer.build (frame-selector) ### Description Creates a stream selector for frames. The selection field follows the same logic as the packet selector. ### Parameters - **type** (string) - Required - Must be "frame-selector" - **selection** (string) - Required - The selection identifier (e.g., "v0") - **input** (object) - Required - The input configuration, typically a decoder ``` -------------------------------- ### Streaming Input File Interface Source: https://github.com/yahweasel/transavormer/blob/master/docs/API.md Interface for providing input data that is read sequentially from beginning to end without seeking. ```APIDOC ## Streaming Input Interface ### Description Provides a mechanism for sequential data input. Can be implemented as a ReadableStream or an object with a read method. ### Interface ```typescript { read: (len: number) => Promise } ``` ### Parameters - **len** (number) - The requested length of data to read. ### Return Value - **Promise** - Returns a Uint8Array containing the data, or null to indicate EOF. ``` -------------------------------- ### Command and Result Structures Source: https://github.com/yahweasel/transavormer/blob/master/docs/STREAM-COMMANDS.md Defines the base structure for sending commands and the expected format of the returned results. ```typescript { c: string } ``` ```typescript { c: string, ran: boolean, success: boolean, diagnostic: any[] } ``` -------------------------------- ### Initialize a frame stream selector Source: https://github.com/yahweasel/transavormer/blob/master/docs/API.md Use the frame-selector type to select frames directly. The selection field follows the same syntax as packet selectors. ```javascript const out = await TransAVormer.build(libav, { type: "frame-selector", selection: "v0", input: { type: "decoder", ... } }); ``` -------------------------------- ### Random-Access Input File Interface Source: https://github.com/yahweasel/transavormer/blob/master/docs/API.md Interface for providing input data that requires seeking to specific positions within the file. ```APIDOC ## Random-Access Input Interface ### Description Provides a mechanism for random-access data input, required for formats that do not support streaming. Can be provided as a Blob/File or an object with size and read fields. ### Interface ```typescript { size: number, read: (pos: number, len: number) => Promise } ``` ### Parameters - **size** (number) - The total size of the file in bytes. - **pos** (number) - The position in the file to start reading from. - **len** (number) - The requested length of data to read. ### Return Value - **Promise** - Returns a Uint8Array containing the data, or null to indicate EOF. ``` -------------------------------- ### Seek Command Source: https://github.com/yahweasel/transavormer/blob/master/docs/STREAM-COMMANDS.md Performs a seek operation in the input file. ```APIDOC ## Seek Command ### Description Seeks to a specific time in the input file. Seeking is generally inexact and depends on keyframe availability. ### Command Structure - **c** (string) - Required - Must be "seek". - **time** (number) - Required - The time to seek to (seconds by default). - **min** (number) - Optional - Floor time for the seek. - **max** (number) - Optional - Ceiling time for the seek (defaults to time). - **stream** (number) - Optional - Index of the stream to base timing decisions on. - **streamTimebase** (boolean) - Optional - If true, interprets times in units of the selected stream's timebase (or microseconds if no stream is selected). ``` -------------------------------- ### Random-access input file interface Source: https://github.com/yahweasel/transavormer/blob/master/docs/API.md Required structure for random-access input, including file size and a read function supporting positional access. ```typescript { size: number, read: (pos: number, len: number) => Promise } ``` -------------------------------- ### Reselect Command Source: https://github.com/yahweasel/transavormer/blob/master/docs/STREAM-COMMANDS.md Changes the selection mapping for a packet or frame selector. ```APIDOC ## Reselect Command ### Description Updates the selection mapping for a packet or frame selector. Use with caution as changing mappings that affect codecs or stream counts may cause pipeline failure. ### Command Structure - **c** (string) - Required - Must be "reselect". - **selection** (Object) - Required - The new selection mapping (same form as selector initializers). ``` -------------------------------- ### Reselect Command Structure Source: https://github.com/yahweasel/transavormer/blob/master/docs/STREAM-COMMANDS.md Updates the selection mapping for packet or frame selectors. Ensure the new mapping does not cause pipeline failures due to codec or stream count changes. ```typescript { c: "reselect", selection: } ``` -------------------------------- ### Seek Command Structure Source: https://github.com/yahweasel/transavormer/blob/master/docs/STREAM-COMMANDS.md Performs a seek operation in the input file. Time values default to seconds unless streamTimebase is enabled. ```typescript { c: "seek", time: number, min?: number, max?: number, stream?: number, streamTimebase?: boolean } ``` -------------------------------- ### Streaming input file interface Source: https://github.com/yahweasel/transavormer/blob/master/docs/API.md An alternative to ReadableStream for streaming input, requiring a read function that returns a Promise of Uint8Array or null for EOF. ```typescript { read: (len: number) => Promise } ``` -------------------------------- ### Muxer stream wrapper structure Source: https://github.com/yahweasel/transavormer/blob/master/docs/API.md The object returned when creating a muxer stream, containing component metadata and command handling. ```typescript { component: "muxer", streamType: "file", stream: ReadableStream<{position: number, data: Uint8Array}>, sendCommands: (cmds: Command[]) => Promise } ``` -------------------------------- ### Define output file stream structure Source: https://github.com/yahweasel/transavormer/blob/master/docs/API.md Represents the structure of an output file stream, supporting random access write operations. ```typescript { streamType: "file", stream: ReadableStream<{position: number, data: Uint8Array}>, sendCommands: (cmds: Command[]) => Promise } ``` -------------------------------- ### Define frame stream structure Source: https://github.com/yahweasel/transavormer/blob/master/docs/API.md The interface definition for frame streams, supporting multiple frame types and command execution. ```typescript { streamType: "frame" | "libav-frame" | "webcodecs-frame", streams: Promise, stream: ReadableStream, sendCommands: (cmds: Command[]) => Promise } ``` -------------------------------- ### Define StreamFrame structure Source: https://github.com/yahweasel/transavormer/blob/master/docs/API.md The wrapper object structure for frames, identifying the stream index and the frame data. ```typescript { streamIndex: number, frame: Frame | number | VideoFrame | AudioData } ``` -------------------------------- ### Packet Stream Structure Source: https://github.com/yahweasel/transavormer/blob/master/docs/API.md The interface definition for a packet stream object, including stream metadata and command handling. ```typescript { streamType: "packet", streams: Promise, stream: ReadableStream, sendCommands: (cmds: Command[]) => Promise } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.