### Install libmedia Packages Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/quick-start.en-US.md Instructions for installing the core libmedia packages (@libmedia/avutil, @libmedia/avformat, @libmedia/avcodec) using different Node.js package managers. ```bash npm install @libmedia/avutil npm install @libmedia/avformat npm install @libmedia/avcodec ``` ```bash pnpm add @libmedia/avutil pnpm add @libmedia/avformat pnpm add @libmedia/avcodec ``` ```bash yarn add @libmedia/avutil yarn add @libmedia/avformat yarn add @libmedia/avcodec ``` -------------------------------- ### Setting up and Running libmedia Demos (Shell) Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/demo.en-US.md This script provides the necessary commands to clone the libmedia project with submodules, navigate into the directory, install project dependencies using npm, build the AVPlayer and AVTranscoder development versions, and start a local HTTP server to host the demo files. The server defaults to port 8000 but can be configured. ```shell # Clone the project and all submodules git clone https://github.com/zhaohappy/libmedia.git --recursive # Enter the libmedia directory cd libmedia # Install dependencies npm install # Compile AVPlayer development version npm run build-avplayer-dev # Compile AVTranscoder development version npm run build-avtranscoder-dev # Start local http service # The default port is 8000. To change the port, execute: npx serve -p xxx --cors --config ./test/serve.json npm run server # Browser access http://localhost:8000/test/avplayer.html # Browser access http://localhost:8000/test/avtranscoder.html ``` -------------------------------- ### Configure Cheap Webpack Plugin (JavaScript) Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/quick-start.en-US.md This snippet shows how to configure Webpack to use the dedicated @libmedia/cheap/build/webpack/CheapPlugin, which simplifies the integration of the cheap transformer. ```javascript const path = require('path'); const CheapPlugin = require('@libmedia/cheap/build/webpack/CheapPlugin'); module.exports = (env) => { return { ... rules: [ { test: /\.ts?$/, use: [ { loader: 'ts-loader' } ] } ], plugins: [ new CheapPlugin({ env: 'browser', projectPath: __dirname }) ] } } ``` -------------------------------- ### Installing libmedia Dependencies Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/quick-start.md Install the core libmedia packages using your preferred package manager (npm, pnpm, or yarn). These packages provide the necessary utilities, format, and codec functionalities. ```bash npm install @libmedia/avutil npm install @libmedia/avformat npm install @libmedia/avcodec ``` ```bash pnpm add @libmedia/avutil pnpm add @libmedia/avformat pnpm add @libmedia/avcodec ``` ```bash yarn add @libmedia/avutil yarn add @libmedia/avformat yarn add @libmedia/avcodec ``` -------------------------------- ### Webpack Plugin Usage - CheapPlugin - JavaScript Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/quick-start.md Demonstrates how to integrate the `@libmedia/cheap/build/webpack/CheapPlugin` into a webpack configuration file. It shows how to require the plugin and add it to the `plugins` array with specific options like `env` and `projectPath`. ```javascript const path = require('path'); const CheapPlugin = require('@libmedia/cheap/build/webpack/CheapPlugin'); module.exports = (env) => { return { ... rules: [ { test: /\.ts?$/, use: [ { loader: 'ts-loader' } ] } ], plugins: [ new CheapPlugin({ env: 'browser', projectPath: __dirname }) ] } } ``` -------------------------------- ### Configure tsconfig.json for libmedia Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/quick-start.en-US.md Example configuration for tsconfig.json in a TypeScript project using libmedia, specifically setting up path aliases for ES module resolution and including necessary declaration files. ```json { "baseUrl": "./", "paths": { ... "@libmedia/common/*": ["node_modules/@libmedia/common/dist/esm/*"], "@libmedia/cheap/*": ["node_modules/@libmedia/cheap/dist/esm/*"], "@libmedia/avcodec/*": ["node_modules/@libmedia/avcodec/dist/esm/*"], "@libmedia/avformat/*": ["node_modules/@libmedia/avformat/dist/esm/*"], "@libmedia/avnetwork/*": ["node_modules/@libmedia/avnetwork/dist/esm/*"], "@libmedia/avplayer/*": ["node_modules/@libmedia/avplayer/dist/esm/*"], "@libmedia/avprotocol/*": ["node_modules/@libmedia/avprotocol/dist/esm/*"], "@libmedia/avrender/*": ["node_modules/@libmedia/avrender/dist/esm/*"], "@libmedia/audiostretchpitch/*": ["node_modules/@libmedia/audiostretchpitch/dist/esm/*"], "@libmedia/audioresample/*": ["node_modules/@libmedia/audioresample/dist/esm/*"], "@libmedia/avpipeline/*": ["node_modules/@libmedia/avpipeline/dist/esm/*"], "@libmedia/avtranscode/*": ["node_modules/@libmedia/avtranscode/dist/esm/*"], "@libmedia/avutil/*": ["node_modules/@libmedia/avutil/dist/esm/*"], "@libmedia/videoscale/*": ["node_modules/@libmedia/videoscale/dist/esm/*"], "@libmedia/avfilter/*": ["node_modules/@libmedia/avfilter/dist/esm/*"] }, "files": [ "node_modules/@libmedia/cheap/dist/esm/cheapdef.d.ts" ] } ``` -------------------------------- ### Setting up and Running libmedia Demo Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/demo.md Provides step-by-step shell commands to clone the libmedia repository including submodules, navigate into the directory, install project dependencies, build the AVPlayer and AVTranscoder development versions, start a local HTTP server, and access the demo pages in a web browser. ```shell # 克隆项目以及所有子模块 git clone https://github.com/zhaohappy/libmedia.git --recursive # 进入 libmedia 目录 cd libmedia # 安装依赖 npm install # 编译 AVPlayer 开发版 npm run build-avplayer-dev # 编译 AVTranscoder 开发版 npm run build-avtranscoder-dev # 启动本地 http 服务 # 默认端口 8000,若要更换端口执行 npx serve -p xxx --cors --config ./test/serve.json npm run server # 浏览器访问 http://localhost:8000/test/avplayer.html # 浏览器访问 http://localhost:8000/test/avtranscoder.html ``` -------------------------------- ### Running the libmedia Project (Shell) Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/contribution.en-US.md Provides shell commands to clone the repository with submodules, navigate into the directory, install dependencies, build AVPlayer and AVTranscoder in development mode, and start a local HTTP server for testing. ```shell # Clone the project and all submodules git clone git@github.com:zhaohappy/libmedia.git --recursive # enter libmedia directory cd libmedia # Install dependencies npm install # Compile AVPlayer with development mode npm run build-avplayer-dev # Compile AVTranscoder with development mode npm run build-avtranscoder-dev # Start local http service # The default port is 8000. To change the port, execute: npx http-server -p xxx --cors npm run server # Browser access http://localhost:8000/test/avplayer.html # Browser access http://localhost:8000/test/avtranscoder.html ``` -------------------------------- ### Install tslib Dependency (yarn) Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/quick-start.en-US.md Install the tslib library using yarn. This dependency may be required by @rollup/plugin-typescript when used with Vite or Rollup. ```bash yarn add tslib ``` -------------------------------- ### Installing tslib Dependency Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/quick-start.md Install the `tslib` package. This package might be required by the `@rollup/plugin-typescript` plugin used in Vite and Rollup configurations. ```bash npm install tslib ``` ```bash pnpm add tslib ``` ```bash yarn add tslib ``` -------------------------------- ### Install tslib Dependency (pnpm) Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/quick-start.en-US.md Install the tslib library using pnpm. This dependency may be required by @rollup/plugin-typescript when used with Vite or Rollup. ```bash pnpm add tslib ``` -------------------------------- ### Install tslib Dependency (npm) Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/quick-start.en-US.md Install the tslib library using npm. This dependency may be required by @rollup/plugin-typescript when used with Vite or Rollup. ```bash npm install tslib ``` -------------------------------- ### Installing @libmedia/cheap using Package Managers Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/package.en-US.md Use these commands to install the @libmedia/cheap module, a tool library for multi-thread JavaScript and high-performance WebAssembly, using npm, pnpm, or yarn. ```bash npm install @libmedia/cheap ``` ```bash pnpm add @libmedia/cheap ``` ```bash yarn add @libmedia/cheap ``` -------------------------------- ### Configure Libmedia Transformer with Rollup (JavaScript) Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/quick-start.en-US.md This snippet shows how to configure Rollup to use the libmedia cheap transformer through the @rollup/plugin-typescript plugin's transformers option, defining a program-level transformer factory. ```javascript import typescript from '@rollup/plugin-typescript'; import transformer from '@libmedia/cheap/build/transformer' export default { ... plugins: [ typescript({ // configure the tsconfig.json configuration file used // setting of "include" must to include the files need to compile tsconfig: './tsconfig.json', ... transformers: { before: [ { type: 'program', factory: (program) => { return transformer.before(program) } } ] }, ... }), ] }; ``` -------------------------------- ### Compiling TypeScript with Custom Transformer using tsc API (JavaScript) Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/quick-start.en-US.md This script demonstrates how to use the TypeScript API (`ts`) to compile a project programmatically. It shows how to load configuration from `tsconfig.json`, create a program, and apply a custom transformer (`@libmedia/cheap/build/transformer`) during the compilation process, specifically before the emit phase. It also includes logic to log compilation errors. ```javascript const fs = require('fs') const path = require('path') const ts = require('typescript') const transformer = require('@libmedia/cheap/build/transformer') // Read the tsconfig.json configuration and change it to your own tsconfig.json path const configPath = path.resolve(__dirname, './tsconfig.json') const configText = fs.readFileSync(configPath, 'utf8') const { config } = ts.parseConfigFileTextToJson(configPath, configText) const parsedCommandLine = ts.parseJsonConfigFileContent( config, ts.sys, path.dirname(configPath) ) const program = ts.createProgram(parsedCommandLine.fileNames, parsedCommandLine.options) const emitResult = program.emit(undefined, undefined, undefined, undefined, { before: [ transformer.before(program, { defined: { ENV_NODE: true } }) ] }) // log error const allDiagnostics = ts .getPreEmitDiagnostics(program) .concat(emitResult.diagnostics) allDiagnostics.forEach((diagnostic) => { if (diagnostic.file) { const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); const message = ts.flattenDiagnosticMessageText( diagnostic.messageText, '\n' ); console.log( `${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}` ); } else { console.log( ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n') ); } }) ``` -------------------------------- ### Configure Libmedia Transformer with Vite (JavaScript) Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/quick-start.en-US.md This snippet demonstrates configuring Vite to use the libmedia cheap transformer via the @rollup/plugin-typescript plugin's transformers option, specifying a program-level transformer factory. ```javascript import { defineConfig } from 'vite'; import typescript from '@rollup/plugin-typescript'; import transformer from '@libmedia/cheap/build/transformer'; export default defineConfig({ ... plugins: [ typescript({ // configure the tsconfig.json configuration file used // setting of "include" must to include the files need to compile tsconfig: './tsconfig.json', ... transformers: { before: [ { type: 'program', factory: (program) => { return transformer.before(program) } } ] }, ... }) ], }); ``` -------------------------------- ### Installing @libmedia/common using Package Managers Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/package.en-US.md Use these commands to install the @libmedia/common module, which provides common tools and methods, using npm, pnpm, or yarn. ```bash npm install @libmedia/common ``` ```bash pnpm add @libmedia/common ``` ```bash yarn add @libmedia/common ``` -------------------------------- ### Installing @libmedia/audiostretchpitch using Package Managers Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/package.en-US.md Use these commands to install the @libmedia/audiostretchpitch module, which processes audio speed and pitch changes (compiled by soundtouch), using npm, pnpm, or yarn. ```bash npm install @libmedia/audiostretchpitch ``` ```bash pnpm add @libmedia/audiostretchpitch ``` ```bash yarn add @libmedia/audiostretchpitch ``` -------------------------------- ### Installing @libmedia/audioresample using Package Managers Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/package.en-US.md Use these commands to install the @libmedia/audioresample module, which handles audio resampling (compiled by FFmpeg), using npm, pnpm, or yarn. ```bash npm install @libmedia/audioresample ``` ```bash pnpm add @libmedia/audioresample ``` ```bash yarn add @libmedia/audioresample ``` -------------------------------- ### Node Compilation with TypeScript Transformer - JavaScript Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/quick-start.md Provides a script for compiling Node.js projects using the TypeScript compiler (`tsc`) with a custom transformer (`@libmedia/cheap/build/transformer`). It reads the `tsconfig.json`, creates a TypeScript program, applies the transformer during emission, and logs any compilation diagnostics. ```javascript const fs = require('fs') const path = require('path') const ts = require('typescript') const transformer = require('@libmedia/cheap/build/transformer') // 读取 tsconfig.json 配置,更改为自己的 tsconfig.json 的路径 const configPath = path.resolve(__dirname, './tsconfig.json') const configText = fs.readFileSync(configPath, 'utf8') const { config } = ts.parseConfigFileTextToJson(configPath, configText) const parsedCommandLine = ts.parseJsonConfigFileContent( config, ts.sys, path.dirname(configPath) ) const program = ts.createProgram(parsedCommandLine.fileNames, parsedCommandLine.options) const emitResult = program.emit(undefined, undefined, undefined, undefined, { before: [ transformer.before(program, { defined: { ENV_NODE: true } }) ] }) // 打印错误 const allDiagnostics = ts .getPreEmitDiagnostics(program) .concat(emitResult.diagnostics) allDiagnostics.forEach((diagnostic) => { if (diagnostic.file) { const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); const message = ts.flattenDiagnosticMessageText( diagnostic.messageText, '\n' ); console.log( `${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}` ); } else { console.log( ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n') ); } }) ``` -------------------------------- ### Configuring tsconfig.json for libmedia Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/quick-start.md Configure your TypeScript project's tsconfig.json file. Specifically, set the `paths` to map libmedia packages to their ES module distributions and include the `cheapdef.d.ts` file in `files`. Ensure `isolatedModules` is not set to true. ```json { "baseUrl": "./", "paths": { ... "@libmedia/common/*": ["node_modules/@libmedia/common/dist/esm/*"], "@libmedia/cheap/*": ["node_modules/@libmedia/cheap/dist/esm/*"], "@libmedia/avcodec/*": ["node_modules/@libmedia/avcodec/dist/esm/*"], "@libmedia/avformat/*": ["node_modules/@libmedia/avformat/dist/esm/*"], "@libmedia/avnetwork/*": ["node_modules/@libmedia/avnetwork/dist/esm/*"], "@libmedia/avplayer/*": ["node_modules/@libmedia/avplayer/dist/esm/*"], "@libmedia/avprotocol/*": ["node_modules/@libmedia/avprotocol/dist/esm/*"], "@libmedia/avrender/*": ["node_modules/@libmedia/avrender/dist/esm/*"], "@libmedia/audiostretchpitch/*": ["node_modules/@libmedia/audiostretchpitch/dist/esm/*"], "@libmedia/audioresample/*": ["node_modules/@libmedia/audioresample/dist/esm/*"], "@libmedia/avpipeline/*": ["node_modules/@libmedia/avpipeline/dist/esm/*"], "@libmedia/avtranscode/*": ["node_modules/@libmedia/avtranscode/dist/esm/*"], "@libmedia/avutil/*": ["node_modules/@libmedia/avutil/dist/esm/*"], "@libmedia/videoscale/*": ["node_modules/@libmedia/videoscale/dist/esm/*"], "@libmedia/avfilter/*": ["node_modules/@libmedia/avfilter/dist/esm/*"] }, "files": [ "node_modules/@libmedia/cheap/dist/esm/cheapdef.d.ts" ] } ``` -------------------------------- ### Installing @libmedia/videoscale using Package Managers Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/package.en-US.md Use these commands to install the @libmedia/videoscale module, which handles video scaling and format transformation (compiled by FFmpeg libswscale), using npm, pnpm, or yarn. ```bash npm install @libmedia/videoscale ``` ```bash pnpm add @libmedia/videoscale ``` ```bash yarn add @libmedia/videoscale ``` -------------------------------- ### Running Development and Build Commands Source: https://github.com/zhaohappy/libmedia/blob/master/site/README.md These commands are used to manage the documentation site development lifecycle. They cover installing necessary packages, starting a local development server, and generating the static site build. ```bash # install dependencies $ npm install # start dev server $ npm run dev # build docs $ npm run build ``` -------------------------------- ### Configuring Compiler for libmedia Transformer Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/quick-start.md Configure your build tool (webpack, vite, or rollup) to use the `@libmedia/cheap` transformer plugin. This is essential for TypeScript projects using libmedia's pointer types. The configuration involves adding the transformer to the TypeScript loader or plugin options. ```javascript const path = require('path'); const transformer = require('@libmedia/cheap/build/transformer'); module.exports = (env) => { return { module: { rules: [ { test: /\.ts?$/, use: [ { loader: 'ts-loader', options: { ... getCustomTransformers: function(program) { return { before: [transformer.before(program)] } }, ... } } ] } ], } } } ``` ```javascript import { defineConfig } from 'vite'; import typescript from '@rollup/plugin-typescript'; import transformer from '@libmedia/cheap/build/transformer'; export default defineConfig({ ... plugins: [ typescript({ // 配置使用的 tsconfig.json 配置文件 // include 中需要包含要处理的文件 tsconfig: './tsconfig.json', ... transformers: { before: [ { type: 'program', factory: (program) => { return transformer.before(program) } } ] }, ... }) ], }); ``` ```javascript import typescript from '@rollup/plugin-typescript'; import transformer from '@libmedia/cheap/build/transformer' export default { ... plugins: [ typescript({ // 配置使用的 tsconfig.json 配置文件 // include 中需要包含要处理的文件 tsconfig: './tsconfig.json', ... transformers: { before: [ { type: 'program', factory: (program) => { return transformer.before(program) } } ] }, ... }), ] }; ``` -------------------------------- ### Configure Libmedia Transformer with Webpack (JavaScript) Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/quick-start.en-US.md This snippet shows how to configure Webpack's ts-loader to use the libmedia cheap transformer by providing a custom transformer function via the getCustomTransformers option. ```javascript const path = require('path'); const transformer = require('@libmedia/cheap/build/transformer'); module.exports = (env) => { return { module: { rules: [ { test: /\.ts?$/, use: [ { loader: 'ts-loader', options: { ... getCustomTransformers: function(program) { return { before: [transformer.before(program)] } }, ... } } ] } ], } } } ``` -------------------------------- ### Install AVPlayer UI Package Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/player.en-US.md Commands to install the @libmedia/avplayer-ui package using different package managers. ```bash npm install @libmedia/avplayer-ui ``` ```bash pnpm add @libmedia/avplayer-ui ``` ```bash yarn add @libmedia/avplayer-ui ``` -------------------------------- ### Installing @libmedia/avplayer-ui using Package Managers Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/package.en-US.md Use these commands to install the @libmedia/avplayer-ui module, which provides a player with a user interface, using npm, pnpm, or yarn. ```bash npm install @libmedia/avplayer-ui ``` ```bash pnpm add @libmedia/avplayer-ui ``` ```bash yarn add @libmedia/avplayer-ui ``` -------------------------------- ### Installing @libmedia/avrender using Package Managers Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/package.en-US.md Use these commands to install the @libmedia/avrender module, which handles audio and video rendering using technologies like audioWorklet, WebGL, and WebGPU, using npm, pnpm, or yarn. ```bash npm install @libmedia/avrender ``` ```bash pnpm add @libmedia/avrender ``` ```bash yarn add @libmedia/avrender ``` -------------------------------- ### Installing @libmedia/avprotocol using Package Managers Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/package.en-US.md Use these commands to install the @libmedia/avprotocol module, which supports audio and video protocols like dash, m3u8, rtp, rtsp, rtmp, using npm, pnpm, or yarn. ```bash npm install @libmedia/avprotocol ``` ```bash pnpm add @libmedia/avprotocol ``` ```bash yarn add @libmedia/avprotocol ``` -------------------------------- ### Basic Usage of AVTranscoder Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/transcode.en-US.md Demonstrates how to initialize AVTranscoder, configure WASM file loading, handle task completion events, add a transcoding task, and start the task. ```javascript import AVTranscoder from '@libmedia/avtranscoder' import { AVCodecID } from '@libmedia/avutil/codec' const player = new AVTranscoder({ getWasm: (type, codecId, mediaType) => { switch (type) { case 'decoder': { switch (codecId) { case AVCodecID.AV_CODEC_ID_AAC: return `https://cdn.jsdelivr.net/gh/zhaohappy/libmedia@latest/dist/decode/aac-simd.wasm` case AVCodecID.AV_CODEC_ID_MP3: return `https://cdn.jsdelivr.net/gh/zhaohappy/libmedia@latest/dist/decode/mp3-simd.wasm` case AVCodecID.AV_CODEC_ID_FLAC: return `https://cdn.jsdelivr.net/gh/zhaohappy/libmedia@latest/dist/decode/flac-simd.wasm` case AVCodecID.AV_CODEC_ID_H264: return `https://cdn.jsdelivr.net/gh/zhaohappy/libmedia@latest/dist/decode/h264-simd.wasm` case AVCodecID.AV_CODEC_ID_HEVC: return `https://cdn.jsdelivr.net/gh/zhaohappy/libmedia@latest/dist/decode/hevc-simd.wasm` } } case 'encoder': { switch (codecId) { case AVCodecID.AV_CODEC_ID_AAC: return `https://cdn.jsdelivr.net/gh/zhaohappy/libmedia@latest/dist/encode/aac-simd.wasm` case AVCodecID.AV_CODEC_ID_MP3: return `https://cdn.jsdelivr.net/gh/zhaohappy/libmedia@latest/dist/encode/mp3-simd.wasm` case AVCodecID.AV_CODEC_ID_FLAC: return `https://cdn.jsdelivr.net/gh/zhaohappy/libmedia@latest/dist/encode/flac-simd.wasm` case AVCodecID.AV_CODEC_ID_H264: return `https://cdn.jsdelivr.net/gh/zhaohappy/libmedia@latest/dist/encode/h264-simd.wasm` case AVCodecID.AV_CODEC_ID_HEVC: return `https://cdn.jsdelivr.net/gh/zhaohappy/libmedia@latest/dist/encode/hevc-simd.wasm` } } case 'resampler': return `https://cdn.jsdelivr.net/gh/zhaohappy/libmedia@latest/dist/resample/resample-simd.wasm` case 'stretchpitcher': return `https://cdn.jsdelivr.net/gh/zhaohappy/libmedia@latest/dist/stretchpitch/stretchpitch-simd.wasm` case 'scaler': return 'https://cdn.jsdelivr.net/gh/zhaohappy/libmedia@latest/dist/scale/scale-simd.wasm' } } }) await transcoder.ready() transcoder.on('task-ended', (taskId) => { console.log('task', taskId, 'transcode ended') }) transcoder.addTask({ input: { 'https://xxxxx.flv' }, output: { file: writeFileHandler, format: 'mp4', audio: { codec: 'copy' }, video: { codec: 'copy' } } }).then((taskId) => { transcoder.startTask(taskId) }) ``` -------------------------------- ### Install AVPlayer Package Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/player.en-US.md Commands to install the @libmedia/avplayer package using different package managers. ```bash npm install @libmedia/avplayer ``` ```bash pnpm add @libmedia/avplayer ``` ```bash yarn add @libmedia/avplayer ``` -------------------------------- ### Installing @libmedia/avformat using Package Managers Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/package.en-US.md Use these commands to install the @libmedia/avformat module, which provides libraries for video and audio formats like flv, mp4, mpegts, etc., using npm, pnpm, or yarn. ```bash npm install @libmedia/avformat ``` ```bash pnpm add @libmedia/avformat ``` ```bash yarn add @libmedia/avformat ``` -------------------------------- ### Installing AVTranscoder Package Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/transcode.en-US.md Instructions on how to install the AVTranscoder package using different Node.js package managers. ```bash npm install @libmedia/avtranscoder ``` ```bash pnpm add @libmedia/avtranscoder ``` ```bash yarn add @libmedia/avtranscoder ``` -------------------------------- ### Installing @libmedia/avnetwork using Package Managers Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/package.en-US.md Use these commands to install the @libmedia/avnetwork module, which provides Web Platform network file IO related functionalities (Fetch, WebSocket, etc.), using npm, pnpm, or yarn. ```bash npm install @libmedia/avnetwork ``` ```bash pnpm add @libmedia/avnetwork ``` ```bash yarn add @libmedia/avnetwork ``` -------------------------------- ### Installing @libmedia/avplayer using Package Managers Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/package.en-US.md Use these commands to install the @libmedia/avplayer module, which provides player functionality, using npm, pnpm, or yarn. ```bash npm install @libmedia/avplayer ``` ```bash pnpm add @libmedia/avplayer ``` ```bash yarn add @libmedia/avplayer ``` -------------------------------- ### Installing @libmedia/avtranscoder using Package Managers Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/package.en-US.md Use these commands to install the @libmedia/avtranscoder module, which provides transcoder functionality, using npm, pnpm, or yarn. ```bash npm install @libmedia/avtranscoder ``` ```bash pnpm add @libmedia/avtranscoder ``` ```bash yarn add @libmedia/avtranscoder ``` -------------------------------- ### Installing @libmedia/avpipeline using Package Managers Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/package.en-US.md Use these commands to install the @libmedia/avpipeline module, which provides a media task processing pipeline for multi-threaded parallel tasks, using npm, pnpm, or yarn. ```bash npm install @libmedia/avpipeline ``` ```bash pnpm add @libmedia/avpipeline ``` ```bash yarn add @libmedia/avpipeline ``` -------------------------------- ### Configuring Build Tools for AVTranscoder Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/transcode.en-US.md Configuration examples for webpack and vite to copy the necessary dynamic module files required by AVTranscoder to the output directory. ```javascript // webpack can use the copy-webpack-plugin plugin // npm install copy-webpack-plugin --save-dev const CopyWebpackPlugin = require('copy-webpack-plugin') module.exports = (env) => { return { plugins: [ new CopyWebpackPlugin({ patterns: [ { from: 'node_modules/@libmedia/avtranscoder/dist/esm/[0-9]*.avtranscoder.js', to: './[name].[ext]' } ] }) ] } } ``` ```javascript // vite can use the vite-plugin-static-copy plugin // npm install vite-plugin-static-copy --save-dev import { viteStaticCopy } from 'vite-plugin-static-copy' export default defineConfig({ ... plugins: [ viteStaticCopy({ targets: [ { src: 'node_modules/@libmedia/avtranscoder/dist/esm/[0-9]*.avtranscoder.js', dest: './' } ] }) ] }); ``` -------------------------------- ### Installing @libmedia/avcodec using Package Managers Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/package.en-US.md Use these commands to install the @libmedia/avcodec module, an audio and video codec library primarily using Wasm compiled from C/C++ and WebCodecs, using npm, pnpm, or yarn. ```bash npm install @libmedia/avcodec ``` ```bash pnpm add @libmedia/avcodec ``` ```bash yarn add @libmedia/avcodec ``` -------------------------------- ### Basic AVPlayer Usage Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/player.en-US.md Example demonstrating how to import, initialize, load, and play media using the AVPlayer class, including specifying WASM file locations. ```javascript import AVPlayer from '@libmedia/avplayer' import { AVCodecID } from '@libmedia/avutil/codec' const player = new AVPlayer({ container: document.querySelector('#player'), getWasm: (type, codecId, mediaType) => { switch (type) { case 'decoder': { switch (codecId) { case AVCodecID.AV_CODEC_ID_AAC: return `https://cdn.jsdelivr.net/gh/zhaohappy/libmedia@latest/dist/decode/aac-simd.wasm` case AVCodecID.AV_CODEC_ID_MP3: return `https://cdn.jsdelivr.net/gh/zhaohappy/libmedia@latest/dist/decode/mp3-simd.wasm` case AVCodecID.AV_CODEC_ID_FLAC: return `https://cdn.jsdelivr.net/gh/zhaohappy/libmedia@latest/dist/decode/flac-simd.wasm` case AVCodecID.AV_CODEC_ID_H264: return `https://cdn.jsdelivr.net/gh/zhaohappy/libmedia@latest/dist/decode/h264-simd.wasm` case AVCodecID.AV_CODEC_ID_HEVC: return `https://cdn.jsdelivr.net/gh/zhaohappy/libmedia@latest/dist/decode/hevc-simd.wasm` } } case 'resampler': return `https://cdn.jsdelivr.net/gh/zhaohappy/libmedia@latest/dist/resample/resample-simd.wasm` case 'stretchpitcher': return `https://cdn.jsdelivr.net/gh/zhaohappy/libmedia@latest/dist/stretchpitch/stretchpitch-simd.wasm` } } }) await player.load('https://xxxxxxx') await player.play() ``` -------------------------------- ### Time Base Example: Arbitrary Fraction Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/timebase.en-US.md An example of an arbitrary fractional time base (666/6666 seconds per unit) used purely for illustration purposes to show the flexibility of the Rational structure. ```JavaScript {num: 666, den: 6666} ``` -------------------------------- ### Configure Build Tool for WASM Files Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/player.en-US.md Configuration examples for Webpack and Vite to copy necessary WASM module files to the output directory. ```javascript // webpack can use the copy-webpack-plugin plugin // npm install copy-webpack-plugin --save-dev const CopyWebpackPlugin = require('copy-webpack-plugin') module.exports = (env) => { return { plugins: [ new CopyWebpackPlugin({ patterns: [ { from: 'node_modules/@libmedia/avplayer/dist/esm/[0-9]*.avplayer.js', to: './[name].[ext]' } ] }) ] } } ``` ```javascript // vite can use the vite-plugin-static-copy plugin // npm install vite-plugin-static-copy --save-dev import { viteStaticCopy } from 'vite-plugin-static-copy' export default defineConfig({ ... plugins: [ viteStaticCopy({ targets: [ { src: 'node_modules/@libmedia/avplayer/dist/esm/[0-9]*.avplayer.js', dest: './' } ] }) ] }); ``` -------------------------------- ### Using libmedia Multithreading with DemuxPipeline (Bundler Examples) Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/threads.md These examples demonstrate how to instantiate a class, such as `DemuxPipeline`, to run within a worker thread using the `createThreadFromClass` utility. The specific import method for the worker file varies depending on the bundler (Vite, Webpack) or environment (Node.js). ```JavaScript import DemuxPipeline from '@libmedia/avpipeline/DemuxPipeline' import DemuxPipelineWorker from './worker?worker' const pipeline = await createThreadFromClass( DemuxPipeline, DemuxPipelineWorker ).run() ``` ```JavaScript import DemuxPipeline from '@libmedia/avpipeline/DemuxPipeline' import DemuxPipelineWorker from 'worker-loader!./worker' const pipeline = await createThreadFromClass( DemuxPipeline, DemuxPipelineWorker ).run() ``` ```JavaScript import DemuxPipeline from '@libmedia/avpipeline/DemuxPipeline' import { Worker } from 'worker_threads' const pipeline = await createThreadFromClass( DemuxPipeline, () => new Worker(require.resolve('./worker')) ).run() ``` -------------------------------- ### Enabling Multi-threaded Worker Debugging (JSON) Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/demo.en-US.md This JSON snippet shows how to modify the `tsconfig.json` file to enable debugging for multi-threaded Workers by setting the `ENABLE_THREADS_SPLIT` macro to `true` within the `cheap.defined` section. After making this change, the project must be recompiled for the setting to take effect. ```json { "cheap": { "defined": { "ENABLE_THREADS_SPLIT": true } } } ``` -------------------------------- ### Load RTMP/RTSP Streams Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/player.en-US.md Examples showing how to load RTMP and RTSP streams using AVPlayer, including options for specifying the source URI and using different proxy connection types (ws, wss, webtransport). ```javascript const player = new AVPlayer() // The first parameter is the rtmp proxy of Websocket Address player.load('rtmp://xxx.xxx.xxx.xxx/xxx/xxx', { // uri is the source rtmp address uri: 'rtmp://xxx.xxx.xxx.xxx/xxx/xxx' }) player.play() player.load('rtsp://xxx.xxx.xxx.xxx/xxx') player.play() // Use wss connection player.load('rtsp://xxx.xxx.xxx.xxx/xxx') // Use ws connection player.load('rtsp+ws://xxx.xxx.xxx.xxx/xxx') // Use webtransport connection player.load('rtsp+webtransport://xxx.xxx.xxx.xxx/xxx') ``` -------------------------------- ### Simplified libmedia Multithreading Usage with Webpack Plugin (JavaScript) Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/threads.md When using the recommended webpack plugin for libmedia, the process of creating a worker from a class is simplified. This example shows that you can directly pass the class to `createThreadFromClass` without needing a separate worker entry file, as the plugin handles the worker creation internally. ```JavaScript import DemuxPipeline from '@libmedia/avpipeline/DemuxPipeline' const pipeline = await createThreadFromClass( DemuxPipeline ).run() ``` -------------------------------- ### Time Base Example: Milliseconds Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/timebase.en-US.md Represents a time base where one unit equals 1/1000 seconds (1 millisecond). This time base is commonly used in formats like FLV. ```JavaScript {num: 1, den: 1000} ``` -------------------------------- ### Time Base Example: Web AudioData Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/timebase.en-US.md Represents the standard time base for Web API AudioData objects, where one unit equals 1/1000000 seconds (1 microsecond). AudioData output from WebAudioDecoder uses this time base. ```JavaScript {num: 1, den: 1000000} ``` -------------------------------- ### Time Base Example: Web VideoFrame Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/timebase.en-US.md Represents the standard time base for Web API VideoFrame objects, where one unit equals 1/1000000 seconds (1 microsecond). Decoded VideoFrames are uniformly converted to this time base. ```JavaScript {num: 1, den: 1000000} ``` -------------------------------- ### Obtaining Struct Instance Address with symbolStructAddress Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/javascript.en-US.md This code demonstrates how to retrieve the raw memory address of a struct instance in JavaScript. By accessing the `symbolStructAddress` property, provided by `@libmedia/cheap/symbol`, you can get the pointer value for the instance, as shown with the `codecpar` property of a `stream` object. ```JavaScript import { symbolStructAddress } from '@libmedia/cheap/symbol' let stream = iformatContext.getStreamByMediaType(AVMediaType.AVMEDIA_TYPE_AUDIO) // The instance address can be obtained by accessing the symbolStructAddress attribute of the instance let codecpar = stream.codecpar[symbolStructAddress] ``` -------------------------------- ### Calculating Structural Attribute Address with offsetof Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/javascript.en-US.md This snippet illustrates how to calculate the memory address of a specific attribute within a struct pointer. It uses the `offsetof` function from `@libmedia/cheap/std/offsetof` to determine the byte offset of the attribute (`data` in `AVPacket`) and adds this offset to the base pointer address (`avpacket`) to get the attribute's address. ```JavaScript import offsetof from '@libmedia/cheap/std/offsetof' import AVPacket from '@libmedia/avutil/struct/avpacket' // an avpacket pointer variable let avpacket // get the data address under the avpacket pointer, base address + offset const data = avpacket + offsetof(AVPacket, 'data') ``` -------------------------------- ### Initializing IOWriterSync for Data Output in TypeScript Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/io.en-US.md This snippet shows the basic initialization of an IOWriterSync instance for synchronous data output. It illustrates how to define the essential onFlush and onSeek callbacks required for writing data to an output source. ```typescript import IOWriterSync from '@libmedia/common/io/IOWriterSync' const ioWriter = new IOWriterSync() ioWriter.onFlush = (data: Uint8Array, pos: int64) => { return 0 } ioWriter.onSeek = (pos) => { return 0 } ``` -------------------------------- ### Build All Packages (Node.js Script) Source: https://github.com/zhaohappy/libmedia/blob/master/publish.readme.md Runs a Node.js script to compile all packages. This process generates the distribution files (e.g., bundled code) in the 'dist' directory within each package's subdirectory, preparing them for publication. ```Shell node scripts/build-package.js --package=all ``` -------------------------------- ### Initializing IOWriterSync for Data Output (TypeScript) Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/io.md This snippet illustrates how to create and configure an IOWriterSync instance for synchronous data output. It shows the basic structure for defining the onFlush and onSeek callbacks, which handle writing data and adjusting the write position. ```TypeScript import IOWriterSync from '@libmedia/common/io/IOWriterSync'\n\nconst ioWriter = new IOWriterSync()\n\nioWriter.onFlush = (data: Uint8Array, pos: int64) => {\n return 0\n}\nioWriter.onSeek = (pos) => {\n return 0\n}\n ``` -------------------------------- ### Worker Entry File for libmedia Multithreading (TypeScript) Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/threads.md This TypeScript file serves as the entry point for a worker thread. It imports the class intended to run in the worker (e.g., DemuxPipeline) and uses the `runThread` utility from `@libmedia/cheap/thread` to initialize and run the class within the worker context. ```TypeScript import DemuxPipeline from '@libmedia/avpipeline/DemuxPipeline' import runThread from '@libmedia/cheap/thread/runThread' runThread(DemuxPipeline) ``` -------------------------------- ### Vite Configuration for libmedia Worker Bundling (JavaScript) Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/threads.md This snippet shows the necessary configuration within the Vite `defineConfig` object to correctly bundle worker files for libmedia. It specifically illustrates how to apply a custom TypeScript transformer (`@libmedia/cheap/build/transformer`) to the worker scripts during the build process. ```JavaScript import { defineConfig } from 'vite'; import typescript from '@rollup/plugin-typescript'; import transformer from '@libmedia/cheap/build/transformer'; export default defineConfig({ ... worker: { plugins: () => { return [ typescript({ ... transformers: { before: [ { type: 'program', factory: (program) => { return transformer.before(program); } } ] } ... }), ] } } ... }); ``` -------------------------------- ### Cloning libmedia Repository (Shell) Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/compile-wasm.en-US.md Clones the libmedia repository from GitHub using the `--recursive` flag to ensure all necessary submodules are also downloaded. ```shell git clone https://github.com/zhaohappy/libmedia.git --recursive ``` -------------------------------- ### Initializing IOReader for File Input (TypeScript) Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/io.md This snippet demonstrates how to create and configure an IOReader instance to read data from a browser File object. It sets the SEEKABLE flag and defines the onFlush, onSeek, and onSize callbacks to handle data reading, seeking, and size reporting, respectively. ```TypeScript import { IOFlags } from '@libmedia/avutil/avformat'\nimport IOReader from '@libmedia/common/io/IOReader'\n\nconst readFile: File\n\nconst ioReader = new IOReader()\n\n// 设置可以 seek 标志\nioReader.flags |= IOFlags.SEEKABLE\n\nlet readPos = 0\nconst readFileLength = readFile.size\n\nioReader.onFlush = async (buffer) => {\n if (readPos >= readFileLength) {\n return IOError.END\n }\n const len = Math.min(buffer.length, readFileLength - readPos)\n\n buffer.set(new Uint8Array(await (readFile.slice(readPos, readPos + len).arrayBuffer())), 0)\n\n readPos += len\n\n return len\n}\nioReader.onSeek = (pos) => {\n readPos = Number(pos)\n return 0\n}\n\nioReader.onSize = () => {\n return BigInt(readFile.size)\n} ``` -------------------------------- ### Cloning and Checking out FFmpeg for libmedia Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/compile-wasm.md Clones the customized FFmpeg repository used by libmedia from GitHub and switches to the specific `libmedia7.0` branch required for compatibility with the libmedia build process. ```Shell git clone https://github.com/zhaohappy/FFmpeg.git cd FFmpeg git checkout libmedia7.0 ``` -------------------------------- ### Checking and Fixing Code Style with ESLint (Shell) Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/contribution.en-US.md Shows shell commands to check the project's code style using ESLint and automatically fix non-compliant code where possible, ensuring contributions adhere to the project's coding standards. ```shell # Check Code Style npm run eslint-check # Automatically revise non-compliant code # If automatic revise is not possible, please revise it manually npm run eslint-fix ``` -------------------------------- ### Cloning libmedia with Submodules Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/compile-wasm.md Clones the libmedia repository from GitHub using the `--recursive` flag to ensure that all necessary submodules, which contain dependencies and build scripts, are also cloned. ```Shell git clone https://github.com/zhaohappy/libmedia.git --recursive ``` -------------------------------- ### Configuring tsconfig.json for Worker Debugging Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/demo.md Shows how to modify the tsconfig.json file to enable source code debugging for multi-threaded Worker code by setting the ENABLE_THREADS_SPLIT macro to true within the 'cheap.defined' section. This requires recompiling the project after the change. ```json { "cheap": { "defined": { "ENABLE_THREADS_SPLIT": true } } } ``` -------------------------------- ### Configuring IOReader for File Input in TypeScript Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/io.en-US.md This snippet demonstrates how to initialize and configure an IOReader instance to read data asynchronously from a File object. It shows how to set the necessary callbacks (onFlush, onSeek, onSize) and flags (IOFlags.SEEKABLE) for file-based input. ```typescript import { IOFlags } from '@libmedia/avutil/avformat' import IOReader from '@libmedia/common/io/IOReader' const readFile: File const ioReader = new IOReader() // set seekable flag ioReader.flags |= IOFlags.SEEKABLE let readPos = 0 const readFileLength = readFile.size ioReader.onFlush = async (buffer) => { if (readPos >= readFileLength) { return IOError.END } const len = Math.min(buffer.length, readFileLength - readPos) buffer.set(new Uint8Array(await (readFile.slice(readPos, readPos + len).arrayBuffer())), 0) readPos += len return len } ioReader.onSeek = (pos) => { readPos = Number(pos) return 0 } ioReader.onSize = () => { return BigInt(readFile.size) } ``` -------------------------------- ### Compiling Wasm Codec Binaries (Shell) Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/compile-wasm.en-US.md Executes shell scripts (`build-decoder.sh`, `build-encoder.sh`) from the libmedia build directory to compile the WebAssembly (.wasm) binary files for the previously compiled codec libraries (e.g., aac) with various configurations. Requires being in the libmedia root directory. ```shell # Compile the binary of the baseline version of the aac decoder ./build/build-decoder.sh aac 0 0 0 # Compile the binary of the atomic version of the aac decoder ./build/build-decoder.sh aac 0 1 0 # Compile the binary of the simd version of the aac decoder ./build/build-decoder.sh aac 1 1 0 # Compile the binary of the 64 version of the aac decoder ./build/build-decoder.sh aac 1 1 1 # Compile the binary of the baseline version of the aac encoder ./build/build-encoder.sh aac 0 0 0 ``` -------------------------------- ### Compiling Codec Wasm Binaries Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/compile-wasm.md Executes shell scripts within the libmedia directory to compile the previously generated codec libraries into final WebAssembly (.wasm) binary files. This step uses the `build-decoder.sh` and `build-encoder.sh` scripts for different configurations (baseline, atomic, simd, 64-bit), producing the executable Wasm modules. ```Shell # 编译 aac 解码器 baseline 版本的二进制 ./build/build-decoder.sh aac 0 0 0 # 编译 aac 解码器 atomic 版本的二进制 ./build/build-decoder.sh aac 0 1 0 # 编译 aac 解码器 simd 版本的二进制 ./build/build-decoder.sh aac 1 1 0 # 编译 aac 解码器 64 版本的二进制 ./build/build-decoder.sh aac 1 1 1 # 编译 aac 编码器 baseline 版本的二进制 ./build/build-encoder.sh aac 0 0 0 # 编译 aac 编码器 atomic 版本的二进制 ./build/build-encoder.sh aac 0 1 0 # 编译 aac 编码器 simd 版本的二进制 ./build/build-encoder.sh aac 1 1 0 # 编译 aac 编码器 64 版本的二进制 ./build/build-encoder.sh aac 1 1 1 ``` -------------------------------- ### Compiling FFmpeg Codec Libraries (Shell) Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/compile-wasm.en-US.md Executes shell scripts (`build-ffmpeg-decoder.sh`, `build-ffmpeg-encoder.sh`) from the libmedia build directory to compile FFmpeg codec libraries (e.g., aac) with different configurations (baseline, atomic, simd, 64-bit). Requires being in the libmedia root directory. ```shell # Enter the libmedia root directory cd libmedia # Find the name of the decoder you need to compile in the FFmpeg compilation script, such as 'h264' for h264 and 'hevc' for h265 # and replace 'aac' in the following command with the found name # Compile the baseline version of the aac decoder ./build/build-ffmpeg-decoder.sh aac 0 0 0 # Compile the atomic version of the aac decoder ./build/build-ffmpeg-decoder.sh aac 0 1 0 # Compile the simd version of the aac decoder ./build/build-ffmpeg-decoder.sh aac 1 1 0 # Compile the 64 version of the aac decoder ./build/build-ffmpeg-decoder.sh aac 1 1 1 # Compile the baseline version of the aac encoder Version ./build/build-ffmpeg-encoder.sh aac 0 0 0 # Compile aac encoder atomic version ./build/build-ffmpeg-encoder.sh aac 0 1 0 # Compile aac encoder simd version ./build/build-ffmpeg-encoder.sh aac 1 1 0 # Compile aac encoder 64 version ./build/build-ffmpeg-encoder.sh aac 1 1 1 ``` -------------------------------- ### Worker Entry Point - JavaScript Source: https://github.com/zhaohappy/libmedia/blob/master/site/docs/guide/threads.en-US.md This code snippet shows the content of a separate TypeScript file intended to serve as the entry point for a worker thread. It imports the DemuxPipeline class and uses the runThread utility to execute it within the worker context. ```javascript import DemuxPipeline from '@libmedia/avpipeline/DemuxPipeline' import runThread from '@libmedia/cheap/thread/runThread' runThread(DemuxPipeline) ``` -------------------------------- ### Publish Packages to npm (Shell Script) Source: https://github.com/zhaohappy/libmedia/blob/master/publish.readme.md Runs a shell script to push the compiled and versioned packages to the configured npm repository. Ensure you are logged in to the target npm registry before executing this command. ```Shell sh ./build/publish.sh ```