I'm trying to incorporate a video into a web page, where the video has a solid color background that matches the background color of the page, as well as a small animated character moving around within it. If I encode the uncompressed video with something like ffmpeg using naive settings, the resulting h.265 compressed video will have artifacting such that its background will subtly change colors, resulting in a subtle but still visible border with the page background. I want to avoid that.
Because I need to support Safari in iOS and macOS going back several years, I can't use an animated webp or webm file with a transparent background to display the video. And of course a transparent animated gif is right out due to the poor quality and large file size.
I'm aware that it's possible to use canvas to render a transparent h.265 video but before resorting to a method like that, I'm wondering, is there a way to encode the video so that its background remains the specific color I need it to be, at least in areas where there is no motion?