[macOS Sonoma 14.4b 23E5196e] screencapture fails to capture video.

FeedbackID: FB13636921

I'm using /usr/sbin/screencapture -v -x -C -k -R 0,0,500,500 /path/to/a/movfile/in/a/folder/in/my/apps/sandbox/Group/Container in my app to allow users to capture screenshots and recordings.

Screenshots keep working fine on macOS Sonoma 14.4b23E5196e, but video recordings no longer work.

I'm guessing the following log output has something to do with it:

default	15:01:53.151819+0100	screencapture	sampleBuffer: start recording time: 3123.604833 target: 3123.474266, overshot: 0.130568
error	15:01:53.185179+0100	screencapture	<private>:246:<private> Not writable url (null).!folderIsWritable == true
error	15:01:53.185236+0100	screencapture	<private>:50:<private> We could not create a byte stream!
error	15:01:53.185252+0100	screencapture	<private>:87:<private> NULL byte stream.
error	15:01:53.185298+0100	screencapture	<private>:3479:<private> ### Err -45,
error	15:01:53.185312+0100	screencapture	<private>:3814:<private> ### Err -45,
error	15:01:53.185334+0100	screencapture	<<<< AVCaptureMovieFileOutput >>>> Fig assert: "status == 0 " at  (AVCaptureMovieFileOutput.m:2522) - CMIOFileWritingControlTokenStartWriting (err=-45)
error	15:01:53.185374+0100	screencapture	<private>:1885:<private> ### Err -67452,
error	15:01:53.185388+0100	screencapture	<private>:303:<private> FigMovieFormatFileWriter::PostProcessMovie: WriteMovie() errored!!! -67452
error	15:01:53.185476+0100	screencapture	<private>:4687:<private> consolidate movie fragments err : -17913
default	15:01:53.185610+0100	screencapture	<<<< AVError >>>> AVLocalizedErrorWithUnderlyingOSStatus: Returning error (AVFoundationErrorDomain / -11800) status (-45)
default	15:01:53.186201+0100	screencapture	didFinishRecording: No trim finish. duration: 0.000000s size: 0, error: Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={AVErrorRecordingSuccessfullyFinishedKey=false, NSLocalizedDescription=The operation could not be completed, NSLocalizedFailureReason=An unknown error occurred (-45), NSURL=file:///Users/eternalstorms/Library/Group%20Containers/group.com.apple.screencapture/ScreenRecordings/3ED15EE7-A814-47A7-A398-29D5A6AD03C1.mov, NSUnderlyingError=0x6000031d80c0 {Error Domain=NSOSStatusErrorDomain Code=-45 "fLckdErr: file is locked"}}
error	15:01:53.186290+0100	screencapture	recording failed. The operation could not be completed

Are there new entitlements we need for this in our apps starting with macOS Sonoma 14.4? Or is it a bug? Calling it directly from Terminal works.

Thank you,

Matthias

Answered by DTS Engineer in 796624022
the main reason I'm using the screencapture CLI is for its "interactive" area-drawing and window-selecting UI.

My advice on that front is:

  1. Look at the latest ScreenCaptureKit APIs. Since that framework rolled out in macOS 12.3, we’ve added a number of new features. One notable one is SCContentSharingPicker. It’s possible that you might find helpful features there.

  2. Failing that, file an enhancement request for the features you need, making sure to detail your specific requirements.

If you do file any bugs, please post the numbers, just for the record.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

still the case in macOS 14.4b4 23E5205c

doesn't work when run from Shortcuts.app, either, as a "run script"

hm, it works when I add group.com.apple.screencapture to the XPC's App Groups, but I very much doubt it'll make it through App Review.

XPC's

This is the first time you’ve mentioned XPC on this thread. How does that come into play here?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I've submitted it to TestFlight and App Review, and as expected, it's taking a very long time in "In Review" (and very likely leading to a rejection). I hope this'll get fixed before 14.4 is released.

The entire screencapture task is run inside an XPC

I presume you mean an XPC service.

Regarding your App Group workaround, I don’t recommend that you try to claim groups that you obviously don’t ‘own’. On iOS this is just not allowed. The story on macOS is more complex; see App Groups: macOS vs iOS: Fight! for the details. And while I don’t work for App Review, and thus can’t make definitive statements about their policy, IMO your claim should not be allowed.

Taking a step back, why are you doing this task using the screencapture tool? There are APIs for capturing the screen, both long standing ones (in Core Graphics) and shiny new ones (ScreenCaptureKit). Using a tool when you could be using an API is suboptimal, not least because it exposes you to binary compatibility problems like the one you just hit.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

still the case on macOS 14.4b5(23E5211a)

I presume you mean an XPC service.

obviously.

XPC can be used for more than just XPC services. The majority of XPC questions I see are from folks using a launchd daemon or agent to vend a named XPC endpoint. Hence my desire to clarify the context.

an issue with any sort of relying on other peoples' code, and a constant worry in software development

Quite. However, you have to recognise that there are two levels of compatibility in play:

  • Apple works hard to maintain binary compatibility with our APIs. If you were calling an API and it started failing in a new OS release, we’d welcome a bug about that.

  • In contrast, the compatibility story for command-line tools is different. Their target market is Terminal users and shell scripts. And AFAIK this change doesn’t affect those use cases.

ps If you reply in the comments, I’m not notified of your reply. For this and other tips, see Quinn’s Top Ten DevForums Tips.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

the main reason I'm using the screencapture CLI is for its "interactive" area-drawing and window-selecting UI. Reimplementing this myself (highlighting windows when the space bar is pressed, drawing the selection rectangle and size/position crosshair info directly onto the screen, etc), is way out of proportion just for not using the screencapture CLI.

the main reason I'm using the screencapture CLI is for its "interactive" area-drawing and window-selecting UI.

My advice on that front is:

  1. Look at the latest ScreenCaptureKit APIs. Since that framework rolled out in macOS 12.3, we’ve added a number of new features. One notable one is SCContentSharingPicker. It’s possible that you might find helpful features there.

  2. Failing that, file an enhancement request for the features you need, making sure to detail your specific requirements.

If you do file any bugs, please post the numbers, just for the record.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[macOS Sonoma 14.4b 23E5196e] screencapture fails to capture video.
 
 
Q