Post not yet marked as solved
Our app is receiving more of these 2 errors recently. But there is 0 documentation or search result about these 2 errors. Anyone know what they mean?
CoreMediaErrorDomain: -16934
CoreMediaErrorDomain: 28
Post not yet marked as solved
Hi!
I'm trying to move from CoreMedio I/O DAL Plug-In to CoreMedia I/O camera extensions, announced in macOS 12.3.
I created a test extension, placed it inside my app bundle into Contents/Library/SystemExtensions and signed with codesigning certificate. But when I try to install my extension from inside my app, using this code (Swift):
func requestActivation() {
guard case .idle = status
else { fatalError("Invalid state") }
print("Requesting activation of extension \"\(extensionIdentifier)\"")
let req = OSSystemExtensionRequest.activationRequest(forExtensionWithIdentifier: extensionIdentifier, queue: DispatchQueue.main)
req.delegate = self
OSSystemExtensionManager.shared.submitRequest(req)
status = .requested
}
I'm getting an error:
OSSystemExtensionErrorDomain error 8: Code Signature Invalid
which is rather generic. Can anybody tell me what I am doing wrong? Or at least propose some steps to find it out?
I'm posting here entitlements and codesign output for my extension and containing application for further information.
kdg@admins-Mac-mini SystemExtensions % codesign -d --entitlements - ./com.visicom.VirtualCamera.avextension.systemextension
Executable=/Applications/VirtualCamera.app/Contents/Library/SystemExtensions/com.visicom.VirtualCamera.avextension.systemextension/Contents/MacOS/com.visicom.VirtualCamera.avextension
[Dict]
[Key] com.apple.security.app-sandbox
[Value]
[Bool] true
[Key] com.apple.security.application-groups
[Value]
[Array]
[String] 6SUWV7QQBJ.com.visicom.VirtualCamera
kdg@admins-Mac-mini /Applications % codesign -d --entitlements - ./VirtualCamera.app
Executable=/Applications/VirtualCamera.app/Contents/MacOS/VirtualCamera
[Dict]
[Key] com.apple.developer.system-extension.install
[Value]
[Bool] true
[Key] com.apple.security.app-sandbox
[Value]
[Bool] true
[Key] com.apple.security.application-groups
[Value]
[Array]
[String] 6SUWV7QQBJ.com.visicom.VirtualCamera
[Key] com.apple.security.files.user-selected.read-only
[Value]
[Bool] true
kdg@admins-Mac-mini SystemExtensions % codesign -dvvv ./com.visicom.VirtualCamera.avextension.systemextension
Executable=/Applications/VirtualCamera.app/Contents/Library/SystemExtensions/com.visicom.VirtualCamera.avextension.systemextension/Contents/MacOS/com.visicom.VirtualCamera.avextension
Identifier=com.visicom.VirtualCamera.avextension
Format=bundle with Mach-O universal (x86_64 arm64)
CodeDirectory v=20500 size=1553 flags=0x10700(hard,kill,expires,runtime) hashes=37+7 location=embedded
Hash type=sha256 size=32
CandidateCDHash sha256=25bd80657bfd6e0ab95467146c7b532817e9e520
CandidateCDHashFull sha256=25bd80657bfd6e0ab95467146c7b532817e9e5209fd50b0cb7ceef40dcfb40e8
Hash choices=sha256
CMSDigest=25bd80657bfd6e0ab95467146c7b532817e9e5209fd50b0cb7ceef40dcfb40e8
CMSDigestType=2
CDHash=25bd80657bfd6e0ab95467146c7b532817e9e520
Signature size=9006
Authority=Developer ID Application: Visicom Media Inc. (6SUWV7QQBJ)
Authority=Developer ID Certification Authority
Authority=Apple Root CA
Timestamp=7 Jul 2022, 21:49:32
Info.plist entries=23
TeamIdentifier=6SUWV7QQBJ
Runtime Version=12.3.0
Sealed Resources version=2 rules=13 files=0
Internal requirements count=1 size=200
kdg@admins-Mac-mini /Applications % codesign -dvvv ./VirtualCamera.app
Executable=/Applications/VirtualCamera.app/Contents/MacOS/VirtualCamera
Identifier=com.visicom.VirtualCamera
Format=app bundle with Mach-O universal (x86_64 arm64)
CodeDirectory v=20500 size=1989 flags=0x10700(hard,kill,expires,runtime) hashes=51+7 location=embedded
Hash type=sha256 size=32
CandidateCDHash sha256=31e15fbbd436a67a20c5b58c597d8a4796a67720
CandidateCDHashFull sha256=31e15fbbd436a67a20c5b58c597d8a4796a6772020308fb69f4ee80b4e32788b
Hash choices=sha256
CMSDigest=31e15fbbd436a67a20c5b58c597d8a4796a6772020308fb69f4ee80b4e32788b
CMSDigestType=2
CDHash=31e15fbbd436a67a20c5b58c597d8a4796a67720
Signature size=9006
Authority=Developer ID Application: Visicom Media Inc. (6SUWV7QQBJ)
Authority=Developer ID Certification Authority
Authority=Apple Root CA
Timestamp=7 Jul 2022, 21:58:09
Info.plist entries=20
TeamIdentifier=6SUWV7QQBJ
Runtime Version=12.3.0
Sealed Resources version=2 rules=13 files=4
Internal requirements count=1 size=188
Thanks in advance!
Post not yet marked as solved
I am trying to calculate frame rate of a video format based on CMFormatDescription but I'm getting strange output that I do not know what to do with. According to the documentation, "value/timescale = seconds". This is also the answer in this question.
The code is being called while getting a video stream from FaceTime camera:
let av = device.activeFormat
let fd = av.formatDescription
print("time scale",fd.frameDuration.timescale)
print("value",fd.frameDuration.value)
print("value/timescale=",fd.frameDuration.value)/Int64(fd.frameDuration.timescale))
This is the output:
time scale 480
value 2749654773878
value/timescale= 5728447445.579166
Time scale is always == height (of the format description) - I also tried with another usb camera.
Post not yet marked as solved
_streamSinkIn = [[CMIOExtensionStream alloc] initWithLocalizedName:localizedName
streamID:streamInputID
direction:CMIOExtensionStreamDirectionSink clockType:CMIOExtensionStreamClockTypeHostTime
source:self];
Attempting to publish a CMIOExtensionStream with the 'sink' direction (i.e. print-to-tape) as alluded to in Brad Ford's presentation. Any attempt to create such a stream yields and invalid argument exception and if you examine the header files all the init methods are described as returning stream instances that source data (ie camera publishers).
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid argument'
Post not yet marked as solved
I struggle to add custom properties to my streams as described in the WWDC22 video https://developer.apple.com/videos/play/wwdc2022/10022/
minute 28:17
The speaker describes using this technique in his CIFilterCam demo (would the source code be available please?) to let the app control which filter the extension should apply.
Presumably, there's thus a way to:
1 - define a custom property in the camera extension's stream/device/provider?
2 - be able to use CoreMediaIO (from Swift?) in the app in order to set values of that custom property.
This is not documented anywhere I could find.
Help and sample code would be greatly appreciated.
Thank you.
Laurent
Post not yet marked as solved
While trying to re-create the CIFilterCam demo shown in the WWDC session, I hit a roadblock when trying to access a hardware camera from inside my extension.
Can I simply use an AVCaptureSession + AVCaptureDeviceInput + AVCaptureVideoDataOutput to get frames from an actual hardware camera and pass them to the extension's stream? If yes, when should I ask for camera access permissions?
It seems the extension code is run as soon as I install the extension, but I never get prompted for access permission. Do I need to set up the capture session lazily? What's the best practice for this use case?
Post not yet marked as solved
It’d be nice if the extension could inherit the permissions given to the main app by the user, in my case screen capture.
Alternatively, is there a way to send data to the extension from the app, or vice versa?
Especially image or video data.
thanks!
laurent
Post not yet marked as solved
Hi, I have been following the steps presented in
https://developer.apple.com/documentation/coremediaio/creating_a_camera_extension_with_core_media_i_o
to create a core media I/O camera.
However when calling
let activationRequest = OSSystemExtensionRequest.activationRequest(
forExtensionWithIdentifier: identifier, queue: .main
)
activationRequest.delegate = installDelegate
OSSystemExtensionManager.shared.submitRequest(activationRequest)
The delegate's request(_ request: OSSystemExtensionRequest, didFailWithError error: Error) method is being called with error code 9 (OSSystemExtensionError.Code.validationFailed) and the system dialog does not appear.
Post not yet marked as solved
Hi everyone,
I am having a problem on AVPlayer when I try to play some videos.
The video starts for a few seconds, but immediately after I see a black screen and in the console there is the following error:
https://...manifest.m3u8 -12642 "CoreMediaErrorDomain" "Impossibile completare l'operazione. (Errore CoreMediaErrorDomain -12642 - No matching mediaFile found from playlist)"
-12880 "CoreMediaErrorDomain" "Can not proceed after removing variants" -
The strange thing is that if I try to play the same video on multiple devices, the result is that on someone it works and on someone it does not. For example on iPhone 5SE works and on iPad Pro 11'' II gen. and iPhone11
I've tried searching around to figure out what may be causing the problem, but there doesn't seem to be a clear solution.
Anyone who has had a similar problem? Do you have any ideas about the reason for this problem?
Post not yet marked as solved
I built an app which hosts a CMIOExtension. The app works, and it can activate the extension. The extension loads in e.g. Photo Booth and shows the expected video (a white horizontal line which moves down the picture).
I have a couple of questions about this though.
The sample Camera Extension is built with a CMIOExtension dictionary with just one entry, CMIOExtensionMachServiceName which is $(TeamIdentifierPrefix)$(PRODUCT_BUNDLE_IDENTIFIER)
This Mach service name won't work though. When attempting to activate the extension, sysextd says that the extensions has an invalid mach service name or is not signed, the value must be prefixed with one of the App Groups in the entitlement.
So in order to get the sample extension to activate from my app, I have to change its CMIOExtensionMachServiceName to
<my team ID>.com.mycompany.my-app-group.<myextensionname>
Is this to be expected?
The template CMIOExtension generates its own video using a timer. My app is intended to capture video from a source, filter that video, then feed it to the CMIOExtension, somehow. The template creates an app group called "$(TeamIdentifierPrefix)com.example.app-group", which suggests that it might be possible to use XPC to send frames from the app to the extension.
However, I've been unable to do so. I've used
NSXPCConnection * connection = [[NSXPCConnection alloc] initWithMachServiceName:, using the CMIOExtensionMachServiceName with no options and with the NSXPCConnectionPrivileged option. I've tried NSXPCConnection * connection = [[NSXPCConnection alloc] initWithServiceName: using the extension's bundle identifier. In all cases when I send the first message I get an error in the remote object proxy's handler:
Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named <whatever name I try> was invalidated: failed at lookup with error 3 - No such process."
According to the "Daemons and Services Programming Guide" an XPC service should have a CFBundlePackageType of XPC!, but a CMIOExtension is of type SYSX. It can't be both.
Does the CMIOExtension loading apparatus cook up a synthetic name for the XPC service, and if so, what is it? If none, how is one expected to get pixel buffers into the camera extension?
Hi.
Our NWListener runs fine and accepts connections successfully when it's run in a standalone app, however, the same code fails when moved into the System Extension code.
Specifically, we get the error: The operation couldn’t be completed. (Network.NWError error 0.)
...
let listener = try NWListener(using: params!)
listener.service = NWListener.Service(name: "service",
type: "_service._tcp")
listener.stateUpdateHandler = { newState in
switch newState {
case .ready:
if let port = listener.port {
self.receiveIncomingDataOnConnection()
}
case .failed(let error):
listener.cancel()
print("Listener - failed with %{public}@, restarting", error.localizedDescription)
// Getting the error ^
default:
break
}
}
...
We have checked that the App Sandbox permissions for inbound and outbound connections are set in the entitlements file.
At this point, we are stumped at what's limiting our listener when it's running in the extension.
Thanks!
Post not yet marked as solved
In the example of the Core Media IO there is a mach server that is providing the samples to the plugin (in the example it is a getting the samples from a yuv file). The architecture of OBS is similar. The mach server is reading from a camera or from from a file and provides the samples to the plugin.
Why do we need the mach server? I've implemented a virtual webcam where the plugin is capturing samples from a webcam (either the built in webcam or a USB one). It seems to be more efficient though I guess that there is a reason for doing this with a mach server. What is the reason?
Post not yet marked as solved
When playing several short HLS clips using AVPlayer connected to a TV using Apple's Lightning-to-HDMI adapter (A1438) we often fail with those unknown errors.
CoreMediaErrorDomain -12034
and
CoreMediaErrorDomain -12158
Anyone has any clue what the errors mean?
Environment:
iPhone8
iOS 15.4
Lightning-to-HDMI adapter (A1438)
Post not yet marked as solved
I had successfully added the new template Camera Extension to a project, and was able to use it in MacOS 12.3 Beta 3. After updating to the RC version of MacOS 12.3, the extension no longer appears in (for example) Quicktime Player.
As far as the application is concerned, the requests to "update" the extension work, and I get an OSSystemExtensionRequest.Result.completed response from OSSystemExtensionManager.shared.submitRequest.
The only clue I see is an error in the Console app:
RegisterAssistantService.m:806:-[RegisterAssistantServer launchdJobForExtension:error:] submit returned Error Domain=OSLaunchdErrorDomain Code=125 UserInfo={NSLocalizedFailureReason=<private>} for {
EnablePressuredExit = 1;
Label = "CMIOExtension.app.mmhmm.CameraTest.camera";
LaunchEvents = {
"com.apple.cmio.registerassistantservice.system-extensions.matching" = {
"app.mmhmm.CameraTest.camera" = {
CMIOExtensionBundleIdentifier = "app.mmhmm.CameraTest.camera";
};
};
};
LimitLoadToSessionType = Background;
MachServices = {
"M3KUT44L48.app.mmhmm.CameraTest.camera" = 1;
};
ProcessType = Interactive;
Program = "/Library/SystemExtensions/9D731619-32C2-45C4-9B7C-2F22D184868A/app.mmhmm.CameraTest.camera.systemextension/Contents/MacOS/app.mmhmm.CameraTest.camera";
SandboxProfile = cmioextension;
"_ManagedBy" = "com.apple.cmio.registerassistantservice";
}
Any ideas? Submitting a deactivationRequest also apparently "works", but doesn't actually seem to remove the installed extension...
Edit: Weirdly, rebooting seems to have cleared up the issue.
When I ran systemextensionsctl list, I got a bunch of SE reported as "[terminated waiting to uninstall on reboot]":
% systemextensionsctl list
9 extension(s)
--- com.apple.system_extension.cmio
enabled active teamID bundleID (version) name [state]
M3KUT44L48 app.mmhmm.CameraTest.camera (1.0/1) camera [terminated waiting to uninstall on reboot]
M3KUT44L48 app.mmhmm.CameraTest.camera (1.0/1) camera [terminated waiting to uninstall on reboot]
M3KUT44L48 app.mmhmm.CameraTest.camera (1.0/1) camera [terminated waiting to uninstall on reboot]
M3KUT44L48 app.mmhmm.CameraTest.camera (1.0/1) camera [terminated waiting to uninstall on reboot]
M3KUT44L48 app.mmhmm.CameraTest.camera (1.0/1) camera [terminated waiting to uninstall on reboot]
M3KUT44L48 app.mmhmm.CameraTest.camera (1.0/1) camera [terminated waiting to uninstall on reboot]
M3KUT44L48 app.mmhmm.CameraTest.camera (1.0/1) camera [terminated waiting to uninstall on reboot]
M3KUT44L48 app.mmhmm.CameraTest.camera (1.0/1) camera [terminated waiting to uninstall on reboot]
M3KUT44L48 app.mmhmm.CameraTest.camera (1.0/1) camera [terminated waiting to uninstall on reboot]
I didn't see anything in the (very sparse) documentation that indicated how I'd know that a reboot was required to finish un-installing (especially given that it wasn't required for installing). Maybe that's what OSSystemExtensionProperties.isUnstalling is for?
Post not yet marked as solved
Hi,
I have written a DAL virtual webcam plugin which works fine with all apps (Zoom, OBS, ...) except Apple QuickTime.
Other 3rd party virtual webcams show up in QuickTime, for instance the OBS virtual cam plugin:
https://github.com/obsproject/obs-studio/tree/dde4d57d726ed6d9e244ffbac093d8ef54e29f44/plugins/mac-virtualcam/src/dal-plugin
My first intention was that it has something to do with code signing, so I removed the signature from OBS virtual cam plugin but it kept working in QuickTime.
This is the source code of my plugin's entry function:
#include <CoreFoundation/CoreFoundation.h>
#include "plugininterface.h"
extern "C" void *TestToolCIOPluginMain(CFAllocatorRef allocator, CFUUIDRef requestedTypeUUID)
{
// This writes to a log file in /tmp/logfile.txt but is NEVER called from QuickTime:
Logger::write("Called TestToolCIOPluginMain");
if (!CFEqual(requestedTypeUUID, kCMIOHardwarePlugInTypeID))
return nullptr;
return VCam::PluginInterface::create();
}
And the plugin's Info.plist (almost the same as OBS virtual cam's one):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>TestDriverCIO</string>
<key>CFBundleIdentifier</key>
<string>com.test.cmio.DAL.VirtualCamera</string>
<key>LSMinimumSystemVersion</key>
<string>10.13</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>TestDriverCIO</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>3.0.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>3.0.0</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>CFPlugInFactories</key>
<dict>
<key>AAAAAAAA-7320-5643-616D-363462697402</key>
<string>TestToolCIOPluginMain</string>
</dict>
<key>CMIOHardwareAssistantServiceNames</key>
<array>
<string>com.test.cmio.VCam.Assistant</string>
</array>
<key>CFPlugInTypes</key>
<dict>
<key>30010C1C-93BF-11D8-8B5B-000A95AF9C6A</key>
<array>
<string>AAAAAAAA-7320-5643-616D-363462697402</string>
</array>
</dict>
</dict>
</plist>
Interestingly "TestToolCIOPluginMain" is never called (the logger never writes an output) when starting QuickTime and the camera is not shown in QuickTime.
Is there something special required to get the DAL plugin to show up in QuickTime? What am I missing here?
Regards,
Post not yet marked as solved
Hi,
I'm currently looking for a way to render WebVTT subtitles while using AVSampleBufferDisplayLayer. A little background on the issue.
In order to comply with some client rules (for play/pause/seek) and support picture in picture, I had to abandon the AVPlayerLayer (switching to AVSampleBufferDisplayLayer) which made me lose the native subtitles support but let me tap into the play/pause/seek calls and enforce the needed rules. This way I was able to use the AVPictureInPictureController with a content source and delegate (the latter did the trick to tapping into the PiP calls).
But with this, I lost the subtitles. The first thing that came to my mind was to implement support for the rendering of subtitles. Adding an AVPlayerItemLegibleOutput to the AVPlayerItem allowed me to get access to the subtitles, just to find out they were annotated with CoreMedia CMTextMark which don't seem to be automatically rendered by a CATextLayer. Thought of converting the NSAttributedString "styles" from Core Media to "normal" styles but then I would also need to add support for laying the subs correctly. Certainly, one way to do it but not sure it's easier. Couldn't find anything on the Core Media documentation that helped either.
Then while digging around the AVPlayerItemOutput I saw the suppressesPlayerRendering and trying to use AVPlayerLayer and AVSampleBufferDisplayLayer together.
The first one would render the subtitles while the other would do the video rendering. Made a sample and it sure works on the simulator, but when running on the device I get two layers of video playing and it seems that the suppressesPlayerRendering flag doesn't do anything.
How can I tackle this problem?
Post not yet marked as solved
Hi there,
I used AVAssetWriter to export mp4 file, input audio and video samples are encoded data (aac and h264 samples), sometimes it works well, but sometime it will failed randomly with error code -11800 and underlying code -17771 after calling finishWritingWithCompletionHandler, log looks like this:
AVAssetWriter status: Failed, status:err:Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSLocalizedFailureReason=An unknown error occurred (-17771), NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x60400008e1d0 {Error Domain=NSOSStatusErrorDomain Code=-17771 "(null)"}}, status=3
And I notice these logs on Console.app just before the error message:
default 17:35:08.380220+0800 MyAPP <<<< FigExportCommmon >>>> remakerFamily_formatWriterErrorOccurred: (0x6140001ba240)
default 17:35:08.380561+0800 MyAPP <<<< FigExportCommmon >>>> remakerFamily_PostFailureNotificationIfError: (0x6140001ba240) state finish writing called
default 17:35:08.381010+0800 MyAPP <<<< FigExportCommmon >>>> remakerfamily_setFailureStatusIfError: (0x6140001ba240) err -17771 state finish writing called
I don't know why this will happen, any replies are appreciate. thx.
Post not yet marked as solved
Version: 14.x
Setting videoGravity of AVSampleBufferDisplayLayer does not work, however, when I change bounds of this layer, it worked, is this a bug or feature?
but in iOS 15, this propery worked well.
Post not yet marked as solved
After creating a custom action classifier in Create ML, previewing it (see the bottom of the page) with an input video shows the label associated with a segment of the video. What would be a good way to store the duration for a given label, say, each CMTimeRange of segment of video frames that are classified as containing "Jumping Jacks?"
I previously found that storing time ranges of trajectory results was convenient, since each VNTrajectoryObservation vended by Apple had an associated CMTimeRange.
However, using my custom action classifier instead, each VNObservation result's CMTimeRange has a duration value that's always 0.
func completionHandler(request: VNRequest, error: Error?) {
guard let results = request.results as? [VNHumanBodyPoseObservation] else {
return
}
if let result = results.first {
storeObservation(result)
}
do {
for result in results where try self.getLastTennisActionType(from: [result]) == .playing {
var fileRelativeTimeRange = result.timeRange
fileRelativeTimeRange.start = fileRelativeTimeRange.start - self.assetWriterStartTime
self.timeRangesOfInterest[Int(fileRelativeTimeRange.start.seconds)] = fileRelativeTimeRange
}
} catch {
print("Unable to perform the request: \(error.localizedDescription).")
}
}
In this case I'm interested in frames with the label "Playing" and successfully classify them, but I'm not sure where to go from here to track the duration of video segments with consecutive frames that have that label.
Post not yet marked as solved
Modifying guidance given in an answer on AVFoundation + Vision trajectory detection, I'm instead saving time ranges of frames that have a specific ML label from my custom action classifier:
private lazy var detectHumanBodyPoseRequest: VNDetectHumanBodyPoseRequest = {
let detectHumanBodyPoseRequest = VNDetectHumanBodyPoseRequest(completionHandler: completionHandler)
return detectHumanBodyPoseRequest
}()
var timeRangesOfInterest: [Int : CMTimeRange] = [:]
private func readingAndWritingDidFinish(assetReaderWriter: AVAssetReaderWriter,
asset
completionHandler: @escaping FinishHandler) {
if isCancelled {
completionHandler(.success(.cancelled))
return
}
// Handle any error during processing of the video.
guard sampleTransferError == nil else {
assetReaderWriter.cancel()
completionHandler(.failure(sampleTransferError!))
return
}
// Evaluate the result reading the samples.
let result = assetReaderWriter.readingCompleted()
if case .failure = result {
completionHandler(result)
return
}
/*
Finish writing, and asynchronously evaluate the results from writing
the samples.
*/
assetReaderWriter.writingCompleted { result in
self.exportVideoTimeRanges(timeRanges: self.timeRangesOfInterest.map { $0.value }) { result in
completionHandler(result)
}
}
}
func exportVideoTimeRanges(timeRanges: [CMTimeRange], completion: @escaping (Result<OperationStatus, Error>) -> Void) {
let inputVideoTrack = self.asset.tracks(withMediaType: .video).first!
let composition = AVMutableComposition()
let compositionTrack = composition.addMutableTrack(withMediaType: .video, preferredTrackID: kCMPersistentTrackID_Invalid)!
var insertionPoint: CMTime = .zero
for timeRange in timeRanges {
try! compositionTrack.insertTimeRange(timeRange, of: inputVideoTrack, at: insertionPoint)
insertionPoint = insertionPoint + timeRange.duration
}
let exportSession = AVAssetExportSession(asset: composition, presetName: AVAssetExportPresetHighestQuality)!
try? FileManager.default.removeItem(at: self.outputURL)
exportSession.outputURL = self.outputURL
exportSession.outputFileType = .mov
exportSession.exportAsynchronously {
var result: Result<OperationStatus, Error>
switch exportSession.status {
case .completed:
result = .success(.completed)
case .cancelled:
result = .success(.cancelled)
case .failed:
// The `error` property is non-nil in the `.failed` status.
result = .failure(exportSession.error!)
default:
fatalError("Unexpected terminal export session status: \(exportSession.status).")
}
print("export finished: \(exportSession.status.rawValue) - \(exportSession.error)")
completion(result)
}
}
This worked fine with results vended from Apple's trajectory detection, but using my custom action classifier TennisActionClassifier (Core ML model exported from Create ML), I get the console error getSubtractiveDecodeDuration signalled err=-16364 (kMediaSampleTimingGeneratorError_InvalidTimeStamp) (Decode timestamp is earlier than previous sample's decode timestamp.) at MediaSampleTimingGenerator.c:180. Why might this be?