Fixing Home Movies with FFmpeg

My dad converted a bunch of old taped home movies to MP4 and gave them to me for Christmas. I copied them all to my Plex server since I thought having them on-demand would be pretty cool. Unfortunately, a lot of them ended up rotated 90 degrees and–surprisingly–there’s no way to tell Plex to rotate on playback.

I kept thinking there’s got to be an easy way to fix the rotated movies so they play back correctly on my TV. And then I remembered the Swiss Army Knife of video playback tools: FFmpeg.

Some quick searching online and I found there is a transpose video filter that does exactly what I want: it can rotate and flip video files. It’s as easy as:

$ ffmpeg -i input.mp4 -vf "transpose=2" output.mp4

transpose=2 tells the filter to rotate 90 degrees counter-clockwise (which seems to fix all the sideways videos in my collection). But FFmpeg can do more! A lot of these videos were converted from tape and you can see some pretty bad interlacing at times. To clean that up, I add another filter:

$ ffmpeg -i input.mp4 -vf "transpose=2, yadif" output.mp4

The yadif filter does a great job cleaning up that interlacing. Now I’ve got nice progressive 480p home movies.

I don’t want to have to type all this every single time I want to fix a movie, so I’ve created a script in ~/bin/fix-movie.sh:

ffmpeg -i "$1" -vf "transpose=2, yadif" "$(basename -s $2 "$1")_rotated$2"

I can call this from the command line using:

$ fix-movie.sh "My home movie.mp4" .mp4

It fixes the movie and outputs to My home movie_rotated.mp4. If all looks good, I can copy it over the original. FFmpeg really saved the day!

Leave a comment