When recording multiple horizontal videos in succession, the second video is incorrectly oriented vertically.
When recording multiple horizontal videos in succession, the second video has incorrect orientation, and is recorded vertically. Sorry for duplicating #506 - I didn't realise until after I created this.
To reproduce:
- Orient the device horizontally
- Open the GrapheneOS Camera app
- Select "Video" mode
- Press the "record" button 6 times, approximately two seconds apart.
Expected result: 3 videos recorded in horizontal (landscape) orientation. Actual result: First video recorded as horizontal, second video recorded as portrait, third video recorded as horizontal. Suspected cause: The "Rotation" tag is missing from the metadata of the second video.
Three videos as they appear in the gallery:
The same three videos when copied to a PC (Ubuntu):
I made a video demonstrating the issue. It's an external video of the device to demonstrate the orientation. https://github.com/user-attachments/assets/25898f13-3f03-4e41-a3cf-b271d66cb557
I have included a mediainfo dump of the first two videos. Note that the first video is 1080x1920 with a 270° rotation (a weird way to do it, but it does display correctly in 16:9 landscape). The second video is 1080x1920 (9:16) with no rotation tag on the file.
First recording
$ mediainfo VID_20250412_202654.mp4
General
Complete name : VID_20250412_202654.mp4
Format : MPEG-4
Format profile : Base Media / Version 2
Codec ID : mp42 (isom/mp42)
File size : 4.56 MiB
Duration : 2 s 339 ms
Overall bit rate : 16.3 Mb/s
Frame rate : 29.868 FPS
Encoded date : 2025-04-12 10:26:57 UTC
Tagged date : 2025-04-12 10:26:57 UTC
xyz : [redacted]
com.android.version : 15
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L4
Format settings : CABAC / 1 Ref Frames
Format settings, CABAC : Yes
Format settings, Reference frames : 1 frame
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 2 s 339 ms
Source duration : 2 s 277 ms
Bit rate : 16.7 Mb/s
Width : 1 080 pixels
Height : 1 920 pixels
Display aspect ratio : 0.562
Rotation : 270°
Frame rate mode : Variable
Frame rate : 29.868 FPS
Minimum frame rate : 29.772 FPS
Maximum frame rate : 29.871 FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.269
Stream size : 4.53 MiB (99%)
Source stream size : 4.53 MiB (99%)
Title : VideoHandle
Language : English
Encoded date : 2025-04-12 10:26:57 UTC
Tagged date : 2025-04-12 10:26:57 UTC
Color range : Limited
Color primaries : BT.709
Transfer characteristics : BT.709
Matrix coefficients : BT.709
mdhd_Duration : 2339
Codec configuration box : avcC
Second recording
$ mediainfo VID_20250412_202659.mp4
General
Complete name : VID_20250412_202659.mp4
Format : MPEG-4
Format profile : Base Media / Version 2
Codec ID : mp42 (isom/mp42)
File size : 5.88 MiB
Duration : 3 s 49 ms
Overall bit rate : 16.2 Mb/s
Frame rate : 29.868 FPS
Encoded date : 2025-04-12 10:27:02 UTC
Tagged date : 2025-04-12 10:27:02 UTC
xyz : [redacted]
com.android.version : 15
Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L4
Format settings : CABAC / 1 Ref Frames
Format settings, CABAC : Yes
Format settings, Reference frames : 1 frame
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 3 s 49 ms
Source duration : 2 s 980 ms
Bit rate : 16.4 Mb/s
Width : 1 080 pixels
Height : 1 920 pixels
Display aspect ratio : 0.562
Frame rate mode : Variable
Frame rate : 29.868 FPS
Minimum frame rate : 29.772 FPS
Maximum frame rate : 29.871 FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.266
Stream size : 5.84 MiB (99%)
Source stream size : 5.84 MiB (99%)
Title : VideoHandle
Language : English
Encoded date : 2025-04-12 10:27:02 UTC
Tagged date : 2025-04-12 10:27:02 UTC
Color range : Limited
Color primaries : BT.709
Transfer characteristics : BT.709
Matrix coefficients : BT.709
mdhd_Duration : 3049
Codec configuration box : avcC
Device Details
Model: Pixel 6a
GrapheneOS Build number: 2025040700
app.grapheneos.camera version: 83
It's probably worth mentioning that you can losslessly correct affected videos using exiftool:
exiftool -rotation=270 VID_XXXXXXXX_XXXXXX.mp4
I just went through my files and corrected about 40 affected videos from my device. The earliest instance of this issue I could find happened on 2024-08-16. I think the issue was introduced around that time, as I've been encountering it every few days since.
Hi @pHr34kY,
The metadata being missing altogether seems to be unexpected behavior, we are currently always passing a rotation to all the use cases in general. Have tried manually logging the target_rotation values while reproducing this issue and it behavior seems to be unexpected despite setting the right values.
tr_startRecording_logs.txt (The regex (tr:|startRecording) can be used to see when the recording starts and when the target rotation is being set along with the raw values)
We have reported this issue to the CameraX team from our end here: https://issuetracker.google.com/issues/410312131
Will update this thread when this issue gets fixed or when there's any major update to be shared
Thanks a lot for sharing the detailed report! We appreciate all the time and efforts you have put in to bring this up.