VKRecorderSession

@objc
public class VKRecorderSession : NSObject

VKRecorderSession, a powerful object for managing and editing a set of recorded media clips.

  • Declaration

    Swift

    public weak var delegate: VKRecorderDelegate?
  • Output directory for a session.

    Declaration

    Swift

    public var outputDirectory: String
  • Output file type for a session, see AVMediaFormat.h for supported types.

    Declaration

    Swift

    public var fileType: AVFileType
  • Output file extension for a session, see AVMediaFormat.h for supported extensions.

    Declaration

    Swift

    public var fileExtension: String
  • Unique identifier for a session.

    Declaration

    Swift

    public var videoID: UUID { get }
  • Creation date for a session.

    Declaration

    Swift

    public var date: Date { get }
  • Declaration

    Swift

    public var state: VKRecordingState
  • Declaration

    Swift

    public enum VKRecordingState
  • url

    Creates a URL for session output, otherwise nil

    Declaration

    Swift

    public var url: URL? { get }
  • Declaration

    Swift

    public var isVideoSetup: Bool { get }
  • Checks if the session is setup for recording video

    Declaration

    Swift

    public var isVideoReady: Bool { get }
  • Declaration

    Swift

    public var isAudioSetup: Bool { get }
  • Checks if the session is setup for recording audio

    Declaration

    Swift

    public var isAudioReady: Bool { get }
  • Recorded clips for the session.

    Declaration

    Swift

    public var clips: [VKRecorderClip] { get }
  • Duration of a session, the sum of all recorded clips.

    Declaration

    Swift

    public var totalDuration: CMTime { get }
  • Checks if the session’s asset writer is ready for data.

    Declaration

    Swift

    public var isWriterReady: Bool { get }
  • True if the current clip recording has been started.

    Declaration

    Swift

    public var currentClipHasStarted: Bool { get }
  • Duration of the current clip.

    Declaration

    Swift

    public var currentClipDuration: CMTime { get }
  • Checks if the current clip has video.

    Declaration

    Swift

    public var currentClipHasVideo: Bool { get }
  • Checks if the current clip has audio.

    Declaration

    Swift

    public var currentClipHasAudio: Bool { get }
  • AVAsset of the session.

    Declaration

    Swift

    public var asset: AVAsset? { get }
  • Shared pool where by which all media is allocated.

    Declaration

    Swift

    public var pixelBufferPool: CVPixelBufferPool? { get }

object lifecycle

  • Initialize using a specific dispatch queue.

    Declaration

    Swift

    public convenience init(queue: DispatchQueue, queueKey: DispatchSpecificKey<()>)

    Parameters

    queue

    Queue for a session operations

    queueKey

    Key for re-calling the session queue from the system

  • Initializer.

    Declaration

    Swift

    public override init()

setup

  • Prepares a session for recording video.

    Declaration

    Swift

    public func setupVideo(withSettings settings: [String : Any]?, configuration: VKRecorderVideoConfiguration, formatDescription: CMFormatDescription? = nil) -> Bool

    Parameters

    settings

    AVFoundation video settings dictionary

    configuration

    Video configuration for video output

    formatDescription

    sample buffer format description

    Return Value

    True when setup completes successfully

  • Prepares a session for recording audio.

    Declaration

    Swift

    public func setupAudio(withSettings settings: [String : Any]?, configuration: VKRecorderAudioConfiguration, formatDescription: CMFormatDescription) -> Bool

    Parameters

    settings

    AVFoundation audio settings dictionary

    configuration

    Audio configuration for audio output

    formatDescription

    sample buffer format description

    Return Value

    True when setup completes successfully

  • Regenerates the video id

    This is necessary if you use upload while recording and you are recording a new video with the same session

    Declaration

    Swift

    public func reinitVideo()

recording

clip editing

  • Helper function that provides the location of the last recorded clip. This is helpful when merging multiple segments isn’t desired.

    Declaration

    Swift

    public var lastClipUrl: URL? { get }

    Return Value

    URL path to the last recorded clip.

  • Adds a specific clip to a session.

    Declaration

    Swift

    public func add(clip: VKRecorderClip)

    Parameters

    clip

    Clip to be added

  • Adds a specific clip to a session at the desired index.

    Declaration

    Swift

    public func add(clip: VKRecorderClip, at idx: Int)

    Parameters

    clip

    Clip to be added

    idx

    Index at which to add the clip

  • Adds/overrides clips with given clip array

    Declaration

    Swift

    public func setClips(clips: [VKRecorderClip])

    Parameters

    clips

    Clips to be overridden

  • Replaces an existing clip

    Declaration

    Swift

    public func replace(clip: VKRecorderClip, atIndex index: Int)

    Parameters

    clip

    Clip to be added

    index

    Index at which to replace the clip

  • Repositions a specific clip to a desired index. The clip is going to be removed from its current and inserted into the specified index (not replaced).

    Declaration

    Swift

    public func reposition(clip: VKRecorderClip, to indexTo: Int)

    Parameters

    clip

    Clip to be added

    idx

    Index at which to add the clip to

  • Repositions a specific clip by index to a new desired index. The clip is going to be removed from its current and inserted into the specified index (not replaced).

    Declaration

    Swift

    public func reposition(fromIndex indexFrom: Int, to indexTo: Int)

    Parameters

    clip

    Clip to be added

    idx

    Index at which to add the clip to

  • Removes a specific clip from a session.

    Declaration

    Swift

    public func remove(clip: VKRecorderClip)

    Parameters

    clip

    Clip to be removed

  • Removes a clip from a session at the desired index.

    Declaration

    Swift

    public func remove(clipAt idx: Int, removeFile: Bool)

    Parameters

    idx

    Index of the clip to remove

    removeFile

    True to remove the associated file with the clip

  • Removes and destroys all clips for a session.

    Declaration

    Swift

    public func removeAllClips(removeFiles: Bool = true)

    Parameters

    removeFiles

    When true, associated files are also removed.

  • Removes the last recorded clip for a session, “Undo”.

    Declaration

    Swift

    public func removeLastClip()
  • Completion handler type for merging clips, optionals indicate success or failure when nil

    Declaration

    Swift

    public typealias VKRecorderSessionMergeClipsCompletionHandler = (URL?, Error?) -> Void
  • Merges all existing recorded clips in the session and exports to a file.

    Declaration

    Swift

    public func mergeClips(usingPreset preset: String, completionHandler: @escaping VKRecorderSessionMergeClipsCompletionHandler)

    Parameters

    preset

    AVAssetExportSession preset name for export

    completionHandler

    Handler for when the merging process completes