🎥 Make videos programmatically with React
Launch remotion.media/AGENTS.md (#8989)
Jonny Burger01edf88aad2a
diff --git a/packages/docs/docusaurus.config.ts b/packages/docs/docusaurus.config.tsindex ebb862000c..cff590262a 100644--- a/packages/docs/docusaurus.config.ts+++ b/packages/docs/docusaurus.config.ts@@ -99,6 +99,7 @@ const config: Config = {to: '/docs/resources',label: 'Resources',},+ {to: 'https://remotion.media', label: 'Test media'},{to: 'blog', label: 'Blog'},{to: 'showcase', label: 'Showcase'},{to: '/docs/support', label: 'Support'},diff --git a/packages/remotion-media/build.ts b/packages/remotion-media/build.tsindex 3035ca0689..48587c7443 100644--- a/packages/remotion-media/build.ts+++ b/packages/remotion-media/build.ts@@ -1,9 +1,11 @@#!/usr/bin/env bun-import {cpSync, existsSync, readdirSync} from 'fs';-import {rm} from 'fs/promises';-import path from 'path';import {$, build, S3Client, type BuildConfig} from 'bun';import plugin from 'bun-plugin-tailwind';+import {cpSync, existsSync, readdirSync, writeFileSync} from 'fs';+import {rm} from 'fs/promises';+import path from 'path';+import {makeAgentsMarkdown} from './src/agents';+import variants from './variants.json';// Print help text if requestedif (process.argv.includes('--help') || process.argv.includes('-h')) {@@ -205,6 +207,8 @@ for (const file of files) {cpSync(path.join(outdir, file), path.join(filesDir, file));}+writeFileSync(path.join(filesDir, 'AGENTS.md'), makeAgentsMarkdown(variants));+if (!Bun.env.AWS_ACCESS_KEY_ID || !Bun.env.AWS_SECRET_ACCESS_KEY) {console.log('Skipping R2 upload: AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are not set',diff --git a/packages/remotion-media/src/App.tsx b/packages/remotion-media/src/App.tsxindex 07204f0bc2..0eda5bf090 100644--- a/packages/remotion-media/src/App.tsx+++ b/packages/remotion-media/src/App.tsx@@ -1,5 +1,6 @@import React, {useEffect, useState} from 'react';import variants from '../variants.json';+import {getCategoryLabel} from './agents';import './index.css';const CopyLink = ({href}: {readonly href: string}) => {@@ -88,22 +89,6 @@ const VideoVariant = ({);};-const categoryLabelMap: Record<string, string> = {- codecs: 'Codecs',- dimensions: 'Dimensions',- durations: 'Durations',- audio: 'Audio',- fps: 'FPS',- 'sample-rates': 'Sample Rates',- greenscreen: 'Green Screen',- 'edge-cases': 'Edge Cases',- 'sound-effects': 'Sound Effects',- hls: 'HLS',-};--const getCategoryLabel = (category: string) =>- categoryLabelMap[category] ?? category;-const CategoryGroup = ({category,variants: v,@@ -238,6 +223,12 @@ export function App() {Hosted on Cloudflare R2 Free Tier, allowing for theoretically unlimitedbandwidth. <br />Files may be used royalty-free and without attribution.+ <br />+ For agents, use{' '}+ <a href="/AGENTS.md" className="font-brand text-brand hover:underline">+ AGENTS.md+ </a>+ .</p><div className="flex gap-8 items-start"><Sidebardiff --git a/packages/remotion-media/src/agents.ts b/packages/remotion-media/src/agents.tsnew file mode 100644index 0000000000..7e796e06e4--- /dev/null+++ b/packages/remotion-media/src/agents.ts@@ -0,0 +1,100 @@+export type MediaVariant = {+ readonly videoCodec: string;+ readonly audioCodec: string;+ readonly container: string;+ readonly fileNames: readonly string[];+ readonly size: number;+ readonly category: string;+ readonly attribution?: string;+};++const categoryLabelMap: Record<string, string> = {+ codecs: 'Codecs',+ dimensions: 'Dimensions',+ durations: 'Durations',+ audio: 'Audio',+ fps: 'FPS',+ 'sample-rates': 'Sample Rates',+ greenscreen: 'Green Screen',+ 'edge-cases': 'Edge Cases',+ 'sound-effects': 'Sound Effects',+ hls: 'HLS',+};++export const getCategoryLabel = (category: string) =>+ categoryLabelMap[category] ?? category;++const formatBytes = (size: number) =>+ size < 1024 * 1024+ ? `${(size / 1024).toFixed(0)} KB`+ : `${(size / 1024 / 1024).toFixed(1)} MB`;++const formatCodec = (codec: string, type: 'audio' | 'video') => {+ if (codec === 'none') {+ return type === 'audio' ? 'No audio' : 'No video';+ }++ return codec.toUpperCase();+};++const formatCodecWithType = (codec: string, type: 'audio' | 'video') =>+ codec === 'none'+ ? formatCodec(codec, type)+ : `${formatCodec(codec, type)} ${type}`;++const formatCodecs = (variant: MediaVariant) =>+ [+ variant.container.toUpperCase(),+ formatCodecWithType(variant.videoCodec, 'video'),+ formatCodecWithType(variant.audioCodec, 'audio'),+ ].join(', ');++const formatVariant = (variant: MediaVariant) => {+ const primaryFile = variant.fileNames[0];+ const url = `https://remotion.media/${primaryFile}`;++ return [+ `### ${primaryFile}`,+ '',+ `- ${url}`,+ `- Codecs: ${formatCodecs(variant)}`,+ `- ${formatBytes(variant.size)}`,+ ].join('\n');+};++export const makeAgentsMarkdown = (mediaVariants: readonly MediaVariant[]) => {+ const groups = new Map<string, MediaVariant[]>();++ for (const variant of mediaVariants) {+ if (!groups.has(variant.category)) {+ groups.set(variant.category, []);+ }++ groups.get(variant.category)?.push(variant);+ }++ const categories = [...groups.keys()];++ return `${[+ '# remotion.media',+ '',+ 'Plaintext catalog for agents using the Remotion test media library.',+ '',+ 'Base URL pattern: `https://remotion.media/[filename]`',+ '',+ 'Files may be used royalty-free and without attribution unless an item states otherwise.',+ '',+ '## Categories',+ '',+ ...categories.map((category) => `- ${getCategoryLabel(category)}`),+ '',+ ...categories.flatMap((category) => [+ `## ${getCategoryLabel(category)}`,+ '',+ ...(groups.get(category) ?? []).flatMap((variant) => [+ formatVariant(variant),+ '',+ ]),+ ]),+ ].join('\n')}\n`;+};diff --git a/packages/remotion-media/src/index.tsx b/packages/remotion-media/src/index.tsxindex 355dec16cc..e5e052a91a 100644--- a/packages/remotion-media/src/index.tsx+++ b/packages/remotion-media/src/index.tsx@@ -1,8 +1,17 @@import {serve} from 'bun';+import variants from '../variants.json';+import {makeAgentsMarkdown} from './agents';import index from './index.html';+const agentsMarkdown = makeAgentsMarkdown(variants);+serve({routes: {+ '/AGENTS.md': new Response(agentsMarkdown, {+ headers: {+ 'Content-Type': 'text/markdown; charset=utf-8',+ },+ }),// Serve index.html for all unmatched routes.'/*': index,},