OS X Photos Video Archiver

October 4, 2015

Its taken me a while to get used to Apple's Photos app, but I've definitely come around.  The ability to nest folders has dramatically cleaned up my library.  I signed up for iCloud Photo Library so I can share my entire library between my two macs, my iPhone and my wife's iPhone.  Unfortunately iCloud Photo Library only works with one Apple ID, so my wife and I are still sharing the same ID.  Hopefully Apple realizes that there are legitimate cases where multiple people want to share the entire library, but that's besides the point.

So I'm loving Photos and especially the access I have from every device.  One thing that still bothers me, though, is that videos don't get their own app.  Instead they are sort of just second-class citizens within the "Photos" app.  I have about 15,000 photos, so I appreciate having an app like Photos to organize them.  With videos, however, I prefer to organize on the file system.  Maybe I'm old-fashioned.  The other thing is that Apple stores the videos in the highest quality possible, so they chew up tons of space.  Check it out in Apple's own words (iPhone 6s on iOS 9.0.2).


130 MB - 200 MB per minute if you record in 1080p!  I am the father of three children and have hundreds of videos of their antics.  Even with the biggest iPhone I would quickly fill up the storage.  It would also chew up tons of iCloud storage space if I left everything as recorded.  What I want to do is export all the videos and compress for storage in iCloud drive where I can still access them from every device.  I've been doing this in the past manually with Handbrake, where I have come up with a preset that looks reasonably good to me.  I couldn't find anyone else that had put together a solution around automating this, so a buddy and I created one for ourselves.  In the interest of sharing this with the community we've posted it on GitHub.

The Photos Video Archiver is an Automator workflow that exports selected videos from Photos, compresses them to 720p via Handbrake, and finally sets the created timestamp of the new video with the original video creation timestamp.  Since its all on GitHub you can download it for yourself and change any settings you want.  Perhaps you want 1080p with a different Handbrake preset?  No problem!  I will be working on the documentation soon, and will also create a video demonstrating usage.  For now, due to what I think is a bug in El Capitan, you need to open the workflow from within Automator and click "run" after you've selected the videos in the Photos app.

"But wait!", you say, "Doesn't Photos allow you to do 720p exports from within the app?".  It does.  I have found, though, that its compression is lacking.  Using the Photos Video Archiver project when I exported about 300 videos the final size was 4.18 GB.  Using the 720p export from Photos the final size was 11.4 GB.  The stats for exporting these videos with various options are:

  • Photos Export Unmodified Original = 22.92 GB
  • Photos Export with 720p Movie Quality = 11.4 GB
  • Photos Video Archiver = 4.18 GB

That's nearly an 82% reduction from original file size, 63% reduction from the Photos 720p export file size.  Again this preset is one that I've found works well for me.  Its easy enough to adapt it for yourself.  It took about 6 hours for the encoding to finish (MacBook Pro, Mid 2014, 2.5 GHz i7).  The preset I am using is basically:

H.264 (x264)
"veryslow" preset under "Encoder Options"
Constant Quality RF (Rate Factor) 22
Output 1280 x 720 (or 720 x 1280, depending on rotation)

Going into this project I wasn't sure how iCloud Photo Library handled videos.  My fear was that the source quality video was only on the phone, and that a lower-quality version was stored in the cloud.  To my relief I found that the "Unmodified Original" truly is byte-for-byte the same as copying it off the phone with a lightning cable.  When you drag a video out of Photos it treats it as a 720p export.  Something to keep in mind.

Before Photos it was difficult to export slomo videos.  I've addressed this messy issue in a previous post.  Fortunately the video export from Photos preserves the slomo (ducking, audio pitch, slow playback) effects when it exports at 30 FPS.  That means anyone can play back slomo files and see the cool effects.  It also means though that you cannot further modify the slomo after it has been exported, so make sure you're happy with it before you begin.

Something else I've pointed out in the past is that iPhones record all videos with the volume-buttons as the bottom side of the video.  So even if you record a video in portrait (home button at the bottom), if you play it back in something like VLC, it will be rotated 90°, outputting in landscape with all your content sideways.  Fortunately the video export from Photos corrects rotation, so playback in any app (e.g. VLC) has the correct rotation.  So that we don't have to solve rotation ourselves in Photo Video Archiver, we encode videos that have already been exported from Photos in a higher quality.  The workflow is:

  1. Applescript changes the title of all selected videos to include the date and time the video was originally created.
  2. User manually exports selected videos using 1080p Movie Quality, setting the File Name to "Use Title".  The videos need to be exported to an empty folder.
  3. Automator then prompts user to select the folder they just sent the export to.
  4. Unix bash script executes and:
    1. Creates an "encoded" folder within the export folder.
    2. Detects if the video is landscape or portrait.
    3. Sends the video through the HandBrakeCLI with the correct width parameter for landscape or portrait videos.
    4. Renames the newly encoded video with the original title.
    5. Sets the creation date of the newly encoded video with the original creation date.

More work is needed to improve usability and expose more options to the user, but if you are willing to run this from within Automator you can start using it today.  I'm hoping others will find this helpful and will contribute as well.  The ultimate solution, in my opinion, would be for Apple to expose "advanced" options for encoding within Photos.  Until then, we can solve this ourselves!

Subscribe to RSS - github