djcas9 / komanda

The IRC Client For Developers
http://komanda.io
MIT License
1.78k stars 75 forks source link

Gifv support, allow for video display toggle #236

Closed qqndrew closed 9 years ago

qqndrew commented 9 years ago

Video display toggle

600x400 (at maximum size) is a very large amount of valuable screen real estate, not to mention people with less modern computers might not wish to have images displayed immediately. As such, this PR will introduce a toggle button akin to that used to handle gists/jsfiddle.

A screenshot of the end result is presented below: ss 2015-05-05 at 08 51 03

Gifv support

Gifv is a file format specific to imgur (details) that is equivalent/converted at runtime by imgur's servers to mp4/webm depending on browser capabilities. Considering its widespread adoption (whereby all gifs uploaded to imgur are converted to gifvs due to superior performance) it makes sense to support this format. Even if support for this format is not desired, some changes ought to be made as at the moment the client processes it as a gif and displays a broken image icon.

Current behaviour Gifv is processed as a gif by image.js (why does the regex not include the $ terminating/empty character as in video.js out of curiousity? This was left unchanged as I was unsure whether this is intended behaviour) which then displays a broken image icon.

Edit: turns out the empty character being removed is intentional, so yeah good thing I left that there

Implementation In the case of Komanda, it suffices to simply replace the gifv extension with webm (which imgur guarantees will be present) and process it as normal via adding it to video.js

xqwzts commented 9 years ago

Thanks for the work!

I'd be hesitant to automatically replace gifv with webm, the guarantee of a webm alternative only exists on Imgur and would break if the gifv were hosted elsewhere [or if Imgur decides to stop having webm mirrors].

Thoughts?

qqndrew commented 9 years ago

My justification for this would be that at the moment imgur is the only host/only way to produce gifvs: it is (as of right now anyways) a proprietary format that just happens to be in extremely common use, being as imgur is one of the most prolific/popular image hosting solutions available. With that in mind (and acting under the assumption that gifvs is something we want to support) the following is true:

a. based on my understanding of imgur's specifications for gifv, gifv is simply a webm/mp4 file wrapper (i.e. a div that contains the video element for the webm/mp4) that is determined at runtime/upon request. This can be seen with any direct access to a gifv: for example Here where examination of the actual image/video element indicates that it is either a mp4/webm file depending on what your browser supports.

b. This implicitly means that the webm/mp4 file will always exist (and indeed, the details page for gifv I previously linked indicates as such, as imgur will convert gifs to both), which would justify the rewriting URLs on imgur specifically

c. imgur is the only way in which gifv files can currently be produced, and being as it is more a measure of convenience/linking (since not everything supports webm and/or not everything supports mp4/this is just a wrapper that selects the appropriate media to display based on your user agent (probably)) it is unlikely that gifv will be adopted on a wide scale beyond imgur

Beyond that however, lies the simple point as far as why renaming is necessary implementation wise: a. inherently implies that proper gifv files (and not stuff like a simple webm with a renamed extension) will be incompatible with any currently available html tags, including img and video tags.... this means that without renaming the file extension to direct it to the appropriate media (which in this case would be webm as we are using webkit) it is impossible to display said media. You are correct in that we are NOT accessing the same file, but rather bypassing the wrapper (which is incompatible with html tags to display stuff) and skipping directly to the underlying webm, which we know is compatible.

To accomplish this without any renaming, we would have to use iframes (oh the horror) and it would inherently look ugly because of the additional stuff imgur adds at the bottom of the gifv file (i.e. branding)

Beyond all of this: it makes sense (to me anyways) that a webm/mp4 mirror would always exist: gifv is used to determine which of the two to display at runtime based on browser capabilities, if one/the other were to not exist, we would not be using gifv, we would just be linking to the webm/mp4 file directly.

tyscorp commented 9 years ago

I agree with @andrew2060. I think it is reasonable to assume that there will be an .webm.

@xqwzts if you're still unsure, we could perhaps limit it to imgur.com domains?

xqwzts commented 9 years ago

That's a pretty good explanation @andrew2060, cheers.

@tyscorp: Looks good to merge for me as it is.