FFmpeg

FFmpeg is a library for encoding video and audio files.

It's typically required for other encoding software to work, but can also be used on the command line.

Useful commands:

Convert a video file for playback in VRChat video players

Using Unity's Video File Compatibility chart, we can choose how to convert video files to get best playback in Unity.

ffmpeg -i SOURCE.mp4 -vf "fps=fps=30, scale='min(1280,iw)':-2" -c:v h264 -preset veryslow -movflags +faststart -c:a aac -ab 320k -strict -2 OUTPUT.mp4
  • -i SOURCE.mp4 - Specify your source file. It can be pretty much any video format.
  • -vf scale='min(1280,iw)':-2 : (Optional) Scale down to 1280 width (current width if smaller), keep the aspect ratio, and ensure even value for height.
    • Height and Width of the video *must* be divisible by two or Unity will fail to play it.
  • -vf fps=fps=30 : Change framerate of the video to 30. You can go as low as 24 FPS before Unity will fail to play the video.
  • -c:v h264 = Unity loves H.264 and this seems to significantly reduce audio desync problems.
  • -preset veryslow = Presets are a set of options that can be though of as a slider between speed and compression ratio. Higher compression is best since it lowers world size if uploading the video, or lowers bandwidth if it's streamed to a video player.
  • -movflags +faststart = Moves some info to the start of the file to allow video to begin playing sooner.
  • -c:a aac : Another codec that Unity seems to handle very well.
  • -ab 320k : (Optional) Audio bitrate. Just make sure you're not raising the bitrate higher than the source video. Can be lowered to reduce file size a bit.
  • -strict -2 : AAC is considered experimental by FFmpeg so this is required to encode with it.