native-video-encoder
v2.0.1
Published
Allows for access to native video encoding (iOS and Android). Supports splicing together videos based on a provided manifest mapping of the videos (provided these video paths point to videos actually loaded on the device). Supports progress reporting via
Maintainers
Readme
native-video-encoder
Allows for access to native video encoding (iOS and Android). Supports splicing together videos based on a provided manifest mapping of the videos (provided these video paths point to videos actually loaded on the device). Supports progress reporting via listeners.
Install
npm install native-video-encoder
npx cap syncAPI
echo(...)composeVideo(...)cancelComposition(...)addListener('progress', ...)removeAllListeners()- Interfaces
echo(...)
echo(options: { value: string; }) => Promise<{ value: string; }>| Param | Type |
| ------------- | ------------------------------- |
| options | { value: string; } |
Returns: Promise<{ value: string; }>
composeVideo(...)
composeVideo(options: ComposeVideoOptions) => Promise<ComposeVideoResult>Compose multiple video segments into a single output video
| Param | Type | Description |
| ------------- | ------------------------------------------------------------------- | --------------------------- |
| options | ComposeVideoOptions | - Composition configuration |
Returns: Promise<ComposeVideoResult>
cancelComposition(...)
cancelComposition(options: { compositionId: string; }) => Promise<void>Cancel an ongoing composition
| Param | Type | Description |
| ------------- | --------------------------------------- | --------------------------------------- |
| options | { compositionId: string; } | - Contains the composition ID to cancel |
addListener('progress', ...)
addListener(eventName: 'progress', listenerFunc: (event: ProgressEvent) => void) => Promise<PluginListenerHandle>Add a listener for progress events
| Param | Type |
| ------------------ | --------------------------------------------------------------------------- |
| eventName | 'progress' |
| listenerFunc | (event: ProgressEvent) => void |
Returns: Promise<PluginListenerHandle>
removeAllListeners()
removeAllListeners() => Promise<void>Remove all listeners for this plugin
Interfaces
ComposeVideoResult
| Prop | Type | Description |
| -------------------- | ------------------- | ------------------------------------------ |
| outputPath | string | Local file path to the composed video |
| compositionId | string | Composition ID |
| processingTime | number | Time taken to process the video in seconds |
ComposeVideoOptions
| Prop | Type | Description |
| -------------------- | --------------------------- | ------------------------------------------------------------------- |
| segments | VideoSegment[] | Array of video segments to compose |
| outputWidth | number | Output video width (default: 1080 for 9:16) |
| outputHeight | number | Output video height (default: 1920 for 9:16) |
| frameRate | number | Output frame rate (default: 30) |
| bitrate | number | Output video bitrate in bits per second (default: 5000000 = 5Mbps) |
| outputFileName | string | Output file name (optional, will generate if not provided) |
| compositionId | string | Unique ID for this composition (for progress tracking/cancellation) |
VideoSegment
| Prop | Type | Description |
| ------------------- | ------------------- | ---------------------------------------------------------- |
| videoId | string | Unique identifier for this video file |
| videoPath | string | Local file path or URI to the video file |
| timelineStart | number | Where this segment starts in the output timeline (seconds) |
| timelineEnd | number | Where this segment ends in the output timeline (seconds) |
| trackStart | number | Start time in the source video to use (seconds) |
| trackEnd | number | End time in the source video to use (seconds) |
PluginListenerHandle
| Prop | Type |
| ------------ | ----------------------------------------- |
| remove | () => Promise<void> |
ProgressEvent
| Prop | Type | Description |
| ------------------- | ------------------- | ------------------------ |
| compositionId | string | Composition ID |
| progress | number | Progress from 0.0 to 1.0 |
| status | string | Current status message |
