KyleKun / one_second_diary

Minimalist video diary app.
MIT License
300 stars 60 forks source link

Videos recorded upside down are not properly rotated #73

Open arcstur opened 1 year ago

arcstur commented 1 year ago

When I record a video, using the default camera app, with the phone upside down, the camera app auto-orientates it, and the gallery and other apps show it with the correct orientation. One Second Diary, however, shows the video upside down when adding from the calendar section, maybe this has somethind to do with video orientation metadata?

Basically, a normal video for all the apps (and my computer) appears upside down in the app.

KyleKun commented 1 year ago

When I record a video, using the default camera app, with the phone upside down, the camera app auto-orientates it, and the gallery and other apps show it with the correct orientation. One Second Diary, however, shows the video upside down when adding from the calendar section, maybe this has somethind to do with video orientation metadata?

Basically, a normal video for all the apps (and my computer) appears upside down in the app.

Hey @arcstur , I tried to reproduce it but it worked normally on my device, so maybe this is device specific? I tried recording with default camera upside down, adding it from gallery, the preview appears correctly.

If possible, could you attach a screen recording showing how to reproduce? Thanks!

alexanderadam commented 1 year ago

I'm not sure whether it is the same or related but sometimes OSD gets the wrong orientation. It is recording the video in landscape mode but once the recording is finished and I check it in the recorded videos, it is turned by 90 degrees as you can see in the screenshot:

Screenshot_20230524_224018

KyleKun commented 1 year ago

I'm not sure whether it is the same or related but sometimes OSD gets the wrong orientation. It is recording the video in landscape mode but once the recording is finished and I check it in the recorded videos, it is turned by 90 degrees as you can see in the screenshot:

Screenshot_20230524_224018

I have reproduced this on my side too and it's starting to annoy me when I have to re-record because of this lol, I'll try to fix it this weekend.

@arcstur is this the same problem you described?

alexanderadam commented 1 year ago

I have reproduced this on my side too and it's starting to annoy me when I have to re-record because of this lol, I'll try to fix it this weekend.

Sounds promising — obrigado @KyleKun! :raised_hands:

arcstur commented 1 year ago

Mine's actually a little bit different. When recording upside down (horizontally) with my camera app, it auto corrects it to save it to gallery, and gallery shows it in the right orientation.

When adding the video to OSD, it shows it upside down in the add section: image

However, when saving, it shows it in the correct orientation: image

alexanderadam commented 1 year ago

I have reproduced this on my side too and it's starting to annoy me when I have to re-record because of this lol, I'll try to fix it this weekend.

Do you have any update here, @KyleKun? :pleading_face:

KyleKun commented 1 year ago

I have reproduced this on my side too and it's starting to annoy me when I have to re-record because of this lol, I'll try to fix it this weekend.

Do you have any update here, @KyleKun? :pleading_face:

Not yet :(, will try this week.

KristjanLaane commented 1 year ago

I have the same or similar issue. Any video I record in landscape gets added in portrait (and therefore in the wrong orientation). Makes the app unusable for me because I only record in landscape.

KyleKun commented 1 year ago

I have the same or similar issue. Any video I record in landscape gets added in portrait (and therefore in the wrong orientation). Makes the app unusable for me because I only record in landscape.

Do you mean even adding a landscape video from gallery ends up being treated as portrait? Or even with the "Force native camera" option enabled in preferences?

KristjanLaane commented 1 year ago

Do you mean even adding a landscape video from gallery ends up being treated as portrait? Or even with the "Force native camera" option enabled in preferences?

I tried recording a video in landscape with the native Android Camera app and adding it to 1SecondDiary through Gallery and everything works fine then - it is correctly positioned in landscape and the correct way up.

However, with a video that has been recorded in landscape with 1SecondDiary own camera implementation, when I add that through the Gallery then the bug is evident.

I also just now tried the Force native camera setting ticked and recording the landscape video from 1SecondDiary then to add it to today, and that also works fine, no bug.

The bug is also evident as per my original report when making a recording for today with 1SecondDiary camera.

KyleKun commented 1 year ago

Just pushed a fix (#70) for the issue with in-app recording. The library to get device orientation regardless of Device Rotation being enabled has some issues when the device is "flat", meaning the sensor doesn't output the right orientation if there's no inclination angle. With the new lock orientation button this shouldn't happen anymore. FYI @alexanderadam / @KristjanLaane

Will investigate the original issue reported by @arcstur.

A new version of the app with these and other fixes probably comes out next week.

KyleKun commented 1 year ago

Turns out it was fixed in the video_player plugin (https://github.com/flutter/flutter/issues/60327) Should be okay in next version, closing this but feel free to re-open if needed.

alexanderadam commented 10 months ago

Hi @KyleKun

I'm still getting the wrong orientation every now and then in the current version 1.5.2

😔

KyleKun commented 10 months ago

Hi @KyleKun

I'm still getting the wrong orientation every now and then in the current version 1.5.2

😔

Will take a look at it

Edit: yeah, still broken in the video player package (https://github.com/flutter/flutter/issues/122276). Guess I'll try ffprobe to get recording orientation and rotate it myself.

Flo-711 commented 7 months ago

Can report this is still an issue (landscape video upside down) - however it does save right way up so the fix can wait for a bit ;)

alexanderadam commented 3 months ago

For folks that need to correct the wrongly rotated clips:

  1. install ffmpeg if you don't have it already
  2. download the YuseiMagic-Regular.ttf font from the repo
ffmpeg -i 2023-11-14.mp4 -vf "transpose=1,crop=1080:607,drawtext=fontfile='/path/to/the/font/YuseiMagic-Regular.ttf':text='2023-11-14':x=w-tw-22:y=22:fontsize=22:fontcolor=white:borderw=1" output.mp4

or if you want to add the location:

ffmpeg -i 2023-11-14_orig.mp4 -vf "transpose=1,crop=1080:607,drawtext=fontfile='../YuseiMagic-Regular.ttf':text='2023-11-14':x=w-tw-22:y=22:fontsize=22:fontcolor=white:borderw=1,drawtext=fontfile='../YuseiMagic-Regular.ttf':text='Zug, Switzerland':x=w-tw-22:y=h-th-22:fontsize=22:fontcolor=white:borderw=1" output.mp4

You have to change the name of the input file, the path to the font and the text.

This is for correcting the 90 degrees rotation.

It's not perfect but surely much better than before. :wink: