Use ARVideoKit for recording, the saved video file only show the picture frame with black pic

Viewed 12

I have an ARKit & SceneKit app that records videos using ARVideoKit. Inside my scene I have a picture frame. In the recording view, everything is well, but when I saved recording file and play it, the picture Frame is there with only frame, no picture, only black in the picture area. Please see the attached pictures to see the issue.

I would appreciate if anyone can explain why this is happening.

the recording and playing view attached as pictures: enter image description here enter image description here

Below is my ViewController Code:

import UIKit
import SceneKit
import ARKit
import FirebaseAuth
import FirebaseFirestore
import FirebaseStorage
import ARVideoKit // ARVideoKit for Recording

class ActionViewController: UIViewController, ARSCNViewDelegate, RenderARDelegate {
//    // ARVideoKit for Recording
    func frame(didRender buffer: CVPixelBuffer, with time: CMTime, using rawBuffer: CVPixelBuffer) {

    }
    
    @IBOutlet var sceneView: ARSCNView!
    @IBOutlet weak var progressBar: UIProgressView!
    @IBOutlet weak var environmentIcon: UIButton!
    @IBOutlet weak var spaceIcon: UIButton!
    @IBOutlet weak var timeIcon: UIButton!
    @IBOutlet weak var trackIcon: UIButton!
    @IBOutlet weak var digitalPersonIcon: UIButton!
    @IBOutlet weak var nftIcon: UIButton!
    @IBOutlet weak var startIcon: UIButton!
    @IBOutlet weak var stopIcon: UIButton!
    @IBOutlet weak var actionTopicField: UITextField!
    
    let db = Firestore.firestore()
    var userSettings = UserSetting()
    var currentNftAnchor: String = ""
    var saveLocalOption: Bool = false

    // ARVideoKit for Recording
    var videoRec: RecordAR?
    var videoPath: URL? = nil

    override func viewDidLoad() {
        super.viewDidLoad()
        sceneView.delegate = self
        
        loadNFT()

    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        
        // Create a session configuration
        let configuration = ARWorldTrackingConfiguration()

        // Run the view's session
        sceneView.session.run(configuration)
 
        // ARVideoKit for Recording
        videoRec?.prepare(configuration)
        
        // Load UserSettings
        loadSettings()
        
        startIcon.isHidden = false
        stopIcon.isHidden = true
    }
    
    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        
        videoRec?.rest()
        
        // Pause the view's session
        sceneView.session.pause()
    }
    
  @IBAction func startClicked(_ sender: UIButton) {
        // ARVideoKit for start Recording, set 10 seconds limit temp.
        startIcon.isHidden = true
        stopIcon.isHidden = false
        
        videoRec = RecordAR(ARSceneKit: sceneView)
        videoRec!.deleteCacheWhenExported = false
        videoRec!.renderAR = self
        videoRec!.onlyRenderWhileRecording = false
        videoRec!.fps = ARVideoFrameRate(rawValue: 30)!

        videoRec!.record(forDuration: 10) { videoPath in
            self.videoPath = videoPath

            // For fix the warning msg: uiView.isHidden must be used from main thread only
            DispatchQueue.main.async {
                self.startIcon.isHidden = false
                self.stopIcon.isHidden = true
            }
        }
    }
    
    @IBAction func stopClicked(_ sender: UIButton) {
        // ARVideoKit for stop Recording
        startIcon.isHidden = false
        stopIcon.isHidden = true

        videoRec!.stop { videoPath in
            self.videoPath = videoPath
        }
    }
}
0 Answers
Related