subject-f / cubarimoe

GNU Affero General Public License v3.0
60 stars 16 forks source link

Video-based animation ("gifv") support #17

Open 9ary opened 1 year ago

9ary commented 1 year ago

We maintain some automatically generated Cubari sources over at https://github.com/catgirl-v/cubari. One of the sources (ADHDinos, scraped from reddit) contains an animated strip (chapter 70), and as far as I can tell, reddit will only serve video formats. Currently that just shows up as broken. Imgur does this too with its "gifv" (which is just mp4 with a different extension).

Video codecs have been replacing the aging animated GIF format over the past decade because they offer much better compression (higher quality at much lower file sizes). Because we run our scrapers on github actions, we can't really afford to transcode the files on our end.

I don't think Cubari would need to do much to support these besides detect the source format and use a <video> element instead of <img>.

Algoinde commented 1 year ago

@funkyhippo I'm down to push a frontend fix for it (if I can remember how the hell the code works after 2 years), is there anything that needs to happen on the backend for this? In terms of CORS etc

funkyhippo commented 1 year ago

Hmm, good question; possibly!

How do you plan on implementing this? I don't think there's a surefire way for us to know if a media resource is a video without checking the headers, and for that we'll need proper CORS headers to sniff this out.

Algoinde commented 1 year ago

I was thinking a naive extension check, but yeah, headers is the way. Is the proxy able to forward them? It might require Django to append something to the resource url tho, I'm not sure how the reader is supposed to know that otherwise.

funkyhippo commented 1 year ago

Yep, they'll return the headers. You'll have to use /v1/cors/:url though since the image endpoint has a content-type allowlist.

We can maybe check for video headers on the first image load failure?

Algoinde commented 1 year ago

Alright, I see the path to implement this, but in the true spirit of the comic I'll put it off until Wednesday, as there's multiple things that need to be done & tested for this.

9ary commented 1 year ago

Sounds good, thanks for working on this!