WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
198912
[iOS] MediaRecorder incorrect screen orientation handling
https://bugs.webkit.org/show_bug.cgi?id=198912
Summary
[iOS] MediaRecorder incorrect screen orientation handling
Igor Ievsiukov
Reported
2019-06-17 03:27:09 PDT
When using MediaRecorder to recording a file in portrait mode, for ex. recording a video message using the frontal camera, Safari automatically switches width/height (640x480 => 480x640) but does not applies necessary transformation which results the video track to be rotated 90deg thus stretching the video making it hardly usable, please see [1]. Similar kind of distortions, upside-down video, etc. could be observed while holding the phone in any other orientation except landscape with camera on the right side. After looking at the source code I discover recording is performed using AVAssetWriterInput[2]. According to the dev docs [3] the issue could be resolved using the "transform" property to rotate the image according to the current device orientation [5]. You can find an example of transformation for each screen orientation via the following link [6]. I would be glad to provide a patch, unfortunately iOS Simulator does not supports webcams nor it is possible to deploy a debug version of WebKit to an iOS device. Please let me know if I can help with any further debugging. Thank you very much in advance, Igor [1]
https://www.dropbox.com/s/3kdx77bmw2mghvi/Vid%C3%A9o%2017.06.19%2011%2052%2040.mp4?dl=0
[2]
https://github.com/WebKit/webkit/blob/master/Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.h#L70
[3]
https://developer.apple.com/library/archive/qa/qa1744/_index.html#avassetwriter
[4]
https://developer.apple.com/documentation/avfoundation/avassetwriterinput/1390183-transform
[5]
https://github.com/remirobert/CameraEngine/blob/master/CameraEngine/CameraEngineVideoEncoder.swift#L130
[6]
https://github.com/remirobert/CameraEngine/blob/master/CameraEngine/CameraEngineVideoEncoder.swift#L83-L86
Attachments
Patch
(18.59 KB, patch)
2020-09-21 02:49 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Patch
(18.69 KB, patch)
2020-09-21 04:54 PDT
,
youenn fablet
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
Patch
(17.68 KB, patch)
2020-09-21 05:08 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Patch
(17.85 KB, patch)
2020-09-21 05:25 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Patch
(9.19 KB, patch)
2020-09-21 06:19 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Patch for landing
(9.31 KB, patch)
2020-09-21 11:11 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Patch
(3.81 KB, patch)
2020-09-30 01:14 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Patch for landing
(3.78 KB, patch)
2020-10-01 00:33 PDT
,
youenn fablet
no flags
Details
Formatted Diff
Diff
Show Obsolete
(7)
View All
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2019-06-17 05:09:10 PDT
<
rdar://problem/51802521
>
borisstodic
Comment 2
2019-08-27 01:15:08 PDT
I am facing same issue. Created new ticket with steps to reproduce bug:
https://bugs.webkit.org/show_bug.cgi?id=201137
youenn fablet
Comment 3
2019-08-27 01:41:39 PDT
***
Bug 201137
has been marked as a duplicate of this bug. ***
youenn fablet
Comment 4
2020-09-21 02:49:18 PDT
Created
attachment 409265
[details]
Patch
youenn fablet
Comment 5
2020-09-21 04:54:21 PDT
Created
attachment 409269
[details]
Patch
youenn fablet
Comment 6
2020-09-21 05:08:12 PDT
Created
attachment 409270
[details]
Patch
youenn fablet
Comment 7
2020-09-21 05:25:40 PDT
Created
attachment 409272
[details]
Patch
youenn fablet
Comment 8
2020-09-21 06:19:23 PDT
Created
attachment 409276
[details]
Patch
Eric Carlson
Comment 9
2020-09-21 10:48:11 PDT
Comment on
attachment 409276
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=409276&action=review
> Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm:430 > + if (sample.videoMirrored()) > + videoTransform = CGAffineTransformScale(videoTransform, -1, 1);
It would be nice to have internals API to test mirrored mode, like we have setCameraMediaStreamTrackOrientation to test rotation.
youenn fablet
Comment 10
2020-09-21 11:06:06 PDT
(In reply to Eric Carlson from
comment #9
)
> Comment on
attachment 409276
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=409276&action=review
> > > Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm:430 > > + if (sample.videoMirrored()) > > + videoTransform = CGAffineTransformScale(videoTransform, -1, 1); > > It would be nice to have internals API to test mirrored mode, like we have > setCameraMediaStreamTrackOrientation to test rotation.
I'll file a bug for that. As you noted, I'll remove setting the transform in case of no rotation or no mirroring.
youenn fablet
Comment 11
2020-09-21 11:06:28 PDT
no rotation and no mirroring.
youenn fablet
Comment 12
2020-09-21 11:11:39 PDT
Created
attachment 409286
[details]
Patch for landing
EWS
Comment 13
2020-09-21 13:57:22 PDT
Committed
r267366
: <
https://trac.webkit.org/changeset/267366
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 409286
[details]
.
youenn fablet
Comment 14
2020-09-30 01:07:53 PDT
Reopening since this is not properly working
youenn fablet
Comment 15
2020-09-30 01:14:00 PDT
Created
attachment 410099
[details]
Patch
Eric Carlson
Comment 16
2020-09-30 08:10:31 PDT
Comment on
attachment 410099
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=410099&action=review
> Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm:433 > + m_videoTransform = CGAffineTransformScale(*m_videoTransform, -1, 1);
Do we always want to flip the transform?
youenn fablet
Comment 17
2020-10-01 00:30:50 PDT
(In reply to Eric Carlson from
comment #16
)
> Comment on
attachment 410099
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=410099&action=review
> > > Source/WebCore/platform/mediarecorder/cocoa/MediaRecorderPrivateWriterCocoa.mm:433 > > + m_videoTransform = CGAffineTransformScale(*m_videoTransform, -1, 1); > > Do we always want to flip the transform?
Indeed, will fix that.
youenn fablet
Comment 18
2020-10-01 00:33:11 PDT
Created
attachment 410201
[details]
Patch for landing
EWS
Comment 19
2020-10-01 04:25:42 PDT
Committed
r267828
: <
https://trac.webkit.org/changeset/267828
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 410201
[details]
.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug