All Projects → NextLevel → Nextlevelsessionexporter

NextLevel / Nextlevelsessionexporter

Licence: mit
🔄 Export and transcode media in Swift

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Nextlevelsessionexporter

Avfoundationrecorder
Swift audio recorder using AVFoundation
Stars: ✭ 174 (+2.35%)
Mutual labels:  audio, avfoundation
Soundable
Soundable allows you to play sounds, single and in sequence, in a very easy way
Stars: ✭ 78 (-54.12%)
Mutual labels:  audio, avfoundation
Aural Player
An audio player for macOS, inspired by Winamp for Windows.
Stars: ✭ 256 (+50.59%)
Mutual labels:  audio, avfoundation
Sbplayer ios
基于AVPlayer封装的轻量级播放器,可播放本地及网络视频,易于定制
Stars: ✭ 134 (-21.18%)
Mutual labels:  audio, avfoundation
Cabbage
A video composition framework build on top of AVFoundation. It's simple to use and easy to extend.
Stars: ✭ 1,030 (+505.88%)
Mutual labels:  audio, avfoundation
Avdemo
Demo projects for iOS Audio & Video development.
Stars: ✭ 136 (-20%)
Mutual labels:  audio, avfoundation
Pcmtowav
🎵PHP实现PCM格式音波文件转WAV格式音频文件
Stars: ✭ 160 (-5.88%)
Mutual labels:  audio
Dynamicaudio.js
An interface for the Web Audio API with a Flash shim for older browsers
Stars: ✭ 164 (-3.53%)
Mutual labels:  audio
Ni Media
NI Media is a C++ library for reading and writing audio streams.
Stars: ✭ 158 (-7.06%)
Mutual labels:  audio
Img Encode
Encode an image to sound and view it as a spectrogram - turn your images into music
Stars: ✭ 157 (-7.65%)
Mutual labels:  audio
Ifme
Powerful x265 GUI Encoder
Stars: ✭ 168 (-1.18%)
Mutual labels:  audio
Xrnx
The official Renoise Lua Scripting repository
Stars: ✭ 165 (-2.94%)
Mutual labels:  audio
Q Municate Ios
Q-municate iOS repository
Stars: ✭ 164 (-3.53%)
Mutual labels:  audio
Datmusic Api
Alternative for VK Audio API
Stars: ✭ 160 (-5.88%)
Mutual labels:  audio
Ardour
Mirror of Ardour Source Code
Stars: ✭ 2,318 (+1263.53%)
Mutual labels:  audio
Spectrogram
Audio spectrogram in canvas.
Stars: ✭ 158 (-7.06%)
Mutual labels:  audio
Simplycoreaudio
A Swift framework that aims to make Core Audio use less tedious in macOS
Stars: ✭ 167 (-1.76%)
Mutual labels:  audio
React Native Quiet
🤫 Quiet for React Native.
Stars: ✭ 158 (-7.06%)
Mutual labels:  audio
Vuejs Sound Player
▶️ 🎹 🎵 HTML5 <audio> tag sound player UI for Vue.js - supports single, loop, pause/stop modes etc
Stars: ✭ 164 (-3.53%)
Mutual labels:  audio
Glow
mpv Config File Generator for Windows
Stars: ✭ 167 (-1.76%)
Mutual labels:  audio

NextLevelSessionExporter 🔄

NextLevelSessionExporter is an export and transcode media library for iOS written in Swift.

Build Status Pod Version Swift Version GitHub license

The library provides customizable audio and video encoding options unlike AVAssetExportSession and without having to learn the intricacies of AVFoundation. It was a port of SDAVAssetExportSession with inspiration from SCAssetExportSession – which are great obj-c alternatives.

  • Looking for a capture library? Check out NextLevel.
  • Looking for a video player? Check out Player

Need a different version of Swift?

  • 5.0 - Target your Podfile to the latest release or master
  • 4.2 - Target your Podfile to the swift4.2 branch
  • 4.0 - Target your Podfile to the swift4.0 branch

Quick Start

# CocoaPods

pod "NextLevelSessionExporter", "~> 0.4.5"

# Carthage

github "nextlevel/NextLevelSessionExporter" ~> 0.4.5

# Swift PM

let package = Package(
    dependencies: [
        .Package(url: "https://github.com/nextlevel/NextLevelSessionExporter", majorVersion: 0)
    ]
)

Alternatively, drop the source files into your Xcode project.

Example

Simply use the AVAsset extension or create and use an instance of NextLevelSessionExporter directly.

let tmpURL = URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true)
    .appendingPathComponent(ProcessInfo().globallyUniqueString)
    .appendingPathExtension("mp4")
exporter.outputURL = tmpURL

let compressionDict: [String: Any] = [
    AVVideoAverageBitRateKey: NSNumber(integerLiteral: 6000000),
    AVVideoProfileLevelKey: AVVideoProfileLevelH264HighAutoLevel as String,
]
let videoOutputConfig = [
    AVVideoCodecKey: AVVideoCodec.h264,
    AVVideoWidthKey: NSNumber(integerLiteral: 1920),
    AVVideoHeightKey: NSNumber(integerLiteral: 1080),
    AVVideoScalingModeKey: AVVideoScalingModeResizeAspectFill,
    AVVideoCompressionPropertiesKey: compressionDict
]
let audioOutputConfig = [
    AVFormatIDKey: kAudioFormatMPEG4AAC,
    AVEncoderBitRateKey: NSNumber(integerLiteral: 128000),
    AVNumberOfChannelsKey: NSNumber(integerLiteral: 2),
    AVSampleRateKey: NSNumber(value: Float(44100))
]

let asset = AVAsset(url: Bundle.main.url(forResource: "TestVideo", withExtension: "mov")!)
asset.nextlevel_export(outputURL: tmpURL, videoOutputConfiguration: videoOutputConfig, audioOutputConfiguration: audioOutputConfig)

Alternatively, you can use NextLevelSessionExporter directly.

let exporter = NextLevelSessionExporter(withAsset: asset)
exporter.outputFileType = AVFileType.mp4
let tmpURL = URL(fileURLWithPath: NSTemporaryDirectory(), isDirectory: true)
    .appendingPathComponent(ProcessInfo().globallyUniqueString)
    .appendingPathExtension("mp4")
exporter.outputURL = tmpURL

let compressionDict: [String: Any] = [
    AVVideoAverageBitRateKey: NSNumber(integerLiteral: 6000000),
    AVVideoProfileLevelKey: AVVideoProfileLevelH264HighAutoLevel as String,
]
exporter.videoOutputConfiguration = [
    AVVideoCodecKey: AVVideoCodec.h264,
    AVVideoWidthKey: NSNumber(integerLiteral: 1920),
    AVVideoHeightKey: NSNumber(integerLiteral: 1080),
    AVVideoScalingModeKey: AVVideoScalingModeResizeAspectFill,
    AVVideoCompressionPropertiesKey: compressionDict
]
exporter.audioOutputConfiguration = [
    AVFormatIDKey: kAudioFormatMPEG4AAC,
    AVEncoderBitRateKey: NSNumber(integerLiteral: 128000),
    AVNumberOfChannelsKey: NSNumber(integerLiteral: 2),
    AVSampleRateKey: NSNumber(value: Float(44100))
]

exporter.export(progressHandler: { (progress) in
    print(progress)
}, completionHandler: { result in
    switch result {
    case .success(let status):
        switch status {
        case .completed:
            print("NextLevelSessionExporter, export completed, \(exporter.outputURL?.description ?? "")")
            break
        default:
            print("NextLevelSessionExporter, did not complete")
            break
        }
        break
    case .failure(let error):
        print("NextLevelSessionExporter, failed to export \(error)")
        break
    }
})

Documentation

You can find the docs here. Documentation is generated with jazzy and hosted on GitHub-Pages.

Community

Resources

License

NextLevelSessionExporter is available under the MIT license, see the LICENSE file for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].