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 excellend and consistent result on all platforms. Here's an example of an ffmpeg command encoding video in the proper format:

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.

In some cases, you may also be able to use the less common WebM format in case you need video with transparent areas (more on that below).

Blocks streams video over the network. For best streaming performance, an video file should have a reasonable data-rate for its resolution, and be optimized for "fast start". Such a "fast start" video file has the following properties:

  • The internal "file dictionary" is positioned atthe beginning of the file, making this available right away as the file begins to stream.
  • 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 "streaming" and/or "fast start". If so, you can use those options. For instance, ffmpeg (a popular command-line video encoding program) provides the -movflags faststart option to accomplish this.

In case your video encoder doesn't provide such an option, you can apply this optimization to an already encoded video file using the following command line, again using the ffmpeg program (but here just for optimizing the file, not encoding it):

ffmpeg  -i "SourceFile.mov"  -movflags +faststart -c:v copy -c:a copy "DestFile.mp4"

This assumes that the file already contains H.264-encoded video, and that any audio in the file is AAC encoded. Some distributions of ffmpeg include a stand-alone tool for doing just this optimization, called qt-faststart. See more about this here.

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 "optimizing" it as described above, where the source file is a MOV and the output file is set to MP4.

Using WebM Video Files

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"). To use such a file with Blocks, use a browser that supports this format (such as Google Chrome) to bring the file into Blocks.

:!: IMPORTANT: While WebM works on PIXILAB Player and many other Chrome-based browsers (including many Android-based phones and devices), it does not work on iOS or iPadOS (not even when using Chrome on iOS). Thus, do not use the WebM format if your content may need to play back on visitor's mobile phones or other devices over which you have no control of which browser is being used.