Opened 3 years ago
Closed 3 years ago
#9497 closed defect (fixed)
ffmpeg reports wrong display aspect ratio (DAR) for matroska files.
Reported by: | Rikitiki | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | avformat |
Version: | git-master | Keywords: | mkv |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | yes | |
Analyzed by developer: | yes |
Description
ffmpeg reports wrong display aspect ratio (DAR) for matroska files.
If DAR is 160:67 then ffprobe displays:
"sample_aspect_ratio": "90:67", "display_aspect_ratio": "160:67",
and mkvinfo displays:
| + Display width: 160 | + Display height: 67
If DAR is 161:67 then ffprobe displays:
"sample_aspect_ratio": "123:91", "display_aspect_ratio": "656:273",
and mkvinfo displays:
| + Display width: 161 | + Display height: 67
A matroska file is created by mkvmerge from raw h264 stream. The h264 stream is created by ffmpeg from bmp files.
How to reproduce:
- unpack attcahed file
- replace VAR_FFMPEG_BINS & MKVMERGE_BINS to right location of the tools
- execute run.cmd to obtain output
Pay attention to CASE_1 & CASE_2 texts to change input DAR
ffmpeg version: ffmpeg-4.4.1-full_build
mkvmerge version: mkvtoolnix-64-bit-62.0.0
Attachments (3)
Change History (9)
by , 3 years ago
Attachment: | badout.txt added |
---|
by , 3 years ago
Attachment: | goodout.txt added |
---|
by , 3 years ago
Attachment: | ffmpegbug.zip added |
---|
comment:1 by , 3 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
comment:2 by , 3 years ago
Resolution: | wontfix |
---|---|
Status: | closed → reopened |
To prevent the rounding, can ffmpeg store Sample Aspect Ratio in its internal contexts as rational number? Something like https://www.boost.org/doc/libs/1_77_0/libs/rational/rational.html or https://docs.python.org/3/library/fractions.html.
comment:3 by , 3 years ago
Resolution: | → wontfix |
---|---|
Status: | reopened → closed |
It already does. It still has to be expressed as two integers.
comment:4 by , 3 years ago
Resolution: | wontfix |
---|---|
Status: | closed → reopened |
If it is expressed as two integers (as fractional) then rounding errors, mentioned early by you, must not exist. So must be
"display_aspect_ratio": "161:67",
instead
"display_aspect_ratio": "656:273",
...
comment:5 by , 3 years ago
Analyzed by developer: | set |
---|---|
Component: | undetermined → avformat |
Keywords: | mkv added |
Reproduced by developer: | set |
Version: | unspecified → git-master |
comment:6 by , 3 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Fixed in 9139dc6140e8fb8d84760f3c567332b41858798d.
Matroska stores DisplayWidth and DisplayHeight. ffmpeg stores Sample Aspect Ratio in its internal contexts. The former is the effective ratio of the displayed dimensions. The latter is the 'scale factor' to be applied to the decoder output for processing or display purposes. When converting the former to SAR, rounding may occur. Which in turn, may lead to a slightly different DAR computed by ffmpeg.