Optimizing Long Still-Frame Videos with Audio for Web and Mobile

Optimizing Long Still-Frame Videos with Audio for Web and Mobile

When dealing with long, still-image videos that incorporate audio, the choice of video codec and audio format can greatly impact the final file size and quality. In this article, we explore which video codec (HEVC, H.264, and AV1) and audio format (AAC, MP3, FLAC, M4A) would be the best for your needs. We define "best" by considering both file size and quality, as well as compatibility across various devices and web browsers.

What is the Best Format for Long Still-Frame Videos?

An Overview of HEVC (H.265)

For high-quality, lossless compression of still images, the highly efficient HEVC (High Efficiency Video Coding) codec is often the go-to choice. HEVC can be encoded into an MP4 file with AAC audio and supports a wide range of devices, including modern computers, mobile devices, and smart TVs. HEVC is particularly effective for compressing still images due to its intraframe prediction and a plethora of other advanced features.

One trick to optimize the video for still images is to enable I-frame/IDR/keyframe-only encoding, which can significantly speed up the process compared to typical video compression where each frame is compared to the preceding frames. This method is especially useful when dealing with distinct still images rather than a timelapse. Experiments have shown that HEVC can achieve this at only 1/5 the bitrate of JPEG without visible quality loss, particularly for sharp lines, such as in comic book art.

Alternative: H.264

H.264 is another viable option, albeit with slightly larger file sizes compared to HEVC for similar quality. H.264 is known for its backward compatibility and is supported by major web browsers. While H.264 encoders typically have fewer adjustable parameters, there are still ways to optimize it for still images. Tuning techniques can significantly improve the compression ratio and quality for discrete still frames.

Novel Approach: AV1

For those targeting the latest web browsers and devices, AV1 (Alliance for Open Media Video Codec) is a compelling choice. It offers a similar level of quality to HEVC but with lower compatibility constraints. If your images contain a lot of grain, you can use the film grain synthesis filter to remove the grain before encoding and then have it added back during playback. This method can decrease the bitrate by up to 50%, though it requires advanced expertise to implement effectively.

Embedding the Still Image in Audio Files

In some cases, it might be beneficial to consider embedding the still image within an audio file, such as AAC, MP3, FLAC, or M4A. This technique is often used to attach album art to songs, where embedding the album art in the audio file ensures it is displayed during playback. For this to work successfully, the image must be embedded properly, and software like VLC can display the included image for the duration of the audio.

Tuning for Still-Frame Videos vs. Traditional Videos

When creating a long series of still frames with fades to and from black, the resulting file is more like a video, increasing the bandwidth requirements. The best approach is to create a single frame per image with a multi-second duration and encode just those frames. In this case, you can make tweaks in the fades to minimize the impact, such as ensuring keyint settings are higher than the number of frames between still images and enabling P and B frame weighted prediction. The x265 encoder has a --fades command that can help in these scenarios.

Conclusion

With the right combination of codecs and a bit of fine-tuning, you can significantly improve the quality and reduce the file size of your long, still-frame videos while maintaining compatibility across various devices and web browsers. Whether you choose HEVC, H.264, or AV1, the key is understanding the specific requirements and limitations of your project.