canReencodeVideoTrack()
属于 @remotion/webcodecs 软件包的一部分.
🌐 Part of the @remotion/webcodecs package.
不稳定的 API:此软件包处于实验阶段。在我们移除此提示之前,API 可能随时更改。
给定一个 VideoTrack,确定它是否可以重新编码到另一条轨道。
🌐 Given a VideoTrack, determine if it can be re-encoded to another track.
你可以使用 parseMedia() 获取 VideoTrack,或者在使用 convertMedia() 的 onVideoTrack 回调的转换过程中获取。
🌐 You can obtain a VideoTrack using parseMedia() or during the conversion process using the onVideoTrack callback of convertMedia().
示例
🌐 Examples
Check if video tracks can be re-encoded to VP8import {parseMedia } from '@remotion/media-parser'; import {canReencodeVideoTrack } from '@remotion/webcodecs'; const {tracks } = awaitparseMedia ({src : 'https://remotion.media/BigBuckBunny.mp4',fields : {tracks : true, }, }); constvideoTracks =tracks .filter ((t ) =>t .type === 'video'); for (consttrack ofvideoTracks ) { awaitcanReencodeVideoTrack ({track ,videoCodec : 'vp8',resizeOperation : null,rotate : null, }); }
Convert a video track to VP8, otherwise drop itimport {convertMedia ,canReencodeVideoTrack } from '@remotion/webcodecs'; awaitconvertMedia ({src : 'https://remotion.media/BigBuckBunny.mp4',container : 'webm',videoCodec : 'vp8',audioCodec : 'opus',onVideoTrack : async ({track ,resizeOperation ,rotate }) => { constcanReencode = awaitcanReencodeVideoTrack ({track ,videoCodec : 'vp8',resizeOperation ,rotate , }); if (canReencode ) { return {type : 'reencode',videoCodec : 'vp8'}; } return {type : 'drop'}; }, });
应用编程接口
🌐 API
track
一个 VideoTrack 对象。
🌐 A VideoTrack object.
videoCodec
字符串 ConvertMediaVideoCodec
🌐 string ConvertMediaVideoCodec
支持的视频编解码器之一:"vp8"、"vp9"。
🌐 One of the supported video codecs: "vp8", "vp9".
resizeOperation
你想要应用的调整大小操作。
🌐 The resize operation you would like to apply.
rotate
你想要应用的旋转操作。
🌐 The rotate operation you would like to apply.
返回值
🌐 Return value
返回一个 Promise<boolean>。
🌐 Returns a Promise<boolean>.
另请参阅
🌐 See also