Opened 5 years ago

Closed 5 years ago

#7498 closed defect (invalid)

webm rotation metadata results in deformed output.

Reported by: carl Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

When trying to extract a frame from a video, the video orientation metadata is taken into account, but the output dimensions are wrong. Notice in the example the height and width are swapped, resulting in a warped output.

I am using ImageMagick to convert the concatenated PNG files to a single JPEG, but the concat'd PNG still exhibits the issue.

Repro:

ffmpeg -t 1.0 -i file.webm -frames:v 120 -codec:v png -compression_level 0 -f image2pipe out.png

FFmpeg version (compiled locally at version n4.0):
ffmpeg version n4.0 Copyright (c) 2000-2018 the FFmpeg developers

built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.9) 20160609
configuration: --enable-gpl --enable-static --disable-nonfree --enable-pthreads --enable-libx264 --enable-libmp3lame --enable-libvorbis --enable-libvpx
libavutil 56. 14.100 / 56. 14.100
libavcodec 58. 18.100 / 58. 18.100
libavformat 58. 12.100 / 58. 12.100
libavdevice 58. 3.100 / 58. 3.100
libavfilter 7. 16.100 / 7. 16.100
libswscale 5. 1.100 / 5. 1.100
libswresample 3. 1.100 / 3. 1.100
libpostproc 55. 1.100 / 55. 1.100

Attachments (1)

file.webm (183.4 KB ) - added by carl 5 years ago.

Download all attachments as: .zip

Change History (4)

by carl, 5 years ago

Attachment: file.webm added

comment:1 by Carl Eugen Hoyos, 5 years ago

Resolution: invalid
Status: newclosed

For future tickets: Please remember that only current FFmpeg git head is supported here.

If you know that your application does not support aspect ratios (which are defined for png) use something like -vf scale=iw*sar:ih to force an output sample aspect ratio of 1:1. Even if FFmpeg developers would assume that no other software supports aspect ratios for certain output formats, this could not simplify the issue as FFmpeg will not change the aspect ratio by default.

(Please reopen this ticket if you believe that FFmpeg interprets - and writes - the aspect information backwards, not sure how to rule this out.)

comment:2 by carl, 5 years ago

Resolution: invalid
Status: closedreopened

I rebuilt from master (details below), and I still believe this is a bug. I tried converting to gif and jpg, and the image was still incorrectly warped. I also tried converting to mpeg2, which also had the warping.

This issue is very easy to reproduce with the file I uploaded, so I think it is a bug. The reading application I don't think is relevant, since the issue happens with multiple file types (some of which lack orientation metadata).

For jpg output:

ffmpeg -t 1.0 -i file.webm -frames:v 120 -compression_level 0 -f image2pipe out.jpg

ffmpeg version N-92202-gf72b990 Copyright (c) 2000-2018 the FFmpeg developers

built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.10) 20160609
configuration: --enable-gpl --enable-static --disable-nonfree --enable-pthreads --enable-libx264 --enable-libmp3lame --enable-libvorbis --enable-libvpx
libavutil 56. 19.101 / 56. 19.101
libavcodec 58. 33.101 / 58. 33.101
libavformat 58. 19.100 / 58. 19.100
libavdevice 58. 4.105 / 58. 4.105
libavfilter 7. 33.101 / 7. 33.101
libswscale 5. 2.100 / 5. 2.100
libswresample 3. 2.100 / 3. 2.100
libpostproc 55. 2.100 / 55. 2.100

comment:3 by Gyan, 5 years ago

Resolution: invalid
Status: reopenedclosed

I don't see any orientation metadata in the webm sample. ffmpeg reports a 1920x1080 raster with sample aspect ratio of 19:60 which should result in a display raster of 608x1080 at 1x size.

FFmpeg will not automatically convert frames to square-pixel. It will convey the SAR to the output format if it supports storing that attribute. It's then up to the reading app to read and apply that value. For apps (or formats) which don't do that, the workaround is to use Carl's suggested filter syntax. I would add one thing, though: -vf scale=iw*sar:ih,setsar=1. The setsar is added for safety, since the computed value by scale may not be perfect unity.

Note: See TracTickets for help on using tickets.