AVAssetWriterInputTaggedPixelBufferGroupAdaptor.appendTaggedBuff

ghz 8months ago ⋅ 92 views

I currently write an iOS app in Swift to do "Side-By-Side Video to MV-HEVC format" following the Apple Official document: Converting side-by-side 3D video to multiview HEVC.

The sample code by Apple is written for macOS command line, and I want to move it into an iOS app. When using totally the same conversion code in iOS, the line usually returns false during conversion:

if !bufferInputAdapter.appendTaggedBuffers(taggedBuffers, withPresentationTime: newPTS) {
    fatalError("Failed to append tagged buffers to multiview output")
}

I print out the newPTS for debugging, it returns false at different time and sometimes pass all the conversion. So I don't know where is the different from macOS and iOS.

Have I missed anything important that I should be aware of when it comes to iOS?

Answers

When moving code from macOS to iOS, there are several differences and considerations that may affect the behavior of your application:

  1. Resource Constraints: iOS devices typically have limited resources compared to macOS computers. Ensure that your iOS device has enough memory and processing power to handle the video conversion process, especially if you are working with large video files.

  2. App Sandbox: iOS apps run within a sandboxed environment, which restricts access to certain system resources and files. Make sure your app has the necessary permissions to access the video files and perform the required operations.

  3. Concurrency and Threading: iOS apps often perform long-running tasks, such as video conversion, on background threads to avoid blocking the main UI thread. Ensure that your video conversion code is executed asynchronously and does not block the main thread, which could lead to unresponsiveness or app termination.

  4. File System Differences: iOS uses a different file system structure compared to macOS. Ensure that your code properly handles file paths and file I/O operations, taking into account iOS-specific directories such as the app's sandboxed container and the Documents directory.

  5. iOS Frameworks and APIs: Certain macOS frameworks and APIs may not be available on iOS or may have different behavior. Ensure that you are using iOS-specific frameworks and APIs for tasks such as reading and writing files, working with audio and video, and managing system resources.

  6. Permission and Privacy: iOS apps require explicit user permission to access sensitive data such as camera, microphone, and photo library. If your app requires access to these resources for video conversion, make sure to request the appropriate permissions and handle user privacy considerations.

  7. Debugging and Testing: Use Xcode's debugging tools, such as breakpoints, logging, and the debugger console, to troubleshoot issues and inspect the state of your app during video conversion. Test your app on different iOS devices and configurations to ensure compatibility and performance.

By addressing these differences and considerations, you can optimize your iOS app for video conversion and ensure smooth and reliable operation on iOS devices. If you continue to encounter issues, consider consulting the official Apple documentation, developer forums, or seeking assistance from experienced iOS developers.