Fixing broken .m4v movies made in Matlab

I made a few ten-minute movies in Matlab composed of 1-second clips from BBC Earth, encoded as H.264, to use as visual stimuli. They played fine on Windows but would stop at the 170 second mark in Quicktime on Mac.

We’re using Processing on Mac for visual display, which uses Quicktime in the background, so they would lock up in Processing as well.

A solution is to use a passthrough encoder to remux the file; somehow there’s missing metadata and that fixed it for quicktime. ffmpeg does the trick:

ffmpeg -i bad_movie.m4v -c:v copy -c:a copy good_movie.m4v

Note that it doesn’t actually re-encode the data, it just adds some metadata – about 3k worth of metadata in fact.

Leave a comment

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s