[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003eThis guide explains the basics of VP9 video encoding using FFmpeg, covering topics like resolution, bitrate control, and quality settings.\u003c/p\u003e\n"],["\u003cp\u003eVP9 encoding involves a trade-off between quality and encoding speed, with various settings to balance these factors.\u003c/p\u003e\n"],["\u003cp\u003eThe guide provides recommendations for resolutions and bitrates based on target quality and usage, such as 640x480 for broad device compatibility.\u003c/p\u003e\n"],["\u003cp\u003eFFmpeg command-line parameters are detailed for controlling aspects like frame size (\u003ccode\u003e-vf scale\u003c/code\u003e), bitrate (\u003ccode\u003e-b:v\u003c/code\u003e, \u003ccode\u003e-crf\u003c/code\u003e), and quality/speed (\u003ccode\u003e-quality\u003c/code\u003e, \u003ccode\u003e-speed\u003c/code\u003e).\u003c/p\u003e\n"],["\u003cp\u003eCQ mode (Constrained Quality) is generally recommended for VP9 encoding of video files, using \u003ccode\u003e-crf\u003c/code\u003e to set the maximum quality level.\u003c/p\u003e\n"]]],["The core content outlines VP9 video encoding using FFmpeg, detailing key actions and parameters. It covers: input and output file specification, setting frame size with `-vf scale`, and controlling bitrate via Constant Quantizer (Q), Constrained Quality (CQ), Variable Bitrate (VBR), and Constant Bitrate (CBR). CQ is the mode recommended. The document also explains quality vs. speed trade-offs, managed by `-quality`, `-speed`, `-threads`, and `-tile-columns` parameters, to balance encoding time and output quality.\n"],null,["Basic Encoding\n--------------\n\n### Video Compression Basics\n\nThis section covers basic options for VP9 encoding, including frame size,\nbasic bitrate control and quality.\n\nIf you're new to video compression you may wish to watch\n[this video](https://youtu.be/7YQ1mikDhIo) to learn more about the need for\nvideo compression, and how it works.\n\n### A Simple Encode\n\nThe following FFmpeg command converts an input file to VP9 video with Opus\naudio. This is the simplest possible encode which uses default settings. \n\n ffmpeg -i tears_of_steel_1080p.webm -c:v libvpx-vp9 -c:a libopus output.webm\n\nThis FFmpeg encode uses the following command-line parameters:\n\n| FFmpeg | |\n|-------------------|-----------------------------------|\n| `-i \u003cfilename\u003e` | Specifies input file name |\n| `-c:v libvpx-vp9` | Tells FFmpeg to create VP9 video |\n| `-c:a libopus` | Tells FFmpeg to create Opus audio |\n| `output.webm` | Specifies output file name |\n\nFFmpeg infers the type of file to make from the output file name you use. In\nthis example, FFmpeg will output a WebM file because we asked for\n`output.webm`.\n\n### Resolution\n\nEvery video has a frame size (indicating the pixel width and height). The\nfollowing FFmpeg command-line parameter can be used to control the output video\nframe size for VP9 encoding:\n\n| FFmpeg | |\n|------------------------------|------------------------|\n| `-vf scale=\u003cwidth\u003ex\u003cheight\u003e` | Frame width and height |\n\nFor example, the following FFmpeg command will output a 640x480 VP9 WebM video. \n\n ffmpeg -i tears_of_steel_1080p.webm -vf scale=640x480 \\\n -c:v libvpx-vp9 -c:a libopus output.webm\n\nSmaller resolutions are lower quality, but larger resolutions require more\nbandwidth, more processing power to decode, and may not be supported on older\ndevices. For VP9, 640x480 is considered a safe resolution for a broad range of\nmobile and web devices.\n| **Note:** Every video also has a frame rate (the number of images displayed per second). By default, FFmpeg matches the output video frame rate to the input.\n\n### Bitrate (bit rate)\n\nVP9 supports several different bitrate modes:\n\n| mode | |\n|--------------------------|---------------------------------------------------------------------------------------|\n| Constant Quantizer (Q) | Allows you to specify a fixed quantizer value; bitrate will vary |\n| Constrained Quality (CQ) | Allows you to set a maximum quality level. Quality may vary within bitrate parameters |\n| Variable Bitrate (VBR) | Balances quality and bitrate over time within constraints on bitrate |\n| Constant Bitrate (CBR) | Attempts to keep the bitrate fairly constant while quality varies |\n\nCQ mode is recommended for file-based video (as opposed to live streaming).\nThe following FFmpeg command-line parameters are used for CQ mode:\n\n| FFmpeg | |\n|-----------------------------------|--------------------------------------------------------------------------------------|\n| `-b:v \u003carg\u003e` | Sets target bitrate (e.g. 500k) |\n| `-minrate \u003carg\u003e` `-maxrate \u003carg\u003e` | Sets minimum and maximum bitrate. |\n| `-crf \u003carg\u003e` | Sets maximum quality level. Valid values are 0-63, lower numbers are higher quality. |\n\n| **Note:** Bitrate is specified in kbps, or kilobits per second. In video compression a kilobit is generally assumed to be 1000 bits (not 1024).\n| **Note:** Other codecs in FFmpeg accept the -crf parameter but may interpret the value differently. If you are using -crf with other codecs you will likely use different values for VP9.\n\nFor example, the following FFmpeg command will create a medium-quality 640x480\nvideo file using CQ mode, with an average bitrate of 750kbps and maximum\nquality constrained to 33. \n\n ffmpeg -i tears_of_steel_1080p.webm -vf scale=640x480 \\\n -b:v 750k -crf 33 -c:v libvpx-vp9 -c:a libopus output.webm\n\nBitrate will vary depending upon the quality you wish to achieve, and the\nresolution of the video. A full set of recommendations for bitrates at various\nresolutions can be found [here](../settings/vod/).\n\n### Quality and Speed Settings\n\nCompressing video is a trade-off between the quality of the output, and the\namount of time it takes to create it. Generally speaking, you can always get\nhigher quality by allowing more time to encode, but the time required to get\nthe highest possible quality may be impractical.\n\nVP9 offers several settings to balance quality and speed:\n\n- Quality setting instructs the encoder on the approach it takes to\n compress video. Available modes are best, good, and realtime.\n\n- Threading settings allow the encoder to use multiple CPU\n threads to encode the video. These settings may slightly reduce quality,\n but can significantly improve encoding and decoding speed.\n\nThese two types of settings are controlled by several command-line parameters:\n\n| FFmpeg | |\n|-----------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `-threads` | Indicates the number of threads to use during encoding. |\n| `-quality` | May be set to `good`, `best`, or `realtime` |\n| `-speed` | This parameter has different meanings depending upon whether quality is set to `good` or `realtime`. Speed settings `0-4` apply for VoD in `good` and `best`, with `0` being the highest quality and `4` being the lowest. `Realtime` valid values are `5-8`; lower numbers mean higher quality |\n| `-tile-columns` | Tiling splits the video into rectangular regions, which allows multi-threading for encoding and decoding. The number of tiles is always a power of two. `0`=1 tile, `1`=2, `2`=4, `3`=8, `4`=16, `5`=32. |\n\nThe following FFmpeg command will create a 640x480 file with quality set to\n'good' and speed set to 0 (high quality): \n\n ffmpeg -i tears_of_steel_1080p.webm -vf scale=640x480 \\\n -b:v 750k -quality good -speed 0 -crf 33 -c:v libvpx-vp9 -c:a libopus \\\n output.webm\n\nYour choices for quality and speed settings may vary depending upon resolution\nand available processing power. A full set of recommendations can be found in\nthe next section."]]