# 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:** [2014年六月21日 08:24 UTC](https://meta.discourse.org/t/should-discourse-convert-gifs-to-mp4-video-files/16739 "2014-06-21T08:24:22Z")\
**Posts on this page:** 1\
**Showing post:** 5

<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:** [2014年九月1日 22:28 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?

---

_[View the full topic](https://meta.discourse.org/t/should-discourse-convert-gifs-to-mp4-video-files/16739)._
