WebM
Encode VP9 video and optional Opus audio into a WebM file.
Use webm_vp9 to create a VP9 video file. When the Source has audio, Chunkify encodes it as Opus at 48 kHz. Set disable_audio: true for video only.
Default video settings are CRF 24, quality: realtime, cpu_used: "5", and pixfmt: yuv420p. The cpu_used option controls VP9 encoding effort and its speed-quality tradeoff.
Create a WebM transcode
The example sets a height of 720 pixels and CRF 24. Width follows the Source aspect ratio.
Run these examples on your server after setting up your SDK and Source. Replace the token and Source ID.
These examples save the file in your Project's output storage. Set storage.path to the filename you want to use.
import Chunkify from '@chunkify/chunkify';
async function main() {
const client = new Chunkify({
projectAccessToken: 'My Project Access Token',
});
const transcoding = await client.transcodings.create({
source_id: 'src_2G6MJiNz71bHQGNzGwKx5cJwPFS',
format: {
id: "webm_vp9",
height: 720,
crf: 24,
},
storage: {
path: 'exports/video-720p.webm',
},
});
console.log(transcoding.id, transcoding.status);
}
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
Rate control
Set per_title: true to select a bitrate from the video content, or supply video_bitrate for an explicit target. Do not combine either with a manual CRF.
VP9 maxrate and bufsize require a target video_bitrate. minrate is supported only when it equals both video_bitrate and maxrate, selecting constant bitrate encoding.
Encoding parameters
webm_vp9 standalone file encoding settings.
Id specifies the output format.
AudioBitrate specifies the output audio bitrate in bits per second. Defaults to 128000.
32000 <= x <= 512000AudioSamplerate specifies the output sample rate in Hz. Defaults to 48000. WebM Opus audio uses 48000.
80001102512000160002205024000320004410048000640008820096000Bufsize specifies the video buffer size in bits, from 100000 through 50000000. H.264 and H.265 require maxrate. AV1 and VP9 require a bitrate-controlled mode.
100000 <= x <= 5e+07Channels specifies the output channel count. Defaults to stereo. Six channels means 5.1; eight means 7.1.
1268CpuUsed specifies the CPU usage level for VP9 encoding. Range: 0 to 8. Lower values mean better quality but slower encoding, higher values mean faster encoding but lower quality. Recommended values: 0-2 for high quality, 2-4 for good quality, 4-6 for balanced, 6-8 for speed
0123456784Crf (Constant Rate Factor) controls the quality of the output video. Lower values mean better quality but larger file size. Range: 15 to 35. Recommended values: 18-28 for high quality, 23-28 for good quality, 28-35 for acceptable quality.
15 <= x <= 3523DisableAudio omits the audio stream. Defaults to false. A source without audio produces video only.
DisableVideo selects an audio-only AAC M4A export. Defaults to false. The source must contain audio.
Duration specifies the requested output length in seconds. Defaults to the remaining source duration and is capped at the source end. Audio-only output must resolve to at least 0.001 seconds after trimming and sample rounding. The accepted interval determines the fixed price.
Framerate specifies the output video frame rate. Defaults to the source rate and must be between 0.001 and 240 fps.
0.001 <= x <= 240Gop specifies the maximum keyframe interval in frames. Defaults to four seconds at the accepted frame rate, capped at 960 frames.
1 <= x <= 960Height specifies the output dimension in pixels. Use -2 or omit one dimension to preserve the source aspect ratio. Explicit dimensions must be 2 to 7680 and even. Omitting both preserves the source dimensions rounded down to even pixels.
-2 <= x <= 7680Maxrate specifies the video buffer maximum rate in bits per second, from 100000 through 50000000. H.264 and H.265 require bufsize. VP9 requires video_bitrate; AV1 requires CRF mode.
100000 <= x <= 5e+07Minrate selects VP9 constant bitrate when equal to video_bitrate and maxrate. Other minimum-rate combinations are unsupported.
100000 <= x <= 5e+07PerTitle enables independent content-based bitrate prediction for each part of the video. Analysis uses only the selected trim interval. Defaults to false. Explicit rate-control settings cannot be combined with it.
Pixfmt specifies the output pixel format. Defaults to yuv420p. The selected profile must support it.
yuv420pyuv422pyuv440pyuv444pyuv420p10leyuv422p10leyuv440p10leyuv444p10leyuv420p12leyuv422p12leyuv440p12leyuv444p12leQuality specifies the VP9 encoding quality preset. Valid values:
- good: Balanced quality preset, good for most applications
- best: Best quality preset, slower encoding
- realtime: Fast encoding preset, suitable for live streaming
goodbestrealtimegoodSeek specifies the start in source seconds. Defaults to zero and must precede the source end. The accepted interval uses the output frame or sample timeline. Audio-only output must retain at least 0.001 seconds after sample rounding.
x >= 0VideoBitrate specifies the target video bitrate in bits per second, from 1000 through 100000000. Omit it for CRF or per-title encoding.
1000 <= x <= 1e+08Width specifies the output dimension in pixels. Use -2 or omit one dimension to preserve the source aspect ratio. Explicit dimensions must be 2 to 7680 and even. Omitting both preserves the source dimensions rounded down to even pixels.
-2 <= x <= 7680