GIF转 MP4格式
在浏览器中安全地将GIF动画转换为MP4 (H.264) 视频文件。不需要上传文件到服务器。
点击或拖拽GIF到这里
最大支持50MB
在浏览器中安全地将GIF动画转换为MP4 (H.264) 视频文件。不需要上传文件到服务器。
最大支持50MB
GIF 是一种 1987 年的图像格式,后来作为网络上默认的循环动画格式获得了第二次生命。 It works, but not efficiently — GIF tops out at 256 colors per frame, uses inefficient LZW compression, and produces files several times larger than equivalent video. 480×270 的 5 秒动画 GIF 通常重 2-4 MB;在相同视觉质量下,等效的 MP4 视频通常为 200-500 KB。对于提供动画内容的网站,从 GIF 切换到 MP4 通常会减少 80% 或更多的带宽。
该转换器使用通过 @ffmpeg/ffmpeg 库编译为 WebAssembly 的 FFmpeg。 FFmpeg 解析 GIF,解码每个帧,并将帧序列重新编码为 MP4 容器中的 H.264 视频。 The conversion happens entirely in your browser — no server upload — but uses several megabytes of WebAssembly code that loads on first use, which means the first conversion takes a moment to initialize.
GIF 的帧时序按照 MP4 允许的那样准确保留。 GIF 支持以 1/100 秒为单位测量的每帧延迟; MP4 将时序表示为帧速率。大多数 GIF 使用恒定或接近恒定的帧延迟,可以干净地转换为固定的视频帧速率。时序高度可变的 GIF 可能会产生某些地方运行速度稍快或稍慢的视频。
带宽是主要原因。 Twitter, Reddit, and many other platforms have been converting user-uploaded GIFs to MP4 internally for years precisely because the size savings are dramatic. If you embed animated content on your own site, switching to MP4 with autoplay-loop-muted attributes produces the same visual experience as a GIF at a fraction of the file size and with smoother playback.
质量也往往会更好。 GIF's 256-color palette per frame produces visible banding on photographic content, while H.264 video preserves smooth gradients with no apparent palette limitation.对于涉及照片、截屏视频或 3D 渲染的动画,无论文件大小如何,MP4 看起来都明显优于 GIF。
放下 GIF,等待 FFmpeg 第一次加载,获取 MP4。
GIF(CompuServe,1987)对索引颜色帧使用 LZW 压缩,每个颜色帧最多 256 种颜色。动画存储为帧序列,每帧延迟以厘米为单位。通过单个透明调色板索引支持透明度;部分透明则不然。
H.264(ITU-T H.264、ISO/IEC 14496-10)使用帧间预测(关键帧加差异)、离散余弦变换以及 CABAC 或 CAVLC 熵编码对视频进行编码。 MP4 容器内运行的 H.264 编解码器受到浏览器、移动设备和视频工具的普遍支持。
@ffmpeg/ffmpeg 是 FFmpeg 编译为 WebAssembly。 WASM 模块有几兆字节,首次使用时会加载;同一会话中的后续转换将重用已加载的模块。在当前浏览器中,编码是单线程的,没有 SharedArrayBuffer,这使得基于 WebAssembly 的编码明显慢于本机 FFmpeg,但对于典型的 GIF 大小来说仍然足够快。