Opened 3 years ago

Closed 3 years ago

#2689 closed defect (fixed)

Set-top boxes show wrong Aspect Ratio on HD content

Reported by: jdachik01 Owned by:
Priority: normal Component: avcodec
Version: git-master Keywords: aspect mpeg2video mpegts
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Source material does not matter.

Any HD content done at standard resolutions (1280x720 or 1920x1080) displays as "Aspect Ratio: 1:1" in TS Reader. TS Reader is showing what most set-top boxes show.

I have found that adjusting the resolution to an "incorrect" resolution - e.g. 1270x720, or 1290x720 - fixes the issue, but that is not a solution. The only difference in the CLI output generated by ffmpeg is the SAR, which is 1:1 when 1280x720 is the size selected, and a different value when an "incorrect" resolution is specified. Could there be a flag that ffmpeg is setting at 1:1 which should be 16:9?

ffmpeg -v 9 -loglevel 99 -i C:\lngm1210h.mpg -s 1280x720 -aspect 16:9
-threads 8 -vcodec mpeg2video -vb 13010k -minrate 13010k -maxrate 13010k -muxrat
e 13600k -bufsize 1835000 -r 59.94 -pix_fmt yuv420p -bf 2 -g 15 -ss 0 -y -acodec

mp2 -ar 48000 -ab 192k -copyts -f mpegts 169test.mpg 2>169LOG.log

Attachments (12)

169LOG-1280.log (10.0 KB) - added by jdachik01 3 years ago.
Log of 1280x720
169LOG-1270.log (9.8 KB) - added by jdachik01 3 years ago.
Log of 1270x720
169LOG-ffmpeg.JPG (17.5 KB) - added by jdachik01 3 years ago.
169test-ffmbc64.JPG (17.1 KB) - added by jdachik01 3 years ago.
169LOG-ffmbc32.JPG (16.9 KB) - added by jdachik01 3 years ago.
169test-ffmpeg.mpg (1.6 MB) - added by jdachik01 3 years ago.
169test-ffmbc64.mpg (1.6 MB) - added by jdachik01 3 years ago.
169test-ffmbc64.2.mpg (1.6 MB) - added by jdachik01 3 years ago.
169test-ffmbc32.mpg (1.6 MB) - added by jdachik01 3 years ago.
169LOG-ffmpeg.log (13.0 KB) - added by jdachik01 3 years ago.
169LOG-ffmbc64.log (10.0 KB) - added by jdachik01 3 years ago.
169LOG-ffmbc32.log (9.4 KB) - added by jdachik01 3 years ago.

Change History (26)

Changed 3 years ago by jdachik01

Log of 1280x720

Changed 3 years ago by jdachik01

Log of 1270x720

comment:1 Changed 3 years ago by jdachik01

Last edited 3 years ago by cehoyos (previous) (diff)

comment:2 Changed 3 years ago by cehoyos

  • Component changed from FFmpeg to undetermined
  • Keywords aspect added; Aspect HD MPEG-2 removed

Afaict, a sample aspect ratio of 1:1 is correct for your 1280x720 output file and that is also what FFmpeg shows or do I miss something.

comment:3 Changed 3 years ago by jdachik01

I'm aware that is correct.

The problem is that TS Reader shows the Aspect Ratio (DAR) as 1:1

Set-top boxes also must be reading this because they display the HD, 16:9 content as 1:1 (square).

Please download TS Reader from the link and see for yourself.

Thank you for looking at this.

comment:4 follow-up: Changed 3 years ago by jdachik01

FYI - this problem does not exist on the latest 64-bit Windows build of ffmbc:

http://code.google.com/p/ffmbc/

It *does* exist with the 32-bit version.

Hoping to get it fixed on all versions of ffmpeg and ffmbc.

comment:5 in reply to: ↑ 4 Changed 3 years ago by cehoyos

Replying to jdachik01:

FYI - this problem does not exist on the latest 64-bit Windows build of ffmbc:

http://code.google.com/p/ffmbc/

It *does* exist with the 32-bit version.

Please provide short samples of all three variants (ffmbc x 2 and ffmpeg), if possible made with identical command lines.

Last edited 3 years ago by cehoyos (previous) (diff)

comment:6 Changed 3 years ago by jdachik01

About to attach numerous files:

.mpg files made with each
.jpg showing TS Reader analysis
.log log of each

Each used same command line:

ffmxxx -v 9 -loglevel 99 -i 169test.mov -t 2 -s 1280x720 -aspect 16:9 -threads 8 -vcodec mpeg2video -vb 13010k -minrate 13010k -maxrate 13010k -muxrate 13600k -bufsize 4M -r 59.94 -pix_fmt yuv420p -bf 2 -g 15 -ss 0 -y -acodec mp2 -ar 48000 -ab 192k -f mpegts outputfile.mpg 2>outputlog.log

Changed 3 years ago by jdachik01

Changed 3 years ago by jdachik01

Changed 3 years ago by jdachik01

Changed 3 years ago by jdachik01

Changed 3 years ago by jdachik01

Changed 3 years ago by jdachik01

Changed 3 years ago by jdachik01

Changed 3 years ago by jdachik01

Changed 3 years ago by jdachik01

Changed 3 years ago by jdachik01

comment:7 Changed 3 years ago by jdachik01

Had to redo with -t 1 to get file size under limit.

You can ignore 169test-ffmbc64.2.mpg - uploaded by accident.

Thanks again.

comment:8 Changed 3 years ago by cehoyos

Do I understand correctly that the problem is not so much the output of your analyser software but that set-top-boxes play the output file(s) with an incorrect display aspect ratio?

comment:9 Changed 3 years ago by jdachik01

That is correct.

I only mention/include TS Reader because it is the only program I can find that shows the issue that is causing the set-top box to incorrectly display the video.

comment:10 Changed 3 years ago by cehoyos

  • Keywords mpeg2video mpegts added
  • Version changed from unspecified to git-master

comment:11 Changed 3 years ago by cehoyos

  • Summary changed from TS Reader shows 1:1 Aspect Ratio on HD content to Set-top boxes show wrong Aspect Ratio on HD content

comment:12 Changed 3 years ago by fredt

Based on code analysis and looking at the ffmbc fix, the solution is to modify mpeg12enc.c

When the aspect ratio equal exactly a valid mpeg2 aspect ratio, the wrong aspect ratio is sent in the aspect_ratio field in the mpeg sequence header. In that scenario the error difference will be zero because they match exactly. Because of the < sign, the current algorithm will select the second best error difference ignoring perfect match thus causing the error.

STB use the sequence header to display the right format on screen.

The fix is to change line 267 in function mpeg1_encode_sequence_header:

if (error < best_aspect_error) {

best_aspect_error = error;
s->aspect_ratio_info = i;

}

To this:

if (error <= best_aspect_error) {

best_aspect_error = error;
s->aspect_ratio_info = i;

}

Last edited 3 years ago by fredt (previous) (diff)

comment:13 Changed 3 years ago by cehoyos

Please send your patch (made with git format-patch or at least git diff) to the ffmpeg-devel mailing list where it can be reviewed. Patches on this bug tracker are generally ignored, this is even more relevant for tickets like this one that developers cannot easily reproduce themselves.

comment:14 Changed 3 years ago by cehoyos

  • Component changed from undetermined to avcodec
  • Resolution set to fixed
  • Status changed from new to closed

Should be fixed by Frederic Turmel in b217e1b0

Note: See TracTickets for help on using tickets.