rust-gamedev.github.io icon indicating copy to clipboard operation
rust-gamedev.github.io copied to clipboard

Officially allow small videos (e.g. mp4)

Open caspark opened this issue 8 months ago • 4 comments

I saw this was touched on over at #1500, but I figured I'd make a dedicated issue for it:

Any chance of officially blessing mp4 videos for inclusion, either in addition to or in place of gifs?

Could be with the same <2.5MB size guidance, or a stricter (say <1MB) requirement.

I am asking because mp4 files tend to be significantly more size-efficient than gifs; I happen to generate both for my weekly Slow Rush newsletter so I did a quick size comparison using the videos from 5 of my recent newsletter updates:

image (source: gif-vs-mp4.ods)

This is not a fair comparison because the gifs are generated at half the size and less than half the framerate of the mp4, but mp4 still gives an 80% size reduction on average. Such a large saving may not universally be the case for all footage (my game is pixel art oriented and, well, kinda ugly and monotonous-looking right now), but from a bit of poking around, to me it seems that to have mp4 do worse than gifs you'd have to actually put in effort to pick bad encoding settings.

FYI, here are the ffmpeg invocations I used (extracted from my png frames -> video conversion script):

# create a 60fps h264-encoded mp4
ffmpeg -nostdin -y -framerate 60 -i $frames_dir/%d.png -c:v libx264 -pix_fmt yuv420p $output_dir/$dest_name.mp4

# create a 24fps gif at _half_ the source resolution
ffmpeg -nostdin -y -framerate 60 -i $frames_dir/%d.png -vf fps=24,scale=iw/2:-1:flags=lanczos", $output_dir/$dest_name.gif

# (in no way am I claiming to be an expert in video codecs.. those invocations may not be optimal!)

It would make sense to require gifs if the newsletter was sent out via email (that's why I generate both gif and mp4 files), but that doesn't seem to be the case here?

Lastly, I get that mp4 is just a container format, and so there's the question of what codec, is h264 legally okay to use, is it morally okay to encourage use of a patented codec, etc. As far as I understand, it is at least royalty-free to distribute free h264-encoded videos.

And if the moral angle is a concern, I'd also be totally fine with allowing webm videos (or animated webp images!), but as of earlier this year, (at least some) iOS web browsers couldn't play the webm movies I was encoding.

caspark avatar May 30 '24 04:05 caspark