You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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](https://github.com/rs/SDAVAssetExportSession) with inspiration from [SCAssetExportSession](https://github.com/rFlex/SCRecorder/blob/master/Library/Sources/SCAssetExportSession.h) – which are great obj-c alternatives.
9
9
10
+
### ✨ What's New in Swift 6
11
+
12
+
-**🚀 Modern Async/Await API** - Native Swift concurrency support with `async/await` and `AsyncSequence`
13
+
-**⚡ Better Performance** - Proper memory management with autoreleasepool in encoding loop
14
+
-**🔒 Swift 6 Strict Concurrency** - Full `Sendable` conformance and thread-safety
createMetadataItem(key: .commonKeyTitle, value: "My Video"),
302
+
createMetadataItem(key: .commonKeyDescription, value: "Exported with NextLevelSessionExporter"),
303
+
]
304
+
exporter.metadata= metadata
305
+
```
306
+
307
+
## Performance & Best Practices
308
+
309
+
### Memory Management
310
+
311
+
The library automatically manages memory during export using autoreleasepool, preventing memory accumulation during long exports. This fix resolved [Issue #56](https://github.com/NextLevel/NextLevelSessionExporter/issues/56) where exports would crash after ~10 minutes.
312
+
313
+
### Task Cancellation
314
+
315
+
With the modern async API, exports are properly cancelled when the Task is cancelled:
316
+
317
+
```swift
318
+
let exportTask =Task {
319
+
tryawait exporter.export()
320
+
}
321
+
322
+
// Cancel export
323
+
exportTask.cancel() // Properly stops export and cleans up resources
324
+
```
325
+
326
+
### Progress Updates
327
+
328
+
For optimal UI responsiveness, update progress on the main actor:
329
+
330
+
```swift
331
+
fortryawait event in exporter.exportAsync() {
332
+
switch event {
333
+
case .progress(let progress):
334
+
await MainActor.run {
335
+
progressView.progress= progress
336
+
}
337
+
case .completed(let url):
338
+
awaithandleCompletion(url)
339
+
}
340
+
}
341
+
```
342
+
343
+
### Background Exports
344
+
345
+
For long exports, consider using background tasks:
346
+
347
+
```swift
348
+
let taskID =await UIApplication.shared.beginBackgroundTask()
**Problem:** Export fails when reading the source asset.
359
+
360
+
**Solutions:**
361
+
- Verify the source asset is not corrupted
362
+
- Check that the asset is a supported format (MP4, MOV, M4V, etc.)
363
+
- Ensure the asset is accessible and not protected by DRM
364
+
365
+
### Memory Issues on Long Videos
366
+
367
+
**Fixed in 1.0!** Previous versions had a memory leak causing crashes on videos longer than 10 minutes. Update to 1.0 or later.
368
+
369
+
### Export is Slow
370
+
371
+
**Tips:**
372
+
- Lower the video bitrate and resolution for faster exports
373
+
- Use H.264 instead of HEVC for better encoding speed
374
+
- Avoid frame-by-frame processing if not needed
375
+
- Test on a physical device (simulator performance varies)
376
+
377
+
### Video Orientation is Wrong
378
+
379
+
The library automatically handles video orientation and transforms. If you're experiencing issues:
380
+
- Let the library create the video composition automatically (don't set `videoComposition`)
381
+
- Ensure your video output configuration includes proper width/height
382
+
383
+
### Audio Track Missing
384
+
385
+
**Issue:** Some videos export without audio.
386
+
387
+
**Solution:** This was fixed in 1.0. The library now properly filters APAC audio tracks that cause export failures. Update to the latest version.
388
+
118
389
## Documentation
119
390
120
391
You can find [the docs here](https://nextlevel.github.io/NextLevelSessionExporter). Documentation is generated with [jazzy](https://github.com/realm/jazzy) and hosted on [GitHub-Pages](https://pages.github.com).
0 commit comments