ARKit: How to record and save video, in swift.

Oscar de la Hera
AR Tips And Tricks
Published in
2 min readNov 28, 2018

This tutorial does not include Audio Input, thank you internet for all those attempts in the past that made me understand the path to follow.

For those looking for a TLDR, jump straight to Solution.

How I felt when I got here.

The Problem

The legend goes that Apple’s ReplayKit is the only way to capture AR — but this breaks all the time, without explanationoften pushing all further video to a Apple TV somewhere for no apparent reason with no way to stop casting your videos other than restarting your phone, leaving developers bashing their heads against walls hoping it works again.

ReplayKit comes with the problem that it presents the video in its own skin, leaving a lack of customization for that video presentation. What if you want to create your own workflow — well… tough luck, bud.

There are repo’s out there such as AFathi’s ARVideoKit but these do not suffice for capturing content that composed of ARReferenceImages or ARReferenceObjects.

But, after many trials and tribulations, today. There’s a way.

Solution

Step One: Add the recording functionality

Tie these functions to your buttons — Note that self.saveVideo(…) is at the end — this is in Step 3.

Step Two: Add the capturing frames functionality.

As explained in this post, “in your func renderer(_ renderer: SCNSceneRenderer, updateAtTime time: TimeInterval) call the following function — and yes, it does have to be coded this way, else your system freezes or crashes.”

Step Three: Add the Save Video Functionality

Et Voila.

Please leave questions or comments in the section below.

O

--

--

Oscar de la Hera
AR Tips And Tricks

Oscar is an award-winning Spanish Inventor whose work impacts lives through brands that include Nike, MoMA and Samsung.