On this page
One Bad Opus Packet Broke My Video in Safari
Today I learned that Chrome skips past corrupt packets in a video file while Safari stops playback.
I put a 65-second product walkthrough on our landing page as an 11.2 MB, 1080p WebM file with VP9 video and Opus audio. Chrome played the full clip. Safari played a few seconds and showed Error.
Probe Headers, Then Decode the Stream
I checked the file with ffprobe from FFmpeg. ffprobe reads container headers without decoding media packets, so the streams looked valid:
ffprobe -v error -show_entries stream=codec_name,codec_type -of compact walkthrough.webm
# stream|codec_name=vp9|codec_type=video
# stream|codec_name=opus|codec_type=audio
To inspect the packets themselves, I decoded the file through FFmpeg’s null muxer:
ffmpeg -v error -i walkthrough.webm -f null -
# [opus @ 0x74af054380] Error parsing Opus packet header.
One Opus packet mid-stream had a corrupt header. Chrome skipped the bad packet and kept playing, while Safari aborted playback.
You pass -f null - to decode both streams from start to finish without writing an output file. Add -v error so ffmpeg stays quiet unless a packet fails to decode.
By default, ffmpeg logs decode errors and exits with 0, which passes in CI scripts. Pass -xerror to stop on the first corrupt packet and return a non-zero exit code:
ffmpeg -v error -xerror -i walkthrough.webm -f null -
Switch to H.264 MP4
I could have re-encoded the Opus track and kept the WebM container, except Safari lacked full <video> WebM support before macOS Safari 16 and iOS 17.4. I transcoded the file to H.264 and AAC in an MP4 container:
ffmpeg -i walkthrough.webm \
-c:v libx264 -profile:v high -pix_fmt yuv420p -crf 23 -preset slow \
-c:a aac -b:a 128k \
-movflags +faststart \
walkthrough.mp4
Use -pix_fmt yuv420p to output 8-bit 4:2:0 color for Safari and QuickTime decoders, and -movflags +faststart to place the MP4 moov index atom at the front of the file so browsers start playback before the download completes.
| Metric | WebM (Before) | MP4 (After) |
|---|---|---|
| Codecs | VP9 + Opus | H.264 + AAC |
| File size | 11.2 MB | 5.7 MB (49% smaller) |
| Full decode | 1 Opus header error | 0 errors |
| Safari playback | Stops with “Error” | Plays end to end |
At 5.7 MB against the 11.2 MB WebM, I dropped the WebM <source> fallback and served a single MP4.
Quick Reference
| Task | Command |
|---|---|
| Inspect stream headers | ffprobe -v error -show_entries stream=codec_name,codec_type -of compact file.webm |
| Decode full stream | ffmpeg -v error -i file.webm -f null - |
| Fail CI on corrupt packet | ffmpeg -v error -xerror -i file.webm -f null - |
Decode audio stream (-vn) | ffmpeg -v error -xerror -vn -i file.webm -f null - |
What I Learned
- Chrome skips past corrupt media packets during playback, while Safari halts with an error.
ffprobereads container headers and misses broken packets inside the stream.- Run
ffmpeg -v error -xerror -i file -f null -in pre-deploy checks to decode all packets and exit non-zero on corruption. - Use H.264/AAC MP4 with
-pix_fmt yuv420pand-movflags +faststartas the default for web video; our 1080p clip shrank from 11.2 MB to 5.7 MB.
References
Shipping video on the web? I’d love to hear which browser quirks have caught you out. Reach out on LinkedIn.