Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rs/SDAVAssetExportSession
AVAssetExportSession drop-in replacement with customizable audio&video settings
https://github.com/rs/SDAVAssetExportSession
Last synced: about 1 month ago
JSON representation
AVAssetExportSession drop-in replacement with customizable audio&video settings
- Host: GitHub
- URL: https://github.com/rs/SDAVAssetExportSession
- Owner: rs
- License: mit
- Created: 2013-04-13T19:41:37.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2020-09-04T12:38:33.000Z (over 4 years ago)
- Last Synced: 2024-10-30T02:36:30.577Z (about 1 month ago)
- Language: Objective-C
- Homepage:
- Size: 63.5 KB
- Stars: 803
- Watchers: 41
- Forks: 211
- Open Issues: 46
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- Awesome-iOS - SDAVAssetExportSession - AVAssetExportSession drop-in replacement with customizable audio&video settings (Media)
README
SDAVAssetExportSession
======================`AVAssetExportSession` drop-in replacement with customizable audio&video settings.
You want the ease of use of `AVAssetExportSession` but default provided presets doesn't fit your needs? You then began to read documentation for `AVAssetWriter`, `AVAssetWriterInput`, `AVAssetReader`, `AVAssetReaderVideoCompositionOutput`, `AVAssetReaderAudioMixOutput`… and you went out of aspirin? `SDAVAssetExportSession` is a rewrite of `AVAssetExportSession` on top of `AVAssetReader*` and `AVAssetWriter*`. Unlike `AVAssetExportSession`, you are not limited to a set of presets – you have full access over audio and video settings.
Usage Example
-------------``` objective-c
SDAVAssetExportSession *encoder = [SDAVAssetExportSession.alloc initWithAsset:anAsset];
encoder.outputFileType = AVFileTypeMPEG4;
encoder.outputURL = outputFileURL;
encoder.videoSettings = @
{
AVVideoCodecKey: AVVideoCodecH264,
AVVideoWidthKey: @1920,
AVVideoHeightKey: @1080,
AVVideoCompressionPropertiesKey: @
{
AVVideoAverageBitRateKey: @6000000,
AVVideoProfileLevelKey: AVVideoProfileLevelH264High40,
},
};
encoder.audioSettings = @
{
AVFormatIDKey: @(kAudioFormatMPEG4AAC),
AVNumberOfChannelsKey: @2,
AVSampleRateKey: @44100,
AVEncoderBitRateKey: @128000,
};[encoder exportAsynchronouslyWithCompletionHandler:^
{
if (encoder.status == AVAssetExportSessionStatusCompleted)
{
NSLog(@"Video export succeeded");
}
else if (encoder.status == AVAssetExportSessionStatusCancelled)
{
NSLog(@"Video export cancelled");
}
else
{
NSLog(@"Video export failed with error: %@ (%d)", encoder.error.localizedDescription, encoder.error.code);
}
}];```
Licenses
--------All source code is licensed under the [MIT-License](https://github.com/rs/SDAVAssetExportSession/blob/master/LICENSE).