1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._posthogChunkIds=e._posthogChunkIds||{},e._posthogChunkIds[n]="01a0f726-7ddf-75e1-8659-bdb308577a85")}catch(e){}}();import{u as O,d as B,r as s,j as t,o as H,B as y,U as $}from"./index-DCg2N-ax.js";import{T as q}from"./tool-page-xyzZDU_k.js";import{s as A,e as L}from"./browser-mp4-nLMI-1Bj.js";import{F as _}from"./film-C8237YWC.js";import{D as W}from"./download-C-n2vFkf.js";const j=15,C=300,P=1280;function K(){const{logEvent:G}=O();B();const x=s.useRef(null),[d,N]=s.useState(null),[u,S]=s.useState(""),[n,I]=s.useState({width:0,height:0,frames:0}),[c,b]=s.useState(!1),[F,p]=s.useState(0),[h,w]=s.useState(""),[k,E]=s.useState(0),[g,l]=s.useState(""),T=async e=>{l(""),w(""),N(e),u&&URL.revokeObjectURL(u),S(URL.createObjectURL(e));try{const r=window.ImageDecoder;if(!r)throw new Error("Animated GIF decoding needs a current version of Chrome or Edge.");const a=new r({data:await e.arrayBuffer(),type:"image/gif"});await a.tracks.ready;const i=a.tracks.selectedTrack;if(!(i!=null&&i.frameCount))throw new Error("No animated frames were found in this GIF.");const m=await a.decode({frameIndex:0,completeFramesOnly:!0}),o=m.image.displayWidth,v=m.image.displayHeight;if(m.image.close(),o>P||v>P)throw new Error("Choose a GIF no larger than 1280 pixels on either side.");I({width:o,height:v,frames:i.frameCount}),i.frameCount>C&&l("Choose a GIF with 300 frames or fewer."),a.close()}catch(r){I({width:0,height:0,frames:0}),l(r instanceof Error?r.message:"Could not read this GIF.")}},D=async()=>{if(!d||!n.frames||c)return;if(!A()||!window.ImageDecoder){l("GIF to MP4 conversion needs a current version of Chrome or Edge.");return}b(!0),l(""),p(0),w("");let e=null;try{const r=window.ImageDecoder;e=new r({data:await d.arrayBuffer(),type:"image/gif"}),await e.tracks.ready;const a=Math.min(e.tracks.selectedTrack.frameCount,C),i=await L({width:n.width,height:n.height,duration:a/j,fps:j,drawFrame:async(o,v,R)=>{const M=await e.decode({frameIndex:Math.min(R,a-1),completeFramesOnly:!0}),f=o.getContext("2d",{alpha:!1});if(!f)throw new Error("canvas");f.fillStyle="#000",f.fillRect(0,0,o.width,o.height),f.drawImage(M.image,0,0,o.width,o.height),M.image.close()}},null,({percent:o})=>p(o)),m=URL.createObjectURL(i);w(m),E(i.size),p(100),G("seo_tool_used",void 0,{slug:"gif-to-mp4-converter",frames:a})}catch(r){l(r instanceof Error?r.message:"Conversion failed. Try a smaller GIF in Chrome or Edge.")}finally{e==null||e.close(),b(!1)}},U=()=>{if(!h||!d)return;const e=document.createElement("a");e.href=h,e.download=`${d.name.replace(/\.[^.]+$/,"")||"animation"}.mp4`,e.click()};return t.jsx("div",{className:"opus-home",style:H,children:t.jsx(q,{slug:"gif-to-mp4-converter",metaTitle:"GIF to MP4 Converter, Free and Private | Viddler",metaDescription:"Convert an animated GIF to H.264 MP4 in your browser. Free, private, no upload, no watermark. Download a video ready to share.",heroTitle:"GIF to MP4 converter",heroSubtitle:"Turn an animated GIF into a shareable H.264 MP4. It runs locally, so your file never leaves your device.",faqs:[{q:"How do I convert a GIF to MP4?",a:"Choose an animated GIF and click Convert to MP4. The tool decodes its frames, encodes them as H.264 video, and gives you an MP4 download."},{q:"Is my GIF uploaded anywhere?",a:"No. The GIF is decoded and converted entirely in your browser. Your file never leaves your computer."},{q:"Why convert GIF to MP4?",a:"MP4 video is often much smaller than an animated GIF and plays more smoothly on websites and social platforms. It also supports better compression and wider playback controls."},{q:"Will the MP4 have audio?",a:"No. GIF files do not contain audio, so the converted MP4 is silent."},{q:"What GIF limits does the converter have?",a:"The GIF can contain up to 300 frames and be no larger than 1280 pixels on either side. These limits keep local conversion fast and prevent the browser tab from running out of memory."}],ctaTitle:"Turn that clip into a clean embed.",ctaSubtitle:"Host the MP4 on Viddler with no ads and per-viewer watch tracking.",children:t.jsxs("div",{className:"space-y-5",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsxs(y,{type:"button",variant:"outline",onClick:()=>{var e;return(e=x.current)==null?void 0:e.click()}
1,disabled:c,children:[t.jsx($,{className:"h-4 w-4 mr-2","aria-hidden":"true"})," Choose GIF"]}),t.jsx("input",{ref:x,type:"file",accept:"image/gif,.gif",className:"hidden",onChange:e=>{var a;const r=(a=e.target.files)==null?void 0:a[0];r&&T(r),e.target.value=""}}),d&&t.jsxs("span",{className:"text-sm text-muted-foreground",children:[d.name,n.frames?` (${n.width}Ã${n.height}, ${n.frames} frames)`:""]})]}),u&&t.jsx("img",{src:u,alt:"Selected animated GIF preview",className:"max-h-64 max-w-full rounded-lg border border-border"}),t.jsxs(y,{type:"button",onClick:D,disabled:!d||!n.frames||c||!!g,children:[t.jsx(_,{className:"h-4 w-4 mr-2","aria-hidden":"true"})," ",c?`Converting ${F}%`:"Convert to MP4"]}),c&&t.jsx("div",{className:"h-2 overflow-hidden rounded-full bg-muted",children:t.jsx("div",{className:"h-full bg-primary transition-[width] duration-200",style:{width:`${F}%`}})}),g&&t.jsx("p",{className:"text-sm text-destructive",role:"alert",children:g}),h&&t.jsxs("div",{className:"border-t border-border pt-5 space-y-3",children:[t.jsx("video",{src:h,controls:!0,autoPlay:!0,loop:!0,muted:!0,playsInline:!0,className:"max-h-64 max-w-full rounded-lg border border-border"}),t.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[t.jsxs(y,{type:"button",onClick:U,children:[t.jsx(W,{className:"h-4 w-4 mr-2","aria-hidden":"true"})," Download MP4"]}),t.jsxs("span",{className:"text-sm text-muted-foreground",children:["H.264 MP4, ",(k/1024/1024).toFixed(2)," MB"]})]})]})]})})})}export{K as default}; 2 3//# chunkId=01a0f726-7ddf-75e1-8659-bdb308577a85
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.