Web Development Bug Report

MediaRecorder blobs unplayable across browsers: mimeType differences between Safari and Chrome

Our in-app screen recorder for bug reports saved every clip as video/webm. Safari actually recorded MP4, Chrome's WebM had no duration, and support agents on iPads could not play half the clips. Feature detection, the real recorder mimeType and a server-side transcode fixed it.

Tomás Herrera Tomás Herrera @tomasherrera · November 18, 2026 · 8 min read · 237 Views
585-mediarecorder-mimetype-safari-vs-chrome

Our help-desk product lets end users record their screen and camera when they report a bug. The recording happens in the browser with MediaRecorder, the clip is uploaded, and a support agent watches it in the ticket. Agents started flagging tickets: "video attached, won't play". About half of the broken clips came from Safari users, the rest from Chrome users, and the agents who complained most worked on iPads.

The ticket view used a plain <video> element. For the Safari-recorded clips, the agent's browser either showed a broken player or the download had a .webm extension that the iPad refused to open. For the Chrome-recorded clips, the player opened but the seek bar was missing and the duration read "Infinity". Running ffprobe on one of the Chrome uploads printed:

Input #0, matroska,webm, from 'ticket-55120.webm':
  Duration: N/A, start: 0.000000, bitrate: N/A
  Stream #0:0: Video: vp8, yuv420p(progressive), 1440x900, SAR 1:1 DAR 8:5, 1k tbr, 1k tbn
  Stream #0:1: Audio: opus, 48000 Hz, mono, fltp

Reproducing it

Record a ten-second clip in Safari on macOS and in Chrome, upload both, then open both on an iPad and in desktop Chrome. Every combination except "recorded in Chrome, watched in desktop Chrome or Firefox" had a problem.

What we ruled out

  • Upload corruption. Checksums matched between the browser blob and the stored file.

  • Storage Content-Type. We fixed one wrong header early on; it was not the main cause.

  • Codec support in Safari for playback. Safari can play some WebM, but that did not help clips labelled with the wrong format, or iPad agents opening downloads in other apps.

Root cause

The recorder code had been written and tested in Chrome. It created the recorder with a hardcoded WebM type when supported, and otherwise let the browser choose, but it always built the final blob with type: 'video/webm' and the upload always used a .webm file name. Safari on our users' versions recorded MP4 with H.264 and AAC, so we stored MP4 bytes labelled as WebM. Chrome recorded real WebM, but MediaRecorder writes WebM incrementally and does not go back to write the duration and seek index, which is why players could not show a seek bar. Finally, our agents' iPads could not reliably play VP8 and Opus WebM at all. We had three formats on the way in and no normalisation.

What is happening under the hood

MediaRecorder turns a MediaStream into encoded chunks. Which container and codecs a browser can produce is browser-specific:

Browser

Typical output

Notes

Chrome, Edge

WebM with VP8 or VP9 and Opus

Recent versions also report some MP4 types as supported

Firefox

WebM with VP8 and Opus

Safari

MP4 with H.264 and AAC

Newer releases may list WebM types too; always feature-detect

The only reliable way to know is MediaRecorder.isTypeSupported() before you start, and the recorder's mimeType property after it starts. When you pass no mimeType to the constructor, the browser picks one and reports it there.

Why WebM recordings lack duration. MediaRecorder emits data as it records, often in timeslice chunks so you can upload as you go. The total duration is not known until the end, and the recorder does not rewrite the start of the file. Players then have to scan the file to learn the duration, and many show "Infinity" or no seek bar. Remuxing once on the server fixes it.

Why the label matters. Browsers and operating systems choose a decoder from the declared type or extension before they look at the bytes. An MP4 labelled video/webm can be rejected outright.

Environment

Component

Version / value

Recording browsers

Chrome 141, Safari 26 on macOS 26, Firefox 144

Viewing devices

iPadOS 26 Safari, desktop Chrome and Edge

Recorder

MediaRecorder with timeslice: 2000, screen + camera + mic

Backend

Node.js 24 upload API, object storage, ffmpeg 8.0 workers

Minimal reproduction

// recorder.js — before (excerpt)
const type = MediaRecorder.isTypeSupported('video/webm') ? 'video/webm' : undefined;
const recorder = new MediaRecorder(stream, type ? { mimeType: type } : undefined);
const chunks = [];
recorder.ondataavailable = (e) => chunks.push(e.data);
recorder.onstop = () => {
  const blob = new Blob(chunks, { type: 'video/webm' }); // wrong in Safari
  upload(blob, `ticket-${ticketId}.webm`);
};
recorder.start(2000);

Who is affected

Any app that records with MediaRecorder and plays the result on a different browser or device: bug-report recorders, video messages, interview tools, voice notes. Audio-only recording has the same split: Safari tends to produce MP4 with AAC, Chrome and Firefox WebM or Ogg with Opus.

The fix

1. Pick the best supported type from an ordered list. We prefer MP4 with H.264 where the browser supports recording it, because it is the most playable output, then fall back to WebM:

const CANDIDATES = [
  'video/mp4;codecs=avc1,mp4a.40.2',
  'video/mp4',
  'video/webm;codecs=vp9,opus',
  'video/webm;codecs=vp8,opus',
  'video/webm',
];

export function pickRecorderType() {
  return CANDIDATES.find((t) => MediaRecorder.isTypeSupported(t));
}

2. Trust recorder.mimeType, not your assumption. The blob and the file name are built from what the recorder actually produces:

// recorder.js — after (excerpt)
const wanted = pickRecorderType();
const recorder = new MediaRecorder(stream, wanted ? { mimeType: wanted } : undefined);
const chunks = [];
recorder.addEventListener('dataavailable', (e) => { if (e.data.size) chunks.push(e.data); });
recorder.addEventListener('stop', () => {
  const type = recorder.mimeType || chunks[0]?.type || 'application/octet-stream';
  const ext = type.startsWith('video/mp4') ? 'mp4' : type.startsWith('video/webm') ? 'webm' : 'bin';
  const blob = new Blob(chunks, { type });
  upload(blob, `ticket-${ticketId}.${ext}`, type);
});
recorder.start(2000);

3. Normalise on the server. Even with correct labels, viewers on different devices need one format. The upload API stores the original, then a worker probes the real container with ffprobe (ignoring the client's claim) and produces a playback copy in H.264, AAC, yuv420p, faststart MP4:

ffprobe -v error -show_entries format=format_name -of csv=p=0 "$IN"
# matroska,webm   or   mov,mp4,m4a,3gp,3g2,mj2

ffmpeg -nostdin -i "$IN" \
  -c:v libx264 -preset veryfast -crf 23 -pix_fmt yuv420p \
  -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" \
  -c:a aac -b:a 128k \
  -movflags +faststart \
  "$OUT"

When the input is already H.264 and AAC in MP4, the worker skips re-encoding and only remuxes with -c copy -movflags +faststart, which also writes a proper duration and index.

4. Play the normalised copy. The ticket view now loads the playback copy and falls back to the original only while the transcode is still running.

Alternatives and trade-offs

  • Only remux, never transcode. Remuxing WebM fixes the missing duration but does not make VP8 play on devices that cannot decode it.

  • Record with WebCodecs and a JavaScript muxer. Gives full control over the output in browsers that support WebCodecs, at the cost of more client code and CPU.

  • Force one format in every browser. Not possible today; recorders support different sets, and the list changes between releases. Feature detection is the stable answer.

How to test the fix

We added a browser test that records two seconds from a canvas stream and checks that the declared type matches what the recorder reports:

test('blob type matches recorder output', async ({ page }) => {
  const result = await page.evaluate(async () => {
    const canvas = document.createElement('canvas');
    const stream = canvas.captureStream(15);
    const rec = new MediaRecorder(stream);
    const parts = [];
    rec.ondataavailable = (e) => parts.push(e.data);
    const done = new Promise((r) => (rec.onstop = r));
    rec.start();
    await new Promise((r) => setTimeout(r, 2000));
    rec.stop();
    await done;
    return { recorder: rec.mimeType, blob: new Blob(parts, { type: rec.mimeType }).type };
  });
  expect(result.blob).toBe(result.recorder);
});

It runs in Playwright's Chromium, Firefox and WebKit projects. On the server side, a worker test feeds one WebM and one MP4 sample through the pipeline and asserts that ffprobe reports h264, aac and a finite duration on both outputs.

Confirming in production

We log the original container from ffprobe and the transcode result for each upload. In the first week after release, uploads were 58 percent WebM and 42 percent MP4, every one produced a playable copy, and "video won't play" flags from agents dropped to zero. The seek bar works on every clip because the playback copy has a real duration.

Regression guard

  • The cross-browser recorder test runs in CI on every change to the recording module.

  • The upload worker alerts if more than 1 percent of transcodes fail in an hour.

  • A lint rule bans string literals like 'video/webm' in new Blob() calls in the recorder code.

Security implications

User-recorded video is untrusted input that you run through a complex parser. Run ffmpeg in an isolated worker with CPU, memory and time limits, keep it up to date, and decide the output format on the server, never from a client-supplied type or file name. Screen recordings often contain personal or sensitive data, so store originals and copies with the same access rules as the ticket, and delete originals once the playback copy is verified if you do not need them.

Prevention checklist

  • Choose recording types with MediaRecorder.isTypeSupported() from an ordered list.

  • Build blobs and file names from recorder.mimeType.

  • Probe uploads on the server instead of trusting extensions or headers.

  • Transcode to one playback format, or at least remux to fix duration and index.

  • Test recording in Chromium, Firefox and WebKit on every release.

References

Add a label

#safari #chrome #ffmpeg #webm #mediarecorder
Written by
Tomás Herrera @tomasherrera

I build and operate event-driven systems on AWS: Lambda, Step Functions, SQS, SNS, EventBridge and ECS on Fargate, mostly for e-commerce and logistics workloads where a stuck message means a stuck order. Serverless removes a lot of work, but it also hides limits until the day you hit them: payload sizes, trigger timeouts, scale-in behaviour, resource policies that silently drop events. I write down each one we hit, with the exact error, the configuration that caused it and the change that fixed it, so you can find the limit in a blog post instead of an incident channel.

Advertisement

Comments

0

No comments yet. Be the first to comment!

Sign In to post a comment.