Hacker News new | ask | show | jobs
by Raphmedia 2506 days ago
Why use a chart? It's what, four questions?

Is it a vector image? -> Use .svg

Is it an illustration (bitmap) with transparency (i.e. a cutout of a man) -> Use .png

Is it animated? -> Use .mp4 and fallback to .gif

Is it a photo? -> Use .jpg and compress as much as possible

3 comments

Oh yes. Especially, never ever loose vector information if available. Vectors can scale. Bitmaps cannot. The chart gets this plain wrong.
mp4 with fallback to gif doesn't make much sense. More appropriate would be webm, or in the future AV1 with a fallback of h264 mp4 for video or high quality animated images. Using gif for small animations is fine, especially if you have transparency.
mp4 is for efficiency, gif is for compatibility.

if an mp4 doesn't play, a webm probably won't play either.

you can do mp4 -> webm -> gif if needed, but that's extra encoding that probably isn't needed.

Won't webm be more efficient than h264? (I'm assuming by mp4 you mean h264).

So you'd want to do webm → mp4/h264 → gif.

(I agree this isn't worth the time to set up in most cases)

You're right, you would try WebM first. Like I said I'm not sure why you'd do both. Anything that plays VP8/9 should play h.264.
WebM will play in cases where MP4/h264 won't play due to missing patent-encumbered codecs.
That's not a big real world issue though, but yeah if you want to provide 100% compatibility it would help a little. It's hard to justify the extra (less efficient & slower) encoding to support those few edge cases.

h.264 gives you good performance, hardware encoders/decoders, best compatibility. Most of the time just using it alone is the best value.

All that depends on how many videos you need to transcode though. If you just have a few, do all the main codecs.

gif supports transparency, mp4 doesn't.