     {
         switch self
         {
-        case .cancelled:return "cancelled"
-        case .completed:return "completed"
-        case .writing:return "writing"
-        case .unknown:return "unknown"
-        case .failed:return "failed"
+            case .cancelled:return "cancelled"
+            case .completed:return "completed"
+            case .writing:return "writing"
+            case .unknown:return "unknown"
+            case .failed:return "failed"
         }
     }
 }

    var fetchUnityTime:(()->Double)? // get game timestamp for timesync
    private func synchronize(timestamp value:Double)
    {
        print("sychronize")
        if let time = fetchUnityTime?()
        {
            syncdata.append([value, time])

    }
    
    var lastime:CMTime = kCMTimeZero
    private let background = DispatchQueue(label: "video_encode_queue")
    func append(sample:CMSampleBuffer, type:RPSampleBufferType)
    {
        guard CMSampleBufferIsValid(sample) else {return}
        
        background.sync
        {
            if !initialized
            {
                setup(sample: sample)
            }
            
            if let track = movieTracks[type], track.isReadyForMoreMediaData
            {
                if type == .video
                {
                    track.append(sample)
                    if writer.status == .failed
                    {
                        print(type, writer.error!)
                    }
                }
                else
                {
                    track.append(sample)
                    if writer.status == .failed
                    {
                        print(type, writer.error!)
                    }
                }
            }
