# Should Discourse convert GIFs to mp4 video files?

**URL:** https://meta.discourse.org/t/should-discourse-convert-gifs-to-mp4-video-files/16739
**Category:** Feature
**Created:** [June 21, 2014, 8:24am UTC](https://meta.discourse.org/t/should-discourse-convert-gifs-to-mp4-video-files/16739 "2014-06-21T08:24:22Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![erlend\_sh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/erlend_sh/32/119475_2.png) [@erlend\_sh](https://meta.discourse.org/u/erlend_sh)
#### Post date: [June 21, 2014, 8:24am UTC](https://meta.discourse.org/t/should-discourse-convert-gifs-to-mp4-video-files/16739/1 "2014-06-21T08:24:22Z")

</div>

Just read about this neat trick that Twitter is doing with GIFs:

[http://blog.embed.ly/post/89265229166/what-twitter-isnt-telling-you-about-gifs](http://blog.embed.ly/post/89265229166/what-twitter-isnt-telling-you-about-gifs)

Perhaps this is something Discourse would like to mimic in the future.

And for the watercooler: If a video format does everything GIF does and more, and with better compression, are the days of the GIF numbered?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [June 22, 2014, 8:13am UTC](https://meta.discourse.org/t/should-discourse-convert-gifs-to-mp4-video-files/16739/3 "2014-06-22T08:13:46Z")

</div>

[http://gfycat.com](http://gfycat.com) also does this.

Live example with both formats automatically offered

[http://gfycat.com/HonorableAdolescentFowl](http://gfycat.com/HonorableAdolescentFowl)

```
Gif Size: 13M
Gfy Size: 2M
Compression: 2.7 to 1 (Bandwidth saved: 17G)
Views: 2082
Original: Video
Reddit comments: /r/battlefield_4

```

---

<div class="post-metadata">

### Author: ![erlend\_sh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/erlend_sh/32/119475_2.png) [@erlend\_sh](https://meta.discourse.org/u/erlend_sh)
#### Post date: [June 22, 2014, 9:58am UTC](https://meta.discourse.org/t/should-discourse-convert-gifs-to-mp4-video-files/16739/4 "2014-06-22T09:58:58Z")

</div>

Yep, it seems to have built up a fair bit of traction, mostly thanks to the Reddit crowd. There’s an [API of sorts](http://gfycat.com/api) too. If Discourse did its automatic grab-the-file-and-self-host-it I suppose this might work in the short term.

I really think this kind of workaround [ought to be open source](http://www.reddit.com/r/gfycat/comments/1z9d8e/gfycat_open_source/) though. A lot of articles I’ve read describe Gfy as a new format, which is very misleading. There’s only one way to make a “Gfy”, and that’s through [Gfycat.com](http://Gfycat.com). Gfy is a service.

---

<div class="post-metadata">

### Author: ![lidel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lidel/32/115991_2.png) [@lidel](https://meta.discourse.org/u/lidel)
#### Post date: [September 1, 2014, 10:28pm UTC](https://meta.discourse.org/t/should-discourse-convert-gifs-to-mp4-video-files/16739/5 "2014-09-01T22:28:15Z")

</div>

Some communities would benefit from such functionality.  
Especially ones with _download remote images to local_ setting enabled 😛, but faster page loads alone is a good reason to think about it.

Quick hack would be to just use [gfycat.com API](http://gfycat.com/api).  
Assuming one does not mirror remote images, I think it is achievable even with pure Javascript which you can add via `/admin/customize/css_html`. Lets say JS iterates over posts and if it finds .gif image. HTTP GET is performed:  
[`http://upload.gfycat.com/transcode?fetchUrl=i.imgur.com/jGMtJIb.gif`](http://upload.gfycat.com/transcode?fetchUrl=i.imgur.com/jGMtJIb.gif)  
It downloads&converts remote image (if not already present) and returns JSON with video details. At this point you replace .gif with video in post (see section [“How can I embed these or link to them?”](http://www.gfycat.com/about))  
Custom plugin which bakes .webm into posts via background job would be of course more elegant.

Anyway,  
I don’t think they (gfycat) do anything magical beside handling hight traffic quite well.  
We can replicate functionality with [`ffmpeg`](https://www.ffmpeg.org/) alone (see [4chan’s guide to converting GIF to WebM](https://gist.github.com/ndarville/10010916)).

If we plan to self-host `.webm` it would be just an extension to already existing _download remote images to local_ feature. We would have an additional setting _replace .gifs with optimized .webm versions_ (we could add another setting: _convert only .gifs bigger than.._).

Such native functionality requires `ffmpeg` as a dependency and comes with additional [security risks](https://www.ffmpeg.org/security.html).  
It does not sound like a good default for Discourse: maybe it is possible to create it as a plugin?

---

<div class="post-metadata">

### Author: ![lidel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lidel/32/115991_2.png) [@lidel](https://meta.discourse.org/u/lidel)
#### Post date: [October 9, 2014, 5:17pm UTC](https://meta.discourse.org/t/should-discourse-convert-gifs-to-mp4-video-files/16739/6 "2014-10-09T17:17:05Z")

</div>

A related development, [Imgur is introducing GIFV](https://imgur.com/blog/2014/10/09/introducing-gifv/):

> The cornerstone of Project GIFV is a platform-wide upgrade to automatically convert uploaded GIF files on the fly into the MP4 video format. [..]

> The .GIFV Extension: With all these improvements, Imgur will now denote converted MP4s with a “.gifv” extension. The intention is to signal to users throughout the Internet that these links will feature a GIF experience that incorporates all the current and future enhancements made through Project GIFV. **Imgur plans to submit an accompanying specification to relevant standards organizations before the end of the year.**

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [October 10, 2014, 9:25pm UTC](https://meta.discourse.org/t/should-discourse-convert-gifs-to-mp4-video-files/16739/7 "2014-10-10T21:25:44Z")

</div>

The “gifv” “files” are actually just a HTML page that runs some Javascript to pick the GIF or MP4 file.

---

<div class="post-metadata">

### Author: ![lidel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lidel/32/115991_2.png) [@lidel](https://meta.discourse.org/u/lidel)
#### Post date: [October 10, 2014, 10:11pm UTC](https://meta.discourse.org/t/should-discourse-convert-gifs-to-mp4-video-files/16739/8 "2014-10-10T22:11:06Z")

</div>

Exactly! 😸  
Discourse already has onebox for MP4 files.  
So the only missing piece is some kind of a sidekick job that does the conversion and slight modification to the onebox to loop by default (if mp4 was created from gif).

---

<div class="post-metadata">

### Author: ![Webinsane](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/webinsane/32/160268_2.png) [@Webinsane](https://meta.discourse.org/u/Webinsane)
#### Post date: [October 10, 2014, 11:43pm UTC](https://meta.discourse.org/t/should-discourse-convert-gifs-to-mp4-video-files/16739/11 "2014-10-10T23:43:29Z")

</div>

You can do `view video` and share the gifv link, but you can’t save it. Facebook is embedding givf files nicely.

The problems I have read so far is poor display on some devices. Plus comment about this case:

![](https://global.discourse-cdn.com/meta/original/3X/a/f/af3fa56e1b7ebf072cc7e04447d1a4791896a86f.gif)

[https://i.imgur.com/SgCycAt.mp4](https://i.imgur.com/SgCycAt.mp4)

---

<div class="post-metadata">

### Author: ![JP\_](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jp_/32/115401_2.png) [@JP\_](https://meta.discourse.org/u/JP_)
#### Post date: [January 17, 2015, 6:20pm UTC](https://meta.discourse.org/t/should-discourse-convert-gifs-to-mp4-video-files/16739/12 "2015-01-17T18:20:14Z")

</div>

If you upload to gfycat, you can actually get an .mp4 link that discourse will show inline 😄

[removed broken link]

edit: hmm, this mp4 stopped working for me, but if I open in incognito or restart chrome it works again – not sure what’s up.

---

<div class="post-metadata">

### Author: ![lidel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lidel/32/115991_2.png) [@lidel](https://meta.discourse.org/u/lidel)
#### Post date: [January 17, 2015, 6:39pm UTC](https://meta.discourse.org/t/should-discourse-convert-gifs-to-mp4-video-files/16739/13 "2015-01-17T18:39:06Z")

</div>

It works for imgur.  
For example something like `https://i.imgur.com/mYNXTPw.gif` can be requested as `https://i.imgur.com/mYNXTPw.webm` which gives:

[https://i.imgur.com/mYNXTPw.webm](https://i.imgur.com/mYNXTPw.webm)

It would be nice if Discourse detected .gif URLs from common providers such as imgur/gfycat  
and just replaced image with _looped_ video (already provided by site), as it saves a lot of bandwidth.

---

<div class="post-metadata">

### Author: ![lightyear](https://avatars.discourse-cdn.com/v4/letter/l/848f3c/32.png) [@lightyear](https://meta.discourse.org/u/lightyear)
#### Post date: [January 17, 2015, 7:30pm UTC](https://meta.discourse.org/t/should-discourse-convert-gifs-to-mp4-video-files/16739/14 "2015-01-17T19:30:22Z")

</div>

> [@lidel](#):
>
> It would be nice if Discourse detected .gif URLs from common providers such as imgur/gfycat and just replaced image with looped video (already provided by site), as it saves a lot of bandwidth.

That sounds like something that could easily be done using the onebox, adding a white list either in the [image](https://github.com/discourse/onebox/blob/master/lib/onebox/engine/image_onebox.rb) or [video](https://github.com/discourse/onebox/blob/master/lib/onebox/engine/video_onebox.rb) engine. I am happy to build that, if such a PR is wanted (could also be behind a configuration setting, if needed).

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [January 17, 2015, 9:23pm UTC](https://meta.discourse.org/t/should-discourse-convert-gifs-to-mp4-video-files/16739/15 "2015-01-17T21:23:21Z")

</div>

I am fine with special MP4 handling onebox for these services that specialize in it.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [March 11, 2015, 7:01am UTC](https://meta.discourse.org/t/should-discourse-convert-gifs-to-mp4-video-files/16739/16 "2015-03-11T07:01:27Z")

</div>

A quick update,

Chrome does a terrible job with huge gif files, they can choke the web browser and cause all sorts of nasties not to mention mobile paying a hefty price on traffic and blowing data plans.

Gifv technique championed by imgur is good

`https://i.imgur.com/zvATqgs.gifv`

```plaintext
<video id="video" autoplay="autoplay" muted="muted" preload="auto" loop="loop" poster="//i.imgur.com/zvATqgsh.jpg">
        
     <source src="//i.imgur.com/zvATqgs.webm" type="video/webm">
     <source src="//i.imgur.com/zvATqgs.mp4" type="video/mp4">
     
     <object type="application/x-shockwave-flash" height="370" width="660" data="//s.imgur.com/include/flash/gifplayer.swf?imgur_video=//i.imgur.com/zvATqgs.mp4&amp;imgur_width=660&amp;imgur_height=370&amp;imgur_url=//imgur.com/zvATqgs">
         <param name="movie" value="//s.imgur.com/include/flash/gifplayer.swf?imgur_video=//i.imgur.com/zvATqgs.mp4&amp;imgur_width=660&amp;imgur_height=370&amp;imgur_url=//imgur.com/zvATqgs">
         <param name="allowscriptaccess" value="never">
         <param name="flashvars" value="height=370&amp;width=660">
         <param name="width" value="370">
         <param name="height" value="660">
         <param name="version" value="0">
         <param name="scale" value="scale">
         <param name="salign" value="tl">
         <param name="wmode" value="opaque">
     </object>
 </video>

```

It’s really just a video element with a bunch of fallbacks.

I see a few actionable things we can do here:

1. If people hotlink anything larger than say 10mb force a “click” to actually download the image and hide it behind a preview

2. get ffmpeg into our base image and do the webm and mp4 conversion for all animated gifs, don’t worry about the flash fallback.

3. Offer an integration piece with imgur that uses imgur to do this … any gif larger than X gets sent to imgur for recompression. (or use a different service)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [March 11, 2015, 7:20am UTC](https://meta.discourse.org/t/should-discourse-convert-gifs-to-mp4-video-files/16739/17 "2015-03-11T07:20:16Z")

</div>

Another huge advantage is that you get no auto play on mobile with the technique above

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [March 11, 2015, 8:56pm UTC](https://meta.discourse.org/t/should-discourse-convert-gifs-to-mp4-video-files/16739/18 "2015-03-11T20:56:17Z")

</div>

One thing to consider is how Slack deals with this:

> `http://img0.joyreactor.cc/pics/post/%D0%B3%D0%B8%D1%84%D0%BA%D0%B8-superjail-%D0%BC%D1%83%D0%BB%D1%8C%D1%82%D1%81%D0%B5%D1%80%D0%B8%D0%B0%D0%BB-%D0%A1%D0%B2%D0%BE%D1%8F-%D0%B0%D1%82%D0%BC%D0%BE%D1%81%D1%84%D0%B5%D1%80%D0%B0-1886210.gif` (Not automatically expanded because 30MB is too large. You can [expand it anyway](http://example.com) or [open it in a new window](http://example.com). You can also [change your preferences](http://example.com) to allow images of any file size to auto expand.)

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [November 6, 2018, 2:36am UTC](https://meta.discourse.org/t/should-discourse-convert-gifs-to-mp4-video-files/16739/19 "2018-11-06T02:36:32Z")

</div>

We do handle enormo gif links now in a sane way. One thing we don’t yet offer is the “expand it anyway” option 🤔

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [July 24, 2020, 11:08pm UTC](https://meta.discourse.org/t/should-discourse-convert-gifs-to-mp4-video-files/16739/21 "2020-07-24T23:08:57Z")

</div>

Just created [Discourse Gifs component](https://meta.discourse.org/t/discourse-gifs-component/158738) which uses the technique

> [@sam](#):
>
> It’s really just a video element with a bunch of fallbacks.

---

<div class="post-metadata">

### Author: ![Tris20](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tris20/32/264639_2.png) [@Tris20](https://meta.discourse.org/u/Tris20)
#### Post date: [November 3, 2021, 11:40am UTC](https://meta.discourse.org/t/should-discourse-convert-gifs-to-mp4-video-files/16739/22 "2021-11-03T11:40:31Z")

</div>

Did this ever see the light of day? I see

- a plugin from 4 years ago: [discourse-gif-to-mp4/plugin.rb at master · nbianca/discourse-gif-to-mp4 · GitHub](https://github.com/nbianca/discourse-gif-to-mp4/blob/master/plugin.rb)
- a few topics for example: [Discourse Gifs - #175 by Zup](https://meta.discourse.org/t/discourse-gifs-component/158738/175)

But neither of these make clear if the solution was implemented.

The reason I ask is that, unless I am mistaken, lightboxing does not appear compatible for gifs. By this I mean, I cannot click a gif and go fullscreen. When the gif contains detailed text, the user cannot zoom in without opening the image in another tab.

However, if the gif converts to an mp4 when uploaded, then we benefit from the fullscreen functionality of the existing video player, as well as the time bar – massive benefits when you are watching a short tutorial clip!

Is this conversion possibility already avaiable? I searched also “gif” in the settings and found

 ![image](https://global.discourse-cdn.com/meta/original/3X/0/7/07a0e445077c183de0eedc0dfa79890df89dde81.png)

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [November 14, 2021, 5:56am UTC](https://meta.discourse.org/t/should-discourse-convert-gifs-to-mp4-video-files/16739/23 "2021-11-14T05:56:48Z")

</div>

> [@Tris20](#):
>
> By this I mean, I cannot click a gif and go fullscreen

This is like saying “I should be able to click any image and have it go fullscreen” which doesn’t make a whole lot of sense to me? 😖

---

<div class="post-metadata">

### Author: ![Tris20](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tris20/32/264639_2.png) [@Tris20](https://meta.discourse.org/u/Tris20)
#### Post date: [November 16, 2021, 9:30am UTC](https://meta.discourse.org/t/should-discourse-convert-gifs-to-mp4-video-files/16739/24 "2021-11-16T09:30:58Z")

</div>

When comparing different documentation styles - all text, only video, text + gifs, the text + gifs option was vastly superior. Consequently, we plan on using gifs to demonstrate things in tutorial posts. However, if we can’t go fullscreen, or lightbox the gif, then written text can often be hard to see

![gifstoosmall](https://global.discourse-cdn.com/meta/original/3X/9/c/9cda6ad108a6bdcd39fd452c9e3542cd6dd7dd1c.gif)

And as you see when you hover over, you only get the option to pause

 ![image](https://global.discourse-cdn.com/meta/original/3X/1/5/15faac2e058c27a2a32a4da88c8ebcbff57f0dd6.png)

But what we really need is to be able to make the gif full size. The work around is to right click and open in new tab, which is fine for our more expert users, but the other 90% can’t be expected to adapt to that. So either we need a way to have uploaded gifs use lightboxing so they go full size when clicked, or simply converted to mp4s so Discourse provides fullscreen functionality.

Also, the expanded tables functionality is 👌 🤩

[Next page](https://meta.discourse.org/t/should-discourse-convert-gifs-to-mp4-video-files/16739.md?page=2)
