Hacker News new | ask | show | jobs
by Uncorrelated 594 days ago
Articles about the merits of JPEG XL come up with some regularity on Hacker News, as if to ask, "why aren't we all using this yet?"

This one has a section on animation and cinemagraphs, saying that video formats like AV1 and HEVC are better suited, which makes sense. Here's my somewhat off-topic question: is there a video format that requires support for looping, like GIFs? GIF is a pretty shoddy format for video compared to a modern video codec, but if a GIF loops, you can expect it to loop seamlessly in any decent viewer.

With videos it seems you have to hope that the video player has an option to loop, and oftentimes there's a brief delay at the end of the video before playback resumes at the beginning. It would be nice if there were a video format that included seamless looping as part of the spec -- but as far as I can tell, there isn't one. Why not? Is it just assumed that anyone who wants looping video will configure their player to do it?

4 comments

Besides looping, video players also deal kinda badly with low-framerate videos. Meanwhile, (AFAIK) GIFs can have arbitrary frame durations and it generally works fine.
> GIFs can have arbitrary frame durations and it generally works fine.

But we shouldn't be using animated GIFs in 2024.

The valid replacement for the animated GIF is an animated lossless compressed WebP. File sizes are are much more controlled and there is no generational loss when it propagates the internets as viral loop (if we all settled on it and did not recompress it in a lossy format).

Most modern video container formats support arbitrary frame durations, using a 'presentation timestamp' on each frame. After all, loads of things these days use streaming video, where you need to handle dropped frames gracefully.

Of course, not every video player supports them well. Which is kinda understandable, I can see how expecting 30 frames per second from a 30fps video would make things a lot simpler, and work right 99.9% of the time.

> With videos it seems you have to hope that the video player has an option to loop

<video playsinline muted loop> should be nearly as reliable as a GIF in that regard.

The one exception that I've found is that some devices will prevent videos from autoplaying if the user has their battery-saver on, leading to some frustrating bug reports.

How does GIF require support for looping as opposed to it being just a player implementation no different from any other format?
GIF format includes a flag inside it to indicate how many times (or forever) to loop the video.

HEVC does not have such a flag. Quite unfortunate

Interesting, it seems like this isn't part of the spec per wiki:

> Most browsers now recognize and support NAB, though it is not strictly part of the GIF89a specification.

So I guess the players for the new video codecs could do something similar and agree on some metadata to be used for the same purpose?

> Most browsers now recognize and support NAB

The “NAB” was introduced in Netscape Navigator 2.0, 50 million years ago.

The phrasing with “most browsers” and “now” is a bit weird, on part of whoever wrote that part of the Wikipedia article.

Every major browser that I know of has supported animated gifs since forever.

Any browser that doesn’t is probably either a non-graphical browser in the first place, or one that has like five people using it.

You're doing a similar phrasing weirdnesd as the wiki

> Every major browser

There are only 2 major ones

And this brings us back to the main point - this is no "format" issue, Chrome could just as well support some metadata field as "loop for n" for the newer video files, and the situation would be the same as with NAB when Safari adds it.

There are two major browser engine lineages but at least four of 'major' browsers (>5% market share) and a number of minor browsers.
The same thing stood out to me. With the popularity of animated GIFs, it's disappointing and ridiculous for a new Web-friendly image format to omit at least a simple multi-image/looping facility.

As for your question about video looping: Nothing prevents that, although I don't know of a container format that has a flag to indicate that it should be looped. Players could eliminate the delay on looping by caching the first few frames.