Record your SceneKit and ARKit scenes easily.

Overview

SceneKitVideoRecorder

SceneKitVideoRecorder

Version Downloads License Platform Build Status

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Apps using SceneKitVideoRecorder

Surreal AR Arrow

Send a PR to add your app here

Installation

SceneKitVideoRecorder is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'SceneKitVideoRecorder'

To install Swift 4 branch add the following line to your Podfile:

pod 'SceneKitVideoRecorder', :git => 'https://github.com/svtek/SceneKitVideoRecorder.git', :branch => 'swift4'

Usage

Add NSMicrophoneUsageDescription to info.plist

Add below code to your view controller

var recorder: SceneKitVideoRecorder?
override func viewDidLayoutSubviews() {
    super.viewDidLayoutSubviews()

    if recorder == nil {
        var options = SceneKitVideoRecorder.Options.default

        let scale = UIScreen.main.nativeScale
        let sceneSize = sceneView.bounds.size
        options.videoSize = CGSize(width: sceneSize.width * scale, height: sceneSize.height * scale)
        recorder = try! SceneKitVideoRecorder(withARSCNView: sceneView, options: options)
    }
}

@IBAction func startRecording (sender: UIButton) {
  self.recorder?.startWriting().onSuccess {
    print("Recording Started")
  }
}

@IBAction func stopRecording (sender: UIButton) {
  self.recorder?.finishWriting().onSuccess { [weak self] url in
    print("Recording Finished", url)
  }
}

Performance tips

Here is a piece of Apple sample code

 if let camera = sceneView.pointOfView?.camera {
  camera.wantsHDR = true
  camera.wantsExposureAdaptation = true
  camera.exposureOffset = -1
  camera.minimumExposure = -1
}

The line camera.wantsHDR = true and camera.wantsExposureAdaptation = true causes a huge drop in video recording performance. You should remove or disable it for video recording.

Author

Omer Karisman

Product Manager @ MojiLaLa
Twitter Dribble Github
Sahin Boydas

Co-Founder @ MojiLaLa
LinkedIn

Inspired from

noppefoxwolf, [email protected]

License

SceneKitVideoRecorder is available under the MIT license. See the LICENSE file for more info.

Comments
  • startWriting() method not working properly

    startWriting() method not working properly

    I can't make the new version work. I'm probably doing something wrong.

    Like the demo project, I'm calling:

    • recorder=try! SceneKitVideoRecorder(withARSCNView: sceneView) in viewDidLoad()
    • recorder.setupMicrophone() in viewWillAppear
    • then recorder.startWriting() when pushing the record button

    startDisplayLink() method is never called. So when finishWriting is called, isRecording is false and it returns without actually stoping the recording. Then when I push the record button again I get Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '*** -[AVAssetWriter addInput:] Cannot call method when status is 3'.

    bug Can’t Reproduce 
    opened by mariedm 16
  • Video is not being saved / File is empty

    Video is not being saved / File is empty

    After calling startWriting and finishWriting multiple times in a row, the recorder stops working. A file is created, but it is empty. This happens with the demo project as well as my own. In the demo project I'm getting the error: Video /private/var/mobile/Containers/Data/Application/09B7703C-A173-4EB5-BC8E-F482C2ACDAD8/tmp/output.mp4 cannot be saved to the saved photos album: Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSUnderlyingError=0x1c0445310 {Error Domain=NSOSStatusErrorDomain Code=-12893 "(null)"

    Issue environment:

    • Device Model: iPhone 7 Plus
    • Xcode Version: Xcode 9 GM
    • iOS Version: 11.0 (15A372)
    • Pod Version or Repo Commit: 1.3.1
    bug 
    opened by LeonardRockstar 13
  • Starting white frame

    Starting white frame

    Hi,

    The video recording works fine but all the videos have a single transparent frame. How can i avoid that or remove it so that thumbnails shows correct image in all places.

    Issue environment:

    • Device Model: iPhone 7
    • Xcode Version: 9
    • iOS Version: 11
    • Pod Version or Repo Commit: 1.3.2

    Issue Details:

    bug 
    opened by hablema 7
  • Different video bugs on different devices

    Different video bugs on different devices

    • [+] Issue is reproducible in the Demo Project
    • [+] Issue is reproducible with a clean install
    • [+] You are running on a Device and not the Simulator
    • [+] You have searched existing issues (Open and Closed)
    • [+] You are using an appropriate version of XCode and iOS

    Runs well on iPhone 6S with iOS 11 beta.

    Issue environment:

    • Device Model: iPhone 7 plus
    • Xcode Version: Xcode 9 GM
    • iOS Version: 11 release
    • Pod Version or Repo Commit: last version

    Issue Details: The video is corrupted, please have a look at the photo. Bug with incorrect size is also can be seen on iPhone 6S Plus (without color bug), so I think this is a problem of all 5.5 iPhones.

    bug 
    opened by notdetninja47 5
  • How to handle error if the recording is corrupted?

    How to handle error if the recording is corrupted?

    Hello, this library works GREAT!!!

    When recording or more importantly stopping and saving, how do I handle errors if the video url is somehow messed up?

    The current callback in your example Swift file is a URL:

    self.recorder?.finishWriting().onSuccess { [weak self] url in
                    
        self?.checkAuthorizationAndPresentActivityController(toShare: url, using: self!)
    }
    

    Is there tuple available with a URL and NSERROR?

     self.recorder?.finishWriting().onSuccess { [weak self] (url, error) in
    
        if let error = error {
    
             // alert user recording failed
             return
        }
    
        self?.checkAuthorizationAndPresentActivityController(toShare: url, using: self!)
    }
    

    Or is the error handling in an entirely different function meaning we call one for success and another for failure?:

    self.sceneKitVideoRecorder?.finishWriting().onFailure(callback: { [weak self](error) in
                    
        print("Recording Failed")
    })
    
    opened by lsamaria 4
  • Audio not recorded

    Audio not recorded

    Issue environment:

    • Device Model: iPhone 7
    • Xcode Version: 9.2 Beta 2
    • iOS Version: 11.1
    • Pod Version or Repo Commit: 1.4.0

    Issue Details:

    The audio is not being recorded in the new method recorder?.setupAudio() . Have tried adding it in the beginning of the controller also in the recordbuttontapped method. Still no audio. The microphone permission was asked first time asked and allowed.

    bug 
    opened by hablema 4
  • Crash: A pixel buffer cannot be appended when readyForMoreMediaData is NO

    Crash: A pixel buffer cannot be appended when readyForMoreMediaData is NO

    Issue environment:

    • Device Model: iPhone 6S
    • Xcode Version: 9
    • iOS Version: 11

    Issue Details:

    Sometimes the recorder crashes, line 343

    self?.pixelBufferAdaptor.append(pixelBuffer, withPresentationTime: appendTime)
    

    Error message:

    'NSInternalInconsistencyException', reason: '*** -[AVAssetWriterInputPixelBufferAdaptor appendPixelBuffer:withPresentationTime:] A pixel buffer cannot be appended when readyForMoreMediaData is NO.'
    
    opened by Francescu 4
  • Chromakeyed video recording cause white background

    Chromakeyed video recording cause white background

    Issue environment:

    • Device Model: iPhone mini running iOS 15
    • Xcode Version: Xcode 13
    • iOS Version: iOS 15
    • Pod Version or Repo Commit:

    Issue Details: I record the scene where I play a video ver a SCNPlane in which I remove green background of video using surface shader. This cause recorded video to have a white background instead of transparent one. Any ideas? IMG_5889

    IMG_5887

    opened by ozgurshn 3
  •  Crash on finishWriting: index 0 beyond bounds for empty NSArray

    Crash on finishWriting: index 0 beyond bounds for empty NSArray

    Issue environment:

    • Device Model: iPhone X, iPhone 8 plus
    • Xcode Version: 9.1
    • iOS Version: 11
    • Pod Version or Repo Commit: dc742c912fac986edb68471ccefdd7b24b928b1a

    Issue Details:

    screen shot 2017-11-22 at 14 12 20 screen shot 2017-11-22 at 14 12 14
    opened by Francescu 3
  • How to check if recorder is recording?

    How to check if recorder is recording?

    How can I check if the recorder is recording? For eg.

    if recorder?.isWriting {
    
        _ = recorder?.startWriting()
    
    } else {
    
        recorder?.finishWriting().onSuccess { [weak self] url in
    
            print("recording success", url)
                    
        }.onFailure(callback: { (error) in
    
            print("recording failed", error)
        })
    }
    
    opened by lsamaria 2
  • [Swift4] Updated syntax and changed two property modifiers

    [Swift4] Updated syntax and changed two property modifiers

    • Updated syntaxes and method signatures to latest Swift 4.2 • Changed isPrepared and isRecording properties access modifiers to public. This changes are needed if user wants to update UI based on current recording status.

    opened by mjhassan 2
  • Multiple ARSessions causes crash

    Multiple ARSessions causes crash

    Before submitting an issue please make sure that:

    • [*] Issue is reproducable in the Demo Project
    • [*] Issue is reproducable with a clean install
    • [*] You are running on a Device and not the Simulator
    • [*] You have searched existing issues (Open and Closed)
    • [*] You are using an appropriate version of XCode and iOS

    Issue environment:

    • Device Model: iPhone 6 Plus
    • Xcode Version: 11.4
    • iOS Version: 13.4
    • Pod Version or Repo Commit: 1.6.0

    Issue Details:

    I am trying to record multiple ARSessions and it is causing crash.

    opened by askari01 0
  • Crash fix

    Crash fix

    Occasionally getting crash:

    -[AVAssetWriterInputPixelBufferAdaptor appendPixelBuffer:withPresentationTime:] A pixel buffer cannot be appended when readyForMoreMediaData is NO

    And suggest PR to fix it.

    opened by michdavydov 0
  • Do you plan a Swift 5 version?

    Do you plan a Swift 5 version?

    Before submitting an issue please make sure that:

    • [ ] Issue is reproducable in the Demo Project
    • [ ] Issue is reproducable with a clean install
    • [ ] You are running on a Device and not the Simulator
    • [ ] You have searched existing issues (Open and Closed)
    • [ ] You are using an appropriate version of XCode and iOS

    Issue environment:

    • Device Model:
    • Xcode Version:
    • iOS Version:
    • Pod Version or Repo Commit:

    Issue Details:

    opened by sebastienboulogne 5
  • For Ipad landscape mode - records portrait video

    For Ipad landscape mode - records portrait video

    Before submitting an issue please make sure that:

    • [ ] Issue is reproducable in the Demo Project
    • [ ] Issue is reproducable with a clean install
    • [x] You are running on a Device and not the Simulator
    • [ ] You have searched existing issues (Open and Closed)
    • [ ] You are using an appropriate version of XCode and iOS

    Issue environment:

    • Device Model:
    • Xcode Version:
    • iOS Version:
    • Pod Version or Repo Commit:

    Issue Details:

    opened by Dharini17 8
  • Swift 5 ?

    Swift 5 ?

    Before submitting an issue please make sure that:

    • [ ] Issue is reproducable in the Demo Project
    • [ ] Issue is reproducable with a clean install
    • [ ] You are running on a Device and not the Simulator
    • [ ] You have searched existing issues (Open and Closed)
    • [ ] You are using an appropriate version of XCode and iOS

    Issue environment:

    • Device Model:
    • Xcode Version:
    • iOS Version:
    • Pod Version or Repo Commit:

    Issue Details:

    opened by sebastienboulogne 2
Releases(1.2.0)
Owner
SV Hawks
SV Hawks
ARDicee - Simple augmented reality app using SceneKit and ARKit

ARDicee Simple augmented reality app using SceneKit and ARKit Requirements Xcode

donggyu 3 Feb 4, 2022
AR Ruler - A simple iOS app made using ARKit and SceneKit

A simple iOS app made using ARKit and SceneKit.Which can try to simplify little things in your life such as measuring stuff.

Dishant Nagpal 5 Aug 31, 2022
Easily use ARKit to detect facial gestures.

Easily use ARKit to detect facial gestures. FaceTrigger is a simple to use class that hides the details of using ARKit's ARSCNView to recognize facial gestures via ARFaceAnchor.BlendShapeLocations

Michael Peterson 67 Jun 16, 2022
ARVoxelKit - Lightweight Framework for Voxel graphic using AR + SceneKit

ARVoxelKit Lightweight Framework for Voxel graphic using AR + SceneKit Requirements ARVoxelKit requires iOS 11 and devices, which support ARKit Usage

null 79 Dec 29, 2022
Swift framework for loading various 3d models in SceneKit

AssetImportKit AssetImportKit is a cross platform library (macOS, iOS) that coverts the files supported by Assimp to SceneKit scenes. Features AssetIm

eugene 74 Nov 30, 2022
A library that allows you to generate and update environment maps in real-time using the camera feed and ARKit's tracking capabilities.

ARKitEnvironmentMapper Example To run the example project, clone the repo, and run pod install from the Example directory first. Installation ARKitEnv

SV Hawks 91 Dec 4, 2022
A library that allows you to generate and update environment maps in real-time using the camera feed and ARKit's tracking capabilities.

ARKitEnvironmentMapper Example To run the example project, clone the repo, and run pod install from the Example directory first. Installation ARKitEnv

SV Hawks 91 Dec 4, 2022
Using ARKit and LiDAR to save depth data and export point cloud, based on WWDC20-10611 sample code

Save iOS ARFrame and Point Cloud This project improves the usability of the sample code from WWDC20 session 10611: Explore ARKit 4. Note that the samp

null 4 Dec 22, 2022
Augmented Reality image tracking with SwiftUI, RealityKit and ARKit 4.

ARImageTracking This is an Augmented Reality Xcode project that uses Apple's newest RealityKit framework and ARKit 4 features, to dynamically track a

Richard Qi 198 Dec 7, 2022
ARKit + CoreLocation: Combines the high accuracy of AR with the scale of GPS data.

ARKit: Uses camera and motion data to map out the local world as you move around. CoreLocation: Uses wifi and GPS data to determine your global locati

Andrew Hart 5.3k Dec 27, 2022
ARKit Demo Application

ARKitNavigationDemo Work in progress. In Progress Region — For one, we could render far fewer nodes. In fact, it’s a bit distracting that the entire t

Christopher Webb 296 Dec 16, 2022
IOS example app to generate point clouds in ARKit using scenedepth

Visualizing a Point Cloud Using Scene Depth Place points in the real-world using the scene's depth data to visualize the shape of the physical environ

Isak Diaz 20 Oct 31, 2022
ARKit Base Project. Place virtual objects based on WWDC example project

ARKit - Placing Virtual Objects in Augmented Reality Learn best practices for visual feedback, gesture interactions, and realistic rendering in AR exp

Ignacio Chiazzo Cardarello 338 Jan 5, 2023
This library uses ARKit Face Tracking in order to catch user's smile.

SmileToUnlock Make your users smile before opening the app :) Gif with the demonstration Installation Cocoapods The most preferable way to use this li

Ruslan Serebriakov 628 Oct 22, 2022
PlacenoteSDK Sample app in native iOS using ARKit, written primarily in Swift

Placenote SDK for iOS Placenote SDK lets you easily build cloud-based Augmented Reality (AR) apps that pin digital content to locations in the real wo

Placenote 93 Nov 15, 2022
Power! Unlimited power for ARKit 2.0!

A long time ago in a galaxy, far, far away... It is a period when iPhone SE and iPhone X were destroyed from the apple store, the AR market was under

KBOY (Kei Fujikawa) 516 Dec 1, 2022
A simple application created for educational purposes for mastering ARKit

ARDrawing AR Drawing is a simple application created for educational purposes for mastering ARKit. The basis of the project is copied from the project

NIKOLAY NIKITIN 0 Oct 20, 2022
Trying TDD with ARKit

ARPlacer BDD Spec As a user I want to place a random object in real world. I also want to see the distance between AR object and my phone. Use Cases

null 0 Dec 21, 2021
Draw VR content over live camera feed with ARKit

funny-ar Exercise with ARKit: draw VR content over live camera feed: work is in

pavel 3 Dec 18, 2021