Skip to main content
Glama

convert_to_mp4

Convert .webm videos to MP4 format for compatibility with social media, sharing platforms, and embedding requirements.

Instructions

Convert a .webm video to MP4 (H.264). Widely compatible for social media, sharing, and embedding.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
webmPathYesPath to the .webm file
crfNoQuality (18=high, 23=default, 28=small file)

Implementation Reference

  • Handler implementation for converting WebM to MP4 using ffmpeg.
    export async function convertToMp4(webmPath, options = {}) {
      await checkFfmpeg();
      await access(webmPath);
    
      const mp4Path = options.outputPath || webmPath.replace(/\.webm$/, '.mp4');
      const crf = options.crf || 23; // quality: lower = better, 18-28 is reasonable
    
      await run('ffmpeg', [
        '-i', webmPath,
        '-c:v', 'libx264',
        '-preset', 'slow',
        '-crf', String(crf),
        '-pix_fmt', 'yuv420p',
        '-movflags', '+faststart',
        '-y', mp4Path
      ]);
    
      const mp4Stat = await stat(mp4Path);
      return {
        mp4Path,
        sizeBytes: mp4Stat.size,
        sizeMB: (mp4Stat.size / 1024 / 1024).toFixed(2)
      };
    }
  • src/index.js:123-144 (registration)
    MCP tool registration for convert_to_mp4.
    // Tool 5: Convert WebM to MP4
    mcp.tool(
      'convert_to_mp4',
      'Convert a .webm video to MP4 (H.264). Widely compatible for social media, sharing, and embedding.',
      {
        webmPath: z.string().describe('Path to the .webm file'),
        crf: z.number().optional().default(23).describe('Quality (18=high, 23=default, 28=small file)')
      },
      async ({ webmPath, crf }) => {
        try {
          const result = await convertToMp4(webmPath, { crf });
          return {
            content: [{
              type: 'text',
              text: `MP4 created!\n\nFile: ${result.mp4Path}\nSize: ${result.sizeMB} MB`
            }]
          };
        } catch (err) {
          return { content: [{ type: 'text', text: `Error: ${err.message}` }], isError: true };
        }
      }
    );

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mcpware/pagecast'

If you have feedback or need assistance with the MCP directory API, please join our Discord server