Feature Description
This document introduces how to use the TRTCVideoDecoder plugin to enable video decoder fallback capability. The plugin supports fallback to software decoding when regular decoding fails.
Prerequisites
-
TRTC Web SDK version >= 5.9.0
-
Contact us to enable decoder fallback capability
Implementation Steps
1. Deploy Decoder Resources
Dynamic file dependencies: The decoder plugin depends on certain files. To ensure browsers can load and run these files normally, you need to complete the following steps:
Deploy the videodec.wasm
and videodec_simd.wasm
files from the node_modules/trtc-sdk-v5/plugins/video-decoder
directory to your CDN
or static resource server, and ensure they are under the same public path. If you need to use the decoder functionality, you need to provide the URL of the above public path, and the plugin will dynamically load the dependent files.
- If the Host URL of the directory files is different from the Host URL of the web application, you need to enable CORS policy for accessing the file domain.
- The directory files cannot be placed under HTTP service, as loading HTTP resources under HTTPS domains will be blocked by browser security policies.
The resource path directory needs to be configured in the trtc instance creation function. This path will be the common path for all external resource dependencies, and you can also put resources from other plugins in this path.
For example: https://example.com/assets/
2. Import and Register Plugin
import VideoDecoderPlugin from 'trtc-sdk-v5/plugins/video-decoder';
const trtc = TRTC.create({ plugins: [VideoDecoderPlugin], assetsPath: 'https://example.com/assets/' });
Plugin Activation
The plugin functionality will automatically activate the fallback logic when SDK regular decoding fails, using software decoding method to decode.