Questions tagged [avassetexportsession]

An AVAssetExportSession object transcodes the contents of an AVAsset source object to create an output of the form described by a specified export preset.

Prior to initializing an instance of AVAssetExportSession, you can use allExportPresets to get the complete list of presets available. Use exportPresetsCompatibleWithAsset: to get a list of presets that are compatible with a specific asset.

After you have initialized an export session with the asset that contains the source media, the export preset name (presetName), and the output file type (outputFileType), you can start the export running by invoking exportAsynchronouslyWithCompletionHandler:. Because the export is performed asynchronously, this method returns immediately—you can use progress to check on the progress. Depending on the capabilities of the device, some exports may be queued when multiple exports are attempted. When this happens, the status of a queued export will indicate that it's waiting (AVAssetExportSessionStatusWaiting).

The completion handler you supply to exportAsynchronouslyWithCompletionHandler: is called whether the export fails, completes, or is cancelled. Upon completion, the status property indicates whether the export has completed successfully. If it has failed, the value of the error property supplies additional information about the reason for the failure.

Click Here for Apple documentation of AVAssetExportSession

349 questions
28
votes
5 answers

AVAssetExportSession export fails non-deterministically with error: "Operation Stopped, NSLocalizedFailureReason=The video could not be composed."

We add subtitles to a video recorded by the user, but the export by our AVAssetExportSession object fails non-deterministically: sometimes it works, and sometimes it doesn't. It's unclear even how to reproduce the error. We noticed the asset tracks…
Crashalot
  • 33,605
  • 61
  • 269
  • 439
28
votes
1 answer

What does shouldOptimizeForNetworkUse actually do?

From the Apple documentation it just says: When the value of this property is YES, the output file will be written in such a way that playback can start after only a small amount of the file is downloaded. But what is actually happening?
26
votes
2 answers

Swift: UnsafeMutablePointer.deinitialize fatal error with negative count when appending to array

The code below generates this error (appending to exporters): fatal error: UnsafeMutablePointer.deinitialize with negative count var exporters = [AVAssetExportSession]() let exporter = AVAssetExportSession(asset: mainComposition,…
Crashalot
  • 33,605
  • 61
  • 269
  • 439
25
votes
5 answers

Progress bar for AVAssetExportSession

I've got an app that exports an AVMutableComposition into a .mov file, and I'd like for the user to see the status of the export with a progress bar the same way that you would if you sent a text message or uploaded a file. I know how to create a…
Orpheus Mercury
  • 1,617
  • 2
  • 15
  • 30
23
votes
1 answer

How to properly use AVAssetExportSession to set metadata for an audio asset?

I have looked at every example I can find for setting meta data using AVAssetExportSession, but even though the audio export works fine ( resultant audio file plays OK ), there's still no meta data exported with the file. I'm using Xcode 4.5, target…
user15209
  • 231
  • 2
  • 4
19
votes
2 answers

Custom AVVideoCompositing class not working as expected

I'm attempting to apply a CIFilter to an AVAsset, and then save it with the filter applied. The way that I am doing this is by using an AVAssetExportSession with videoComposition set to an AVMutableVideoComposition object with a custom…
Jojodmo
  • 23,357
  • 13
  • 65
  • 107
18
votes
3 answers

AVAssetExportSession failed with unknown error -12780 for specific video

I have a problem tracing the underlying issue behind my asset export session failure. The issue is for one video only, and I believe the problem is in its audio track, since I successfully exported the asset without the audio track (only the video…
17
votes
4 answers

AVAssetExportSession stops progressing

I'm having a problem with AVAssetExportSession where the progress stops increasing but the status still says that it is exporting. This is actually a pretty rare occurrence, it works flawlessly about 99.99% of the time, but I want to fix the problem…
poiuy_qwert
  • 327
  • 5
  • 14
16
votes
4 answers

how to trim a video in swift for a particular time

I am working on a task in which I have to trim the recorded video from particular start point to particular end point as entered or selected by user. How am I supposed to do that. As I used UIVideoEditorController before but I don't want to use the…
Parv Bhasker
  • 1,773
  • 1
  • 20
  • 39
16
votes
4 answers

AVAssetExport fails for some files

I have tried to export audio file from the iPod-Library. My objective is to create new file in app Document folder with this iPod-Library file .Its fails to create files for some items only . Below is my code snippet. AVURLAsset *songAsset =…
Kannan Prasad
  • 1,796
  • 22
  • 27
15
votes
4 answers

Swift 3: How to add watermark on video ? AVVideoCompositionCoreAnimationTool iOS 10 issue

This code used to work on iOS9 to add a watermark and text to a video but since iOS10 it's not working anymore. There is a iOS 10 bug that has been filed but no answer from Apple. I have not been able to implement any workaround to add watermark and…
Sam
  • 1,101
  • 2
  • 13
  • 26
15
votes
5 answers

AVAssetExportSession giving me a green border on right and bottom of output video

Here's the code: AVAssetExportSession *exporter = [[AVAssetExportSession alloc] initWithAsset:mixComposition presetName:AVAssetExportPresetHighestQuality]; exporter.outputURL = outputUrl; exporter.outputFileType =…
14
votes
1 answer

AVVideoCompositionCoreAnimationTool and CALayer in portrait mode?

I'm trying to bake a CALayer into portrait-mode video (on export) using an AVMutableComposition, an AVMutableVideoComposition and a AVVideoCompositionCoreAnimationTool on iOS 4.3. This all works in landscape. If I capture video in portrait,…
wombat57
  • 1,341
  • 1
  • 13
  • 26
13
votes
3 answers

Swift - Compressing video files

So, at the moment I am using this to compress video: func compressVideo(inputURL: NSURL, outputURL: NSURL, handler:(session: AVAssetExportSession)-> Void) { let urlAsset = AVURLAsset(URL: inputURL, options: nil) let…
Roduck Nickes
  • 1,021
  • 2
  • 15
  • 41
13
votes
2 answers

Cropping AVAsset video with AVFoundation

I am using AVCaptureMovieFileOutput to record some video. I have the preview layer displayed using AVLayerVideoGravityResizeAspectFill which zooms in slightly. The problem I have is that the final video is larger, containing extra image that didn't…
Darren
  • 10,182
  • 20
  • 95
  • 162
1
2 3
23 24