About NextLevelSessionExporter
NextLevelSessionExporter is a powerful and easy-to-use library for exporting media sessions in iOS applications. It provides developers with a comprehensive set of tools to efficiently manage and export audio and video sessions recorded using the NextLevel library. With NextLevelSessionExporter, you can effortlessly handle session trimming, exporting, and customization, while ensuring high-quality media output.
Key Features
- Effortlessly export media sessions to various formats
- Handle session trimming with ease
- Customize video output settings including size, bitrate, and codec
- Apply video filters and transformations
- Export audio sessions as various file formats
- Securely encrypt exported sessions
- Support for multi-track audio and video sessions
Installation
To integrate NextLevelSessionExporter into your iOS project, follow the steps below:
- Ensure you have the latest version of CocoaPods installed.
- Add the following line to your
Podfile
:
pod 'NextLevelSessionExporter', '~> 2.0'
- Save the
Podfile
and run the commandpod install
in Terminal. - Open the generated
.xcworkspace
file. - Import
NextLevelSessionExporter
in your Swift file:
import NextLevelSessionExporter
Getting Started
To begin using NextLevelSessionExporter, you need to follow these steps:
1. Export a Session
To export a media session, you first need to create an instance of NLSessionExporter
. Then, specify the input URL of the session, the output URL for the exported session, and any desired export settings. Finally, call the exportAsynchronously
method to start the export process.
// Code example to export a session
let exporter = NLSessionExporter()
exporter.inputURL = inputURL
exporter.outputURL = outputURL
exporter.exportSettings = exportSettings
exporter.exportAsynchronously { (error) in
// Check for and handle any errors
if let error = error {
print("Export failed: \(error)")
} else {
print("Export succeeded!")
}
}
2. Trim a Session
If you need to trim a session before exporting, you can use the trimTimeRange
property of NLSessionExporter
. Simply set the desired time range to be exported, and then call the exportAsynchronously
method as shown above.
// Code example to trim and export a session
let exporter = NLSessionExporter()
exporter.inputURL = inputURL
exporter.outputURL = outputURL
exporter.exportSettings = exportSettings
exporter.trimTimeRange = CMTimeRangeMake(start: startTime, duration: duration)
exporter.exportAsynchronously { (error) in
// Check and handle errors
if let error = error {
print("Export failed: \(error)")
} else {
print("Export succeeded!")
}
}
Advanced Settings
NextLevelSessionExporter provides a range of advanced settings to customize the output session. Below are some examples:
1. Export Video
To customize video settings, you can use the videoSettings
property of NLAVAssetExportSession
. This allows you to specify video size, bitrate, codec, and other parameters.
// Code example to customize video settings
let assetExport = NLAVAssetExportSession(asset: asset)
assetExport.outputURL = outputURL
assetExport.outputFileType = AVFileType.mp4
let videoSettings = [
AVVideoCodecKey: AVVideoCodecType.h264,
AVVideoWidthKey: 1280,
AVVideoHeightKey: 720,
AVVideoCompressionPropertiesKey: [
AVVideoAverageBitRateKey: 2000000
]
]
assetExport.videoSettings = videoSettings
assetExport.exportAsynchronously { (error) in
// Check and handle errors
if let error = error {
print("Export failed: \(error)")
} else {
print("Export succeeded!")
}
}
2. Export Audio
To export only the audio part of a session, you can specify the desired audio outputFileType
and use the audioSettings
property of NLAVAssetExportSession
to customize audio output settings.
// Code example to customize audio settings
let assetExport = NLAVAssetExportSession(asset: asset)
assetExport.outputURL = outputURL
assetExport.outputFileType = AVFileType.aiff
assetExport.audioSettings = [
AVFormatIDKey: kAudioFormatLinearPCM,
AVSampleRateKey: 44100,
AVNumberOfChannelsKey: 2,
AVLinearPCMBitDepthKey: 16,
AVLinearPCMIsBigEndianKey: false,
AVLinearPCMIsFloatKey: false
]
assetExport.exportAsynchronously { (error) in
// Check and handle errors
if let error = error {
print("Export failed: \(error)")
} else {
print("Export succeeded!")
}
}
Conclusion
NextLevelSessionExporter is a must-have library for managing and exporting media sessions in iOS applications. With its extensive features and customizable settings, it simplifies the export process and provides high-quality output. Whether you need to export videos, trim sessions, or customize audio settings, NextLevelSessionExporter has you covered. Start using NextLevelSessionExporter today and take your media session exports to the next level!