Page MenuHomePhabricator

Thumbor thumbnails for WebM & Ogg videos with non square pixels have wrong aspect ratio
Closed, ResolvedPublic

Description

I noticed while testing some video files with non square pixels in the source file that thumbor-rendered thumbs for them are coming out with the wrong aspect ratio.

It seems to be pulling the aspect ratio of the raw buffer instead of scaling to the proper render dimensions as the previous system did.

An old thumb at right aspect: https://upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Xylocopa_violacea_male_-_2012-10-23.webm/800px--Xylocopa_violacea_male_-_2012-10-23.webm.jpg

A new thumb at wrong aspect: https://upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Xylocopa_violacea_male_-_2012-10-23.webm/804px--Xylocopa_violacea_male_-_2012-10-23.webm.jpg

Ogg Theora also affected when using non-square pixels:

In case those files get overwritten: expected 16:9 but getting 4:3.

Details

Related Gerrit Patches:
operations/debs/python-thumbor-wikimedia : masterUpgrade to 2.0

Event Timeline

brion created this task.Jun 24 2018, 4:57 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJun 24 2018, 4:57 PM
brion updated the task description. (Show Details)Jun 24 2018, 4:58 PM
brion renamed this task from Thumbor thumbnails for WebM videos with non square pixels have wrong aspect ratio to Thumbor thumbnails for WebM & Ogg videos with non square pixels have wrong aspect ratio.Jun 25 2018, 5:10 AM
brion updated the task description. (Show Details)
brion added a comment.Jun 25 2018, 5:51 AM

Can get the base size and the display aspect ratio from ffprobe by extending the call to something like this:

$ ffprobe -v error -show_streams -select_streams v:0 -show_entries 'format=duration:stream=width,height,display_aspect_ratio:stream_tags=:stream_disposition=' -of default=noprint_wrappers=1:nokey=0 Xylocopa_violacea_male_-_2012-10-23.webm 
width=1440
height=1080
display_aspect_ratio=16:9
duration=82.440000

Will take a gander at patching the thumbor plugin later.

Gilles added a subscriber: Gilles.Jun 25 2018, 11:49 AM

It's extracting a frame with ffmpeg, ideally that can somehow be made correct, without having to parse WebM-specific display_aspect_ratio, crop_* etc?

https://github.com/wikimedia/operations-debs-python-thumbor-wikimedia/blob/47fea15502b5248a76201adebe067cfbaf16f35e/wikimedia_thumbor/loader/video/__init__.py#L170-L200

Seems like https://linux.goeszen.com/how-to-take-screen-caps-from-do-thumbnails-of-anamorphic-video-in-correct-display-aspect-ratio.html has the answer, adding

-vf 'scale=iw*sar:ih'

to the ffmpeg -ss command.

Seems to work when testing it on https://commons.wikimedia.org/wiki/File:Xylocopa_violacea_male_-_2012-10-23.webm yielding this:

instead of (currently) this:

Gilles claimed this task.Jun 25 2018, 1:18 PM
Gilles triaged this task as Medium priority.
Gilles added a project: Performance-Team.
Imarlier moved this task from Inbox to Doing on the Performance-Team board.Jun 25 2018, 7:52 PM

Change 427612 had a related patch set uploaded (by Gilles; owner: Gilles):
[operations/debs/python-thumbor-wikimedia@master] Upgrade to 2.0

https://gerrit.wikimedia.org/r/427612

Change 427612 merged by Filippo Giunchedi:
[operations/debs/python-thumbor-wikimedia@master] Upgrade to 2.0

https://gerrit.wikimedia.org/r/427612

Gilles closed this task as Resolved.Jun 26 2018, 11:26 AM

Fixed. Affected files can simply be purge to get correct thumbnail dimensions. I've already purged the 2 you mentioned in the task description.

brion added a comment.Jun 26 2018, 6:26 PM

*chef's kiss emoji* that's a perfect fix, and much simpler than extracting the info and adjusting size manually. Many thanks Gilles!

Vvjjkkii renamed this task from Thumbor thumbnails for WebM & Ogg videos with non square pixels have wrong aspect ratio to 4daaaaaaaa.Jul 1 2018, 1:02 AM
Vvjjkkii reopened this task as Open.
Vvjjkkii removed Gilles as the assignee of this task.
Vvjjkkii raised the priority of this task from Medium to High.
Vvjjkkii updated the task description. (Show Details)
Vvjjkkii removed subscribers: gerritbot, Aklapper.
CommunityTechBot renamed this task from 4daaaaaaaa to Thumbor thumbnails for WebM & Ogg videos with non square pixels have wrong aspect ratio.Jul 2 2018, 10:23 AM
CommunityTechBot closed this task as Resolved.
CommunityTechBot assigned this task to Gilles.
CommunityTechBot lowered the priority of this task from High to Medium.
CommunityTechBot updated the task description. (Show Details)
CommunityTechBot added subscribers: gerritbot, Aklapper.