flingo64 / PhotoStation-Upload-Lr-Plugin

Photo StatLr (aka PhotoStation Upload) is a Lightroom Publish and Export Service Plugin that enables the export /publishing of photos and videos from Lr to a Synology Photo Station. It uploads the photos/videos and all required thumbnails. It can download comments and ratings and do a real two-way synch of various metadata (tags, ratings, labels).
http://messmer-online.de/index.php/software/11-photo-statlr
GNU General Public License v3.0
209 stars 21 forks source link

Issues with videos in portrait mode / rotation #81

Open SuperMasterPhoenix opened 3 months ago

SuperMasterPhoenix commented 3 months ago

Hi Martin, unfortunately I have some issues regarding videos in portrait mode and using rotation. My first example is a video filmed in portrait mode: Portrait_orig.mp4 Using soft rotation during publish results in a video as expected in the same format as the original: Portrait_softrotate.mp4 Using hard rotation during publish results in a video distorted to landscape format: Portrait_hardrotate.mp4

Which means for that case soft rotate would be fine. Unfortunately I cannot soft rotate because of the following reason. See the next example, it is a video filmed in landscape mode but accidentally recognized by the cam as portrait video. So I've added "Rotate-90" as keyword. Landscape-rotated_orig.mp4 Using soft rotation during publish the video isn't touched at all but still in portrait format: Landscape-rotated_softrotate.mp4 Using hard rotation during publish results in a really wired video. It is rotated, but distorted to portrait mode: Landscape-rotated_hardrotate.mp4

I am using the following configuration:

I partially tested the stuff with different ffmpeg versions locally using the exact same comand PhotostatLR logged in the logfile but there wasn't any difference to the video uploaded to Synology Photos. Therefore this is an issue between PhotoStatLR and ffmpeg.

Additionally here are the according ffmpeg commands for all above cases. Soft rotation:

"E:\Dateien\Downloads\Videoprogramme\ffmpeg-6.0-full_build-shared\bin\ffmpeg.exe" -noautorotate -i "C:\Users\Username\AppData\Local\Temp\23F496C6-962B-4A17-AF67-E5B2D355EBDA\Orig_Portrait.mp4" -y -strict experimental -acodec aac -ar 44100 -b:a 64k -ac 2 -vf format=yuv420p -c:v h264_nvenc -preset medium -qp 26 -s 1280x720 -aspect 1280:720 -metadata creation_time="2024-06-05 21:20:19"  -passlogfile "C:\Users\Username\AppData\Local\Temp\23F496C6-962B-4A17-AF67-E5B2D355EBDA\Orig_Portrait_MED_TMP.passlog" "C:\Users\Username\AppData\Local\Temp\23F496C6-962B-4A17-AF67-E5B2D355EBDA\Orig_Portrait_MED_TMP.mp4" 2> "C:\Users\Username\AppData\Local\Temp\23F496C6-962B-4A17-AF67-E5B2D355EBDA\Orig_Portrait_MED_TMP.txt"

"E:\Dateien\Downloads\Videoprogramme\ffmpeg-6.0-full_build-shared\bin\ffmpeg.exe" -noautorotate -i "C:\Users\Username\AppData\Local\Temp\23F496C6-962B-4A17-AF67-E5B2D355EBDA\Orig_Landscape-rotated.mp4" -y -strict experimental -acodec aac -ar 44100 -b:a 64k -ac 2 -vf format=yuv420p -metadata:s:v:0 rotate=90 -c:v h264_nvenc -preset medium -qp 26 -s 1280x720 -aspect 1280:720 -metadata creation_time="2024-06-05 21:20:42"  -passlogfile "C:\Users\Username\AppData\Local\Temp\23F496C6-962B-4A17-AF67-E5B2D355EBDA\Orig_Landscape-rotated_MED_TMP.passlog" "C:\Users\Username\AppData\Local\Temp\23F496C6-962B-4A17-AF67-E5B2D355EBDA\Orig_Landscape-rotated_MED_TMP.mp4" 2> "C:\Users\Username\AppData\Local\Temp\23F496C6-962B-4A17-AF67-E5B2D355EBDA\Orig_Landscape-rotated_MED_TMP.txt"

Hard rotation:

"E:\Dateien\Downloads\Videoprogramme\ffmpeg-6.0-full_build-shared\bin\ffmpeg.exe"  -i "C:\Users\Username\AppData\Local\Temp\9E94FD08-B421-4194-A75A-F2E298D29B99\Orig_Portrait.mp4" -y -strict experimental -acodec aac -ar 44100 -b:a 64k -ac 2 -vf format=yuv420p -c:v h264_nvenc -preset medium -qp 26 -s 1280x720 -aspect 1280:720 -metadata creation_time="2024-06-05 21:20:19"  -passlogfile "C:\Users\Username\AppData\Local\Temp\9E94FD08-B421-4194-A75A-F2E298D29B99\Orig_Portrait_MED_TMP.passlog" "C:\Users\Username\AppData\Local\Temp\9E94FD08-B421-4194-A75A-F2E298D29B99\Orig_Portrait_MED_TMP.mp4" 2> "C:\Users\Username\AppData\Local\Temp\9E94FD08-B421-4194-A75A-F2E298D29B99\Orig_Portrait_MED_TMP.txt"

"E:\Dateien\Downloads\Videoprogramme\ffmpeg-6.0-full_build-shared\bin\ffmpeg.exe"  -i "C:\Users\Username\AppData\Local\Temp\9E94FD08-B421-4194-A75A-F2E298D29B99\Orig_Landscape-rotated.mp4" -y -strict experimental -acodec aac -ar 44100 -b:a 64k -ac 2 -vf format=yuv420p,transpose=1 -c:v h264_nvenc -preset medium -qp 26 -s 720x1280 -aspect 720:1280 -metadata creation_time="2024-06-05 21:20:42"  -passlogfile "C:\Users\Username\AppData\Local\Temp\9E94FD08-B421-4194-A75A-F2E298D29B99\Orig_Landscape-rotated_MED_TMP.passlog" "C:\Users\Username\AppData\Local\Temp\9E94FD08-B421-4194-A75A-F2E298D29B99\Orig_Landscape-rotated_MED_TMP.mp4" 2> "C:\Users\Username\AppData\Local\Temp\9E94FD08-B421-4194-A75A-F2E298D29B99\Orig_Landscape-rotated_MED_TMP.txt"

When playing around with the parameters for the hard rotation calls I got it working by changing width and height of the aspect parameter. But I don't know whether this is the real cause or just fixes the actual issue.

If you need any further infos etc I am glad to help.

Kind regards Mike

SuperMasterPhoenix commented 3 months ago

By the way I cannot tell exactly since when I have that issue. End of last year/beginning of this year I switched from Photostation to Synology Photos but only used the picture export. Last month I began publishing videos again and there I first recognized distorted videos. As far as I know I never had that issue in Photostation but only in Synology Photos.

SuperMasterPhoenix commented 2 months ago

Guess I found the issue. I searched for an older version of ffmpeg in the internet and found 4.4.1 somewhere. With this old version the videos are published correctly. Difference between these two are the movie information files generated by ffmpeg. In newer version the field "rotate" is missing. This information is only shown in the field "displaymatrix" in this format: "rotation of -90.00 degrees" (did not chang compared to older version). Here are two examples: Orig_Portrait_ffmpeg_4.4.1.txt Orig_Portrait_ffmpeg_6.6.1.txt