Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect dimensions for video recorded from iOS Simulator #76

Open
sindresorhus opened this issue May 5, 2019 · 3 comments
Open

Incorrect dimensions for video recorded from iOS Simulator #76

sindresorhus opened this issue May 5, 2019 · 3 comments
Labels
bug Something isn't working

Comments

@sindresorhus
Copy link
Owner

sindresorhus commented May 5, 2019

I've seen this issue in Crashlytics, but couldn't reproduce until I got this reply: https://twitter.com/FlorianBuerger/status/1124945762729779200

I've now managed to reproduce the issue by running an iOS app in a simulator like iPhone XS and then running xcrun simctl io booted recordVideo simulator-recording.mp4 in the terminal, and then pressing Ctrl+C some seconds later to end the recording.

Here's a test file: ios-simulator-recording-incorrect-dimensions-fixture.mp4.zip

And here's the debug output when dragging it into Gifski:

## AVAsset debug info ##
Extension: mp4
Video codec: H264 (avc1)
Audio codec: nil
Duration: 7s
Dimension: 0×0
Frame rate: 14.99
File size: 3.7 MB
Is readable: true
Is playable: true
Is exportable: true
Has protected content: false

Track #1
----
Type: Video
Codec: H264 (avc1)
Duration: 7s
Dimensions: 0×0
Natural size: (1125.0, 0.03717041015625)
Frame rate: 14.99
Is playable: true
Is decodable: true
----

(macOS 10.14.4)

Notice Natural size, which is the AVAssetTrack#naturalSize property, and should be the dimensions, but the height is not the correct value. After applying the .preferredTransform, like you're supposed to, the end result is CGSize.zero.

You can try it for yourself in the debug-dimensions-issue branch.

The dimensions are supposed to be 1125x2436. QuickTime shows the correct dimensions. So does the MediaInfo app.

I have no idea why the height is so screwed up. Seems to me that this is a AVFoundation bug, unless I'm missing something?

@florianbuerger
Copy link

florianbuerger commented May 5, 2019

I was about to mention that workaround (tested it in a small macOS sample app and it works) but you were faster 🙂 Glad I could help to reproduce it.

@sindresorhus
Copy link
Owner Author

sindresorhus commented May 5, 2019

@florianbuerger Does it look like an AVFoundation bug to you too? I'm considering whether I should open a Radar about this.

@florianbuerger
Copy link

Yes it does. Not sure wether the bug is in reading in AVAssetTrack or in writing it in the first place (I guess via AVAssetExportSession when the video is recorded).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants
@florianbuerger @sindresorhus and others