Created
April 5, 2016 12:58
-
-
Save ingramchen/e2af352bf8b40bb88890fba4f47eccd0 to your computer and use it in GitHub Desktop.
ffmpeg convert gif to mp4, for best cross browser compatibility
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Full command line options | |
``` | |
ffmpeg -f gif -i FOO.gif -pix_fmt yuv420p -c:v libx264 -movflags +faststart -filter:v crop='floor(in_w/2)*2:floor(in_h/2)*2' BAR.mp4 | |
``` | |
### Notie | |
* output mp4 is encoded with h264, support Firefox/Chrome/Safari in Windows, Mac OSX, Android, and iOS. | |
* one mp4 file for all platforms, there is no need to encode an extra `webm` movie, which encoding speed is pretty slow. | |
* format as `yuv420p` for Firefox compatibility, the downside is color becomes less-saturate than original gif. | |
* yuv420p only support even width/height, so crop filter is required | |
* `-movflags +faststart` flags are optimized for online view in browser | |
* compression ratio typically 10:1, pretty awesome. note that if original gif is < 512KB, convert as mp4 is less efficient. | |
### Obtain static binary ffmpeg | |
* http://johnvansickle.com/ffmpeg/ | |
Thanks for this 👍 .
Btw what does
:v
means in:
-c:v libx264
and-filter:v crop='floor(in_w/2)*2:floor(in_h/2)*2'
?
:v
apply to video stream. :a
is for audio
Thanks for this +1 .
Btw what does:v
means in:
-c:v libx264
and-filter:v crop='floor(in_w/2)*2:floor(in_h/2)*2'
?
:v
apply to video stream.:a
is for audio
Thx @ingram90
Thx! You save my time 👍
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this 👍 .
Btw what does
:v
means in:-c:v libx264
and-filter:v crop='floor(in_w/2)*2:floor(in_h/2)*2'
?