Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
Optimize /tools/convert/mp4-to-gif page content and metadata
Richie McIlroyfcd236096ec3
diff --git a/apps/web/__tests__/unit/mp4-to-gif-page.test.ts b/apps/web/__tests__/unit/mp4-to-gif-page.test.tsnew file mode 100644index 000000000..9059c134a--- /dev/null+++ b/apps/web/__tests__/unit/mp4-to-gif-page.test.ts@@ -0,0 +1,186 @@+import { readFileSync } from "node:fs";+import { join } from "node:path";+import { describe, expect, it } from "vitest";+import { createFAQSchema, createHowToSchema } from "@/utils/web-schema";++const pageSource = readFileSync(+ join(process.cwd(), "app/(site)/tools/convert/mp4-to-gif/page.tsx"),+ "utf-8",+);++describe("MP4 to GIF page metadata", () => {+ it("contains canonical URL", () => {+ expect(pageSource).toContain(+ 'canonical: "https://cap.so/tools/convert/mp4-to-gif"',+ );+ });++ it("contains full OG image URL", () => {+ expect(pageSource).toContain('"https://cap.so/og.png"');+ });++ it("contains OG url field", () => {+ expect(pageSource).toContain(+ 'url: "https://cap.so/tools/convert/mp4-to-gif"',+ );+ });++ it("contains OG siteName field", () => {+ expect(pageSource).toContain('siteName: "Cap"');+ });++ it("contains OG locale field", () => {+ expect(pageSource).toContain('locale: "en_US"');+ });+});++describe("MP4 to GIF page structured data", () => {+ it("contains FAQPage JSON-LD", () => {+ expect(pageSource).toContain('"@type": "FAQPage"');+ });++ it("contains HowTo JSON-LD", () => {+ expect(pageSource).toContain('"@type": "HowTo"');+ });++ it("contains at least 6 FAQ questions", () => {+ const matches = pageSource.match(/question:/g);+ expect(matches).not.toBeNull();+ expect(matches?.length).toBeGreaterThanOrEqual(6);+ });++ it("contains HowTo steps", () => {+ expect(pageSource).toContain('"@type": "HowToStep"');+ });+});++describe("MP4 to GIF FAQ schema validity", () => {+ const faqs = [+ {+ question: "How do I convert MP4 to GIF?",+ answer:+ "Open the Cap MP4 to GIF converter, drag and drop your MP4 file (or click to browse), adjust your settings if needed, then click Convert. The entire process runs in your browser — your file never leaves your device. Once complete, download the GIF instantly.",+ },+ {+ question: "Is the MP4 to GIF converter free?",+ answer:+ "Yes, completely free with no limits on the number of conversions. There are no watermarks, no sign-up required, and no hidden fees. The converter runs entirely in your browser at zero cost.",+ },+ {+ question: "What quality settings can I adjust?",+ answer:+ "You can customize the frame rate (5–30 FPS), quality level (1–20, where lower means smaller file size), maximum width (240–1280px), and toggle dithering on or off. Dithering improves color gradients in GIFs at the cost of a larger file size.",+ },+ {+ question: "Will the GIF be smaller than the original MP4?",+ answer:+ "Usually not. GIFs are often larger than MP4 videos because the GIF format supports a limited 256-color palette per frame and lacks modern compression. For smaller file sizes, lower the FPS, reduce the max width, or increase the quality number (which reduces quality but shrinks file size).",+ },+ {+ question: "What frame rate should I use for GIFs?",+ answer:+ "10–15 FPS is the standard for web GIFs and produces smooth-looking animations without excessive file size. For short, action-heavy clips you may want 20–30 FPS. For looping backgrounds or simple animations, 10 FPS or lower is usually sufficient.",+ },+ {+ question: "Is there a file size limit?",+ answer:+ "The converter supports MP4 files up to 500 MB. For smooth in-browser performance, keep source files short (under 30 seconds) since longer videos produce very large GIFs. For longer content, consider exporting a trimmed clip first.",+ },+ {+ question: "Does this converter work on mobile?",+ answer:+ "The converter works best on desktop browsers (Chrome, Edge, Brave). Mobile browser support for the underlying video decoding APIs is still limited, so desktop is recommended for reliable results.",+ },+ {+ question: "Do I need to install any software?",+ answer:+ "No. The converter runs entirely in your browser — no downloads, no plugins, no extensions required. Just open the page and start converting. All processing happens locally on your device for complete privacy.",+ },+ ];++ it("produces valid FAQPage schema with all 8 questions", () => {+ const schema = createFAQSchema(faqs);++ expect(schema["@context"]).toBe("https://schema.org");+ expect(schema["@type"]).toBe("FAQPage");+ expect(schema.mainEntity).toHaveLength(8);+ });++ it("maps each FAQ to a Question entity with acceptedAnswer", () => {+ const schema = createFAQSchema(faqs);++ expect(schema.mainEntity[0]).toEqual({+ "@type": "Question",+ name: "How do I convert MP4 to GIF?",+ acceptedAnswer: {+ "@type": "Answer",+ text: faqs[0].answer,+ },+ });+ });++ it("produces JSON-serializable output", () => {+ const schema = createFAQSchema(faqs);+ expect(() => JSON.stringify(schema)).not.toThrow();+ const parsed = JSON.parse(JSON.stringify(schema));+ expect(parsed["@type"]).toBe("FAQPage");+ expect(parsed.mainEntity).toHaveLength(8);+ });+});++describe("MP4 to GIF HowTo schema validity", () => {+ const howToSteps = [+ {+ name: "Upload your MP4 file",+ text: "Open the Cap MP4 to GIF converter and drag and drop your MP4 file into the upload area, or click to browse your files.",+ },+ {+ name: "Adjust conversion settings",+ text: "Optionally customize the frame rate, quality, maximum width, and dithering to balance GIF quality and file size.",+ },+ {+ name: "Convert and download your GIF",+ text: "Click Convert. The file is processed entirely in your browser — nothing is uploaded to any server. Once done, click Download to save the animated GIF.",+ },+ ];++ it("produces valid HowTo schema with 3 steps", () => {+ const schema = createHowToSchema({+ name: "How to Convert MP4 to GIF Online",+ description:+ "Convert MP4 video files to animated GIF format for free using Cap's browser-based converter. No upload required.",+ steps: howToSteps,+ });++ expect(schema["@context"]).toBe("https://schema.org");+ expect(schema["@type"]).toBe("HowTo");+ expect(schema.step).toHaveLength(3);+ });++ it("assigns correct positions to each step", () => {+ const schema = createHowToSchema({+ name: "How to Convert MP4 to GIF Online",+ description: "Convert MP4 to animated GIF in your browser.",+ steps: howToSteps,+ });++ expect(schema.step[0].position).toBe(1);+ expect(schema.step[0].name).toBe("Upload your MP4 file");+ expect(schema.step[1].position).toBe(2);+ expect(schema.step[2].position).toBe(3);+ expect(schema.step[2].name).toBe("Convert and download your GIF");+ });++ it("produces JSON-serializable output", () => {+ const schema = createHowToSchema({+ name: "How to Convert MP4 to GIF Online",+ description: "Convert MP4 to animated GIF in your browser.",+ steps: howToSteps,+ });++ expect(() => JSON.stringify(schema)).not.toThrow();+ const parsed = JSON.parse(JSON.stringify(schema));+ expect(parsed["@type"]).toBe("HowTo");+ expect(parsed.step).toHaveLength(3);+ });+});diff --git a/apps/web/app/(site)/tools/convert/mp4-to-gif/page.tsx b/apps/web/app/(site)/tools/convert/mp4-to-gif/page.tsxindex e12433761..3eb4b2e67 100644--- a/apps/web/app/(site)/tools/convert/mp4-to-gif/page.tsx+++ b/apps/web/app/(site)/tools/convert/mp4-to-gif/page.tsx@@ -4,90 +4,196 @@ import { ToolsPageTemplate } from "@/components/tools/ToolsPageTemplate";import type { ToolPageContent } from "@/components/tools/types";export const metadata: Metadata = {- title: "MP4 to GIF Converter | Free Online Animated GIF Maker | Cap",+ title: "MP4 to GIF Converter — Free Online Animated GIF Maker | Cap",description:- "Convert MP4 videos to animated GIF images directly in your browser. Create high-quality GIFs with our free online converter, no uploads needed.",+ "Convert MP4 videos to animated GIF images directly in your browser. Free, private, no upload needed. Adjust FPS, quality, and dimensions for the perfect GIF.",openGraph: {- title: "MP4 to GIF Converter | Free Online Animated GIF Maker",+ title: "MP4 to GIF Converter — Free Online Animated GIF Maker | Cap",description:- "Convert MP4 videos to animated GIF images directly in your browser. No uploads required, processing happens locally for maximum privacy.",+ "Convert MP4 to animated GIF directly in your browser. No uploads, no installs, 100% private. Customize FPS, quality, and size.",+ url: "https://cap.so/tools/convert/mp4-to-gif",+ siteName: "Cap",images: [{- url: "/og.png",+ url: "https://cap.so/og.png",width: 1200,height: 630,- alt: "Cap MP4 to GIF Converter Tool",+ alt: "Cap MP4 to GIF Converter — Free Online Animated GIF Maker",},],+ locale: "en_US",+ type: "website",},twitter: {card: "summary_large_image",- title: "MP4 to GIF Converter | Free Online Animated GIF Maker",+ title: "MP4 to GIF Converter — Free Online Animated GIF Maker | Cap",description:- "Convert MP4 videos to animated GIF images directly in your browser. No uploads required, maximum privacy.",- images: ["/og.png"],+ "Convert MP4 to animated GIF directly in your browser. No uploads, no installs, 100% private.",+ images: ["https://cap.so/og.png"],},alternates: {canonical: "https://cap.so/tools/convert/mp4-to-gif",},};+const faqs = [+ {+ question: "How do I convert MP4 to GIF?",+ answer:+ "Open the Cap MP4 to GIF converter, drag and drop your MP4 file (or click to browse), adjust your settings if needed, then click Convert. The entire process runs in your browser — your file never leaves your device. Once complete, download the GIF instantly.",+ },+ {+ question: "Is the MP4 to GIF converter free?",+ answer:+ "Yes, completely free with no limits on the number of conversions. There are no watermarks, no sign-up required, and no hidden fees. The converter runs entirely in your browser at zero cost.",+ },+ {+ question: "What quality settings can I adjust?",+ answer:+ "You can customize the frame rate (5–30 FPS), quality level (1–20, where lower means smaller file size), maximum width (240–1280px), and toggle dithering on or off. Dithering improves color gradients in GIFs at the cost of a larger file size.",+ },+ {+ question: "Will the GIF be smaller than the original MP4?",+ answer:+ "Usually not. GIFs are often larger than MP4 videos because the GIF format supports a limited 256-color palette per frame and lacks modern compression. For smaller file sizes, lower the FPS, reduce the max width, or increase the quality number (which reduces quality but shrinks file size).",+ },+ {+ question: "What frame rate should I use for GIFs?",+ answer:+ "10–15 FPS is the standard for web GIFs and produces smooth-looking animations without excessive file size. For short, action-heavy clips you may want 20–30 FPS. For looping backgrounds or simple animations, 10 FPS or lower is usually sufficient.",+ },+ {+ question: "Is there a file size limit?",+ answer:+ "The converter supports MP4 files up to 500 MB. For smooth in-browser performance, keep source files short (under 30 seconds) since longer videos produce very large GIFs. For longer content, consider exporting a trimmed clip first.",+ },+ {+ question: "Does this converter work on mobile?",+ answer:+ "The converter works best on desktop browsers (Chrome, Edge, Brave). Mobile browser support for the underlying video decoding APIs is still limited, so desktop is recommended for reliable results.",+ },+ {+ question: "Do I need to install any software?",+ answer:+ "No. The converter runs entirely in your browser — no downloads, no plugins, no extensions required. Just open the page and start converting. All processing happens locally on your device for complete privacy.",+ },+];++const howToSteps = [+ {+ name: "Upload your MP4 file",+ text: "Open the Cap MP4 to GIF converter and drag and drop your MP4 file into the upload area, or click to browse your files.",+ },+ {+ name: "Adjust conversion settings",+ text: "Optionally customize the frame rate, quality, maximum width, and dithering to balance GIF quality and file size.",+ },+ {+ name: "Convert and download your GIF",+ text: "Click Convert. The file is processed entirely in your browser — nothing is uploaded to any server. Once done, click Download to save the animated GIF.",+ },+];++const faqStructuredData = {+ "@context": "https://schema.org",+ "@type": "FAQPage",+ mainEntity: faqs.map((faq) => ({+ "@type": "Question",+ name: faq.question,+ acceptedAnswer: {+ "@type": "Answer",+ text: faq.answer,+ },+ })),+};++const howToStructuredData = {+ "@context": "https://schema.org",+ "@type": "HowTo",+ name: "How to Convert MP4 to GIF Online",+ description:+ "Convert MP4 video files to animated GIF format for free using Cap's browser-based converter. No upload required.",+ step: howToSteps.map((step, index) => ({+ "@type": "HowToStep",+ position: index + 1,+ name: step.name,+ text: step.text,+ })),+ tool: {+ "@type": "HowToTool",+ name: "A modern web browser (Chrome, Edge, or Brave recommended)",+ },+};+export default function MP4ToGIFPage() {const pageContent: ToolPageContent = {title: "MP4 to GIF Converter",description:- "Convert MP4 videos to animated GIF images directly in your browser",- featuresTitle: "Features",+ "Convert MP4 videos to animated GIF images directly in your browser — free, private, and no installation required",+ featuresTitle: "Why Use This MP4 to GIF Converter",featuresDescription:- "Our free online converter offers several advantages over other conversion services:",+ "A fast, free, and private way to turn MP4 videos into animated GIFs — entirely in your browser with full control over output settings.",features: [{- title: "100% Private",+ title: "100% Browser-Based",description:- "Your files never leave your device. All processing happens right in your browser.",+ "The entire conversion runs locally in your browser. No server uploads, no waiting for processing queues — your files stay on your device at all times.",},{- title: "No Installation Required",+ title: "Customizable Output Settings",description:- "No need to download or install any software. Just open the page and start converting.",+ "Control frame rate (5–30 FPS), quality (1–20), max width (240–1280px), and dithering to fine-tune the balance between GIF quality and file size.",},{- title: "High Quality Conversion",+ title: "Complete Privacy",description:- "We use Remotion technology to create optimized GIFs from your videos.",+ "Your video files never leave your device. Unlike other online converters that upload your content to remote servers, all processing happens client-side.",},- ],- faqs: [{- question: "How does the MP4 to GIF converter work?",- answer:- "Our converter uses Remotion (remotion.dev) directly in your browser. When you upload an MP4 file, it gets processed locally on your device and converted to an animated GIF without ever being sent to a server.",+ title: "No Sign-Up or Installation",+ description:+ "No software downloads, browser extensions, or accounts required. Just open the page and start converting — works instantly in Chrome, Edge, and Brave.",},{- question: "Is there a file size limit?",- answer:- "Yes, currently we limit file sizes to 500MB to ensure smooth performance in the browser. For larger files, you might need to use a desktop application.",+ title: "Unlimited Free Conversions",+ description:+ "Convert as many MP4 files to GIF as you need with no daily limits, no watermarks, and no hidden fees.",},{- question: "What quality settings are used for the GIF?",- answer:- "We use optimal settings for web-friendly GIFs with a frame rate of 10 FPS and appropriate resizing to balance quality and file size.",+ title: "Handles Any MP4 Content",+ description:+ "Works with screen recordings, gameplay clips, product demos, tutorials, and any other MP4 video. Supports H.264 and other common codecs.",},],+ faqs,cta: {title: "Cap is the open source Loom alternative",description:- "Record, edit, and share video messages with Cap. 100% open source and privacy focused.",+ "Record, edit, and share video messages with Cap. 100% open source and privacy focused. Export directly to MP4 — no conversion needed.",buttonText: "Download Cap Free",},};return (- <ToolsPageTemplate- content={pageContent}- toolComponent={- <MediaFormatConverter initialConversionPath="mp4-to-gif" />- }- />+ <>+ <script+ type="application/ld+json"+ dangerouslySetInnerHTML={{+ __html: JSON.stringify(faqStructuredData),+ }}+ />+ <script+ type="application/ld+json"+ dangerouslySetInnerHTML={{+ __html: JSON.stringify(howToStructuredData),+ }}+ />+ <ToolsPageTemplate+ content={pageContent}+ toolComponent={+ <MediaFormatConverter initialConversionPath="mp4-to-gif" />+ }+ />+ </>);}