Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
blocks:video-encoding [2022-05-20 14:38] admin [Video Encoding] |
blocks:video-encoding [2025-02-11 11:54] (current) admin Misc typos and cleanup |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Video Encoding ====== | ====== Video Encoding ====== | ||
- | In general, video needs to be encoded as MP4 (or M4V) files, with video encoded using the H.264 codec and audio (if any) using the AAC codec. While there are many programs you can use to encode video, we recommend the free ffmpeg program, which provides | + | In general, video needs to be encoded as MP4 (or M4V) files, with video encoded using the H.264 codec and audio (if any) using the AAC codec. While there are many programs you can use to encode video, we recommend the free ffmpeg program, which provides |
< | < | ||
- | ffmpeg -i in -pix_fmt yuv420p -c:v libx264 -crf 22 -bf 0 -movflags +faststart out.mp4 | + | ffmpeg -i in.mov -pix_fmt yuv420p -c:v libx264 -crf 22 -movflags +faststart out.mp4 |
</ | </ | ||
The command above uses the constant quality option //-crf 22// rather than a specific bit-rate. We've found this to give the best possible quality while using an adaptive data rate depending on the needs of the source content. | The command above uses the constant quality option //-crf 22// rather than a specific bit-rate. We've found this to give the best possible quality while using an adaptive data rate depending on the needs of the source content. | ||
- | In some cases, you may also be able to use the less common WebM format | + | In some cases, you may also be able to use the less common WebM format. This supports |
Blocks streams video over the network. For best streaming performance, | Blocks streams video over the network. For best streaming performance, | ||
- | * The internal "file dictionary" | + | * The internal "file dictionary" |
* The file's data tracks (audio and video) are properly interleaved in the file, arriving for playback as needed. | * The file's data tracks (audio and video) are properly interleaved in the file, arriving for playback as needed. | ||
- | Some video encoders provide options to optimize the file for " | + | Some video encoders provide options to optimize the file for " |
- | + | ||
- | In case your video encoder doesn' | + | |
< | < | ||
Line 24: | Line 22: | ||
</ | </ | ||
- | This assumes that the file already | + | This assumes that the file already |
- | Note that the MOV and MP4 file formats are very similar. Thus, if you have a MOV file that you know contains H.264 video and AAC audio, you can often use it as is, possibly after " | + | The MOV and MP4 container |
Line 33: | Line 31: | ||
Another file format that can offer additional capabilities is WebM from Google. One interesting capability of this format is that it supports true transparency (sometimes referred to as an "alpha channel" | Another file format that can offer additional capabilities is WebM from Google. One interesting capability of this format is that it supports true transparency (sometimes referred to as an "alpha channel" | ||
- | :!: **IMPORTANT: | + | Example ffmpeg command line to encode a video in webm format: |
+ | |||
+ | < | ||
+ | ffmpeg -i SourceVideoWithAlpha.mov -c:v libvpx-vp9 -crf 22 out.webm | ||
+ | </ | ||
+ | |||
+ | More on using transparency in video for the web in [[https:// | ||
+ | |||
+ | :!: **IMPORTANT: |