Page 1 of 2

incorrect display aspect on Sony Bravia

PostPosted: Sun Nov 13, 2011 10:23 pm
by jlv
When I watch wide-screen (1280x544, DAR 2.35) content on my Bravia (KDL-46EX700), the Bravia displays it with vertical distortion, making it horrible to view. The only thing I can do it set it to 'wide' mode, which fixes the vertical distortion, by cuts of the sides.

The stream is being transcoded by Serviio into mpeg2. Interestingly enough, I've also got a PlayOn DLNA server running on the same system. It also transcodes the video into mpeg2, and when I watch the same video via PlayOn, the Bravia displays it correctly.

I've searched the forum and have found numerous references to similar problems, but don't see any actual solution. e.g., viewtopic.php?f=11&t=3656 and viewtopic.php?f=11&t=2956.

I've seen mention that this is an issue with the Bravia... which I can believe (since IMHO Sony makes everything difficult). However, PlayOn is able to do this correctly, so it must be possible.

This is the MediaInfo output the attached video:
  Code:
Format                           : AVI
Format/Info                      : Audio Video Interleave
File size                        : 11.8 MiB
Duration                         : 39s 549ms
Overall bit rate                 : 2 493 Kbps
Writing library                  : VirtualDub build 31953/release

Video
ID                               : 0
Format                           : MPEG-4 Visual
Format profile                   : Simple@L1
Format settings, BVOP            : No
Format settings, QPel            : No
Format settings, GMC             : No warppoints
Format settings, Matrix          : Default (H.263)
Codec ID                         : XVID
Codec ID/Hint                    : XviD
Duration                         : 39s 539ms
Bit rate                         : 2 368 Kbps
Width                            : 1 280 pixels
Height                           : 544 pixels
Display aspect ratio             : 2.35
Frame rate                       : 23.976 fps
Resolution                       : 24 bits
Colorimetry                      : 4:2:0
Scan type                        : Progressive
Bits/(Pixel*Frame)               : 0.142
Stream size                      : 11.2 MiB (95%)
Writing library                  : SUPER(C)   

This is the transcoded file saved by Serviio
  Code:
Format                           : MPEG-TS
File size                        : 20.5 MiB
Duration                         : 39s 456ms
Overall bit rate                 : 4 352 Kbps

Video
ID                               : 256 (0x100)
Menu ID                          : 1 (0x1)
Format                           : MPEG Video
Format version                   : Version 2
Format profile                   : Main@High-1440
Format settings, Matrix          : Default
Duration                         : 39s 456ms
Bit rate mode                    : Variable
Bit rate                         : 3 858 Kbps
Nominal bit rate                 : 17.0 Mbps
Width                            : 1 280 pixels
Height                           : 544 pixels
Display aspect ratio             : 2.35
Frame rate                       : 23.976 fps
Colorimetry                      : 4:2:0
Scan type                        : Progressive
Bits/(Pixel*Frame)               : 0.231
Stream size                      : 18.1 MiB (89%)

Menu
ID                               : 4096 (0x1000)
Menu ID                          : 1 (0x1)
Format                           : MPEG Video / AC-3
List                             : 256 (0x100) (MPEG Video) / 257 (0x101) (AC-3)
Language                         :  /
Service name                     : Service01
Service provider                 : FFmpeg
Service type                     : digital television

One of the very many annoying things about PlayOn (e.g., why I use Serviio) is that it obfuscates it's logs ... and apparently the cached transcoded stream, too, since nothing I've used to look at the file can

Re: incorrect display aspect on Sony Bravia

PostPosted: Sun Nov 13, 2011 11:01 pm
by jlv
I reread the other threads again, and Illico talked about extra ffmpeg options
Illico wrote:For the moment, this is the ffmpeg option I use (simplify: no need to know the input resolution):

-vf "scale=1280:-1","pad=1280:720:(ow-iw)/2:(oh-ih)/2:black","setdar=4:3"

If I run the ffmpeg by hand using the options Serviio passes with these added, then the video generated is displayed just fine by the Bravia with no zoom mode needed.

However, the Bravia reports this stream as being 1280x720 (since it's being padded to that), and that's not what PlayOn is doing, since it's stream is reported as 1280x544. So, there must still be someway to make the Bravia display this correctly without adding the padding.

Re: incorrect display aspect on Sony Bravia

PostPosted: Mon Nov 14, 2011 8:35 am
by Illico
jlv wrote:However, the Bravia reports this stream as being 1280x720 (since it's being padded to that), and that's not what PlayOn is doing, since it's stream is reported as 1280x544. So, there must still be someway to make the Bravia display this correctly without adding the padding.

Very interesting jlv, if I get time I'll try the trial version of PlayOn to compare...
Do you know Wireshark tool?
Could you capture upnp/dlna message between Bravia and PlayOn server?

Re: incorrect display aspect on Sony Bravia

PostPosted: Mon Nov 14, 2011 5:08 pm
by zip
I found this in FFmpeg mail list: http://ffmpeg.org/pipermail/ffmpeg-cvsl ... 36083.html

It looks like -aspect should just work. Obviously not sure if the TV accepts it ;/ Do we have any indication from MediaInfo that the DAR is wrong?

It looks these guys are having similar issues: http://www.wildmediaserver.com/forum/vi ... 3&start=30

Re: incorrect display aspect on Sony Bravia

PostPosted: Mon Nov 14, 2011 5:45 pm
by Illico
I just install PlayOn on my windows OS and add some samples.
I use exactly the same "Arriety" sample : Stream #0.0: Video: mpeg4, yuv420p, 640x336 [PAR 1:1 DAR 40:21], 23.98 fps, 23.98 tbr, 23.98 tbn, 2997 tbc
With wireshark I see that the file is transcoded into MPEG_PS_NTSC:
HTTP/1.1 200 OK
Content-Type: video/mpeg
contentFeatures.dlna.org: DLNA.ORG_PN=MPEG_PS_NTSC;DLNA.ORG_OP=01;DLNA.ORG_CI=1;DLNA.ORG_FLAGS=25700000000000000000000000000000
transferMode.dlna.org: Streaming
Server: MediaMallServer/3.4.27.2614
Date: Mon, 14 Nov 2011 17:26:37 GMT

But I have exactly the same display aspect than ffmpeg/serviio : bad vertical aspect ratio !!!
jlv how do you explain that ?
You compare 1280x720 (ffmpeg with my extra padding options) with original 1280x544, they are very close. Open the file with VLC or MediaPlayerClassic, then find a revealing pause screen with objects in border limit or a round objects, for aspect ratio comparison.

Re: incorrect display aspect on Sony Bravia

PostPosted: Mon Nov 14, 2011 7:38 pm
by Illico
SERVIIO

Source
Stream #0.0: Video: mpeg4, yuv420p, 640x336 [PAR 1:1 DAR 40:21], 23.98 fps,23.98 tbr, 23.98 tbn, 2997 tbc

Default ffmpeg command line
ffmpeg.exe -i "Test1_640x336.avi" -y -threads 2 -vcodec mpeg2video -b 17000k -maxrate 17000k -bufsize 5097k -r 25 -g 15 -copyts -acodec ac3 -ab 192k -ac 2 -map 0:0 -map 0:1 -sn -f mpegts "Test1_640x336-default.ts"
Result (computing 128-150fps)
Stream #0.0: Video: mpeg2video, yuv420p, 640x336 [PAR 1:1 DAR 40:21], q=2-31, 17000 kb/s, 90k tbn, 25 tbc
- need to zoom on sony menu option : bad
- all vertical pixel but with black bar added on top and bottom, then some pixels lost on left and righ side : bad


ffmpeg.exe -i "Test1_640x336.avi" -y -threads 2 -vcodec mpeg2video -b 17000k -maxrate 17000k -bufsize 5097k -r 25 -g 15 -aspect 16:9 -copyts -acodec ac3 -ab 192k -ac 2 -map 0:0 -map 0:1 -sn -f mpegts "Test1_640x336-16.ts"
Result (computing 124-147fps)
Stream #0.0: Video: mpeg2video, yuv420p, 640x336 [PAR 14:15 DAR 16:9], q=2-31, 17000 kb/s, 90k tbn, 25 tbc
- no need to zoom on sony menu option : ok
- but some pixel lost on top/bot and left/right : bad


ffmpeg.exe -i "Test1_640x336.avi" -y -threads 2 -vcodec mpeg2video -b 17000k -maxrate 17000k -bufsize 5097k -r 25 -g 15 -aspect 4:3 -copyts -acodec ac3 -ab 192k -ac 2 -map 0:0 -map 0:1 -sn -f mpegts "Test1_640x336-4.ts"
Result (computing 126-146 fps)
Stream #0.0: Video: mpeg2video, yuv420p, 640x336 [PAR 7:10 DAR 4:3], q=2-31, 17000 kb/s, 90k tbn, 25 tbc
- no need to zoom on sony menu option : ok
- but some pixel lost on top/bot and left/right : bad


ffmpeg.exe -i "Test1_640x336.avi" -y -threads 2 -vcodec mpeg2video -b 17000k -maxrate 17000k -bufsize 5097k -r 25 -g 15 -vf "scale=1280:1280/dar/sar","pad=1280:720:(ow-iw)/2:(oh-ih)/2:blue","setdar=4:3" -copyts -acodec ac3 -ab 192k -ac 2 -map 0:0 -map 0:1 -sn -f mpegts "Test1_640x336-pad4.ts"
Result (computing 41-49 fps )
Stream #0.0: Video: mpeg2video, yuv420p, 1280x720 [PAR 3:4 DAR 4:3], q=2-31, 17000 kb/s, 90k tbn, 25 tbc
- no need to zoom on sony menu option : ok
- all pixels are displayed with good aspect ratio : ok

ffmpeg.exe -i "Test1_640x336.avi" -y -threads 2 -vcodec mpeg2video -b 17000k -maxrate 17000k -bufsize 5097k -r 25 -g 15 -vf "scale=1280:1280/dar/sar","pad=1280:720:(ow-iw)/2:(oh-ih)/2:blue","setdar=16:9" -copyts -acodec ac3 -ab 192k -ac 2 -map 0:0 -map 0:1 -sn -f mpegts "D:\temp\Serviio\Test1_640x336-pad16.ts"
Result (computing 42-49 fps )
Stream #0.0: Video: mpeg2video, yuv420p, 1280x720 [PAR 1:1 DAR 16:9], q=2-31, 17000 kb/s, 90k tbn, 25 tbc
- need to zoom on sony menu option : bad
- all vertical pixel but with black bar added on top and bottom (+ padding option), then some pixels lost on left and righ side : bad

Re: incorrect display aspect on Sony Bravia

PostPosted: Tue Nov 15, 2011 10:20 am
by zip
how does that work with remuxed files (-vcodec copy).. in the FFmpeg discussion they seem to suggest that the filter (vf) works for transcoded files and -aspect for transcoded/remuxed.

Also why do you set aspect ration to 4:3 in your command?

And - can you compare the speed (fps) of doing transcode with and without the vf attribute?

Re: incorrect display aspect on Sony Bravia

PostPosted: Tue Nov 15, 2011 1:27 pm
by Illico
zip wrote:how does that work with remuxed files (-vcodec copy).. in the FFmpeg discussion they seem to suggest that the filter (vf) works for transcoded files and -aspect for transcoded/remuxed.

I will check...but I remember that there were no good result for remuxed file (with -vf)
zip wrote:Also why do you set aspect ration to 4:3 in your command?

When I began the investigation, I was inspired by the PS3 Media Server Mencoder custom option : "-vf softskip,expand=::::1:16/9,dsize=4/3"
But I could retry with 16:9, is probably the same result for Sony...I will check.
zip wrote:And - can you compare the speed (fps) of doing transcode with and without the vf attribute?

Yes, will check

Re: incorrect display aspect on Sony Bravia

PostPosted: Tue Nov 15, 2011 9:01 pm
by Illico
So some new results:
1) -vcodec copy -aspect 16:9 or -vcodec copy -aspect 4:3 did not change the Display Aspect Ratio (DAR) of the output resulting file, so that doesn't work for remuxed files.

2) I update the previous post with fps computing value and confirm that "setdar=4:3" must be used.

Re: incorrect display aspect on Sony Bravia

PostPosted: Wed Nov 16, 2011 11:30 am
by zip
So it is significantly slower ;-(

Do you have display problems with remuxed files though? I.e., do they show correctly or not?

Do you have a sample I can play with? It looks like the -aspect parameter sets the aspect header on the container, but some players seem to ignore it, or it might be container/codec specific. Possibly PlayOn is transcoding to mpeg4/h264? Reading some forums, it looks like -aspect does the same as -vf setdar, but filters are only applied to transcoded streams, so not sure what happens when we remux.

Also, do you have an example of a native file with 1280x720 resolution? Can you post ffmpeg -i for it? It seems the SAR/DAR values of your working example are weird. It should be 1:1/16:9 I think.

Re: incorrect display aspect on Sony Bravia

PostPosted: Wed Nov 16, 2011 2:16 pm
by Illico
zip wrote:So it is significantly slower ;-(

Yes because the source file is a 640x336 [PAR 1:1 DAR 40:21] and with padding option its an 1280x720 [PAR 3:4 DAR 4:3], so there were an upscaling too.

zip wrote:Do you have display problems with remuxed files though? I.e., do they show correctly or not?

I don't have samples for remux with low resolution (only avi) (640x336), but I will try to build some.

zip wrote:Do you have a sample I can play with? It looks like the -aspect parameter sets the aspect header on the container, but some players seem to ignore it, or it might be container/codec specific.

I will try to build the same "Arriety" AVI sample into other format (mkv, ts, m2ts) with same low resoution 640x336.
zip wrote:Possibly PlayOn is transcoding to mpeg4/h264?

No, PlayOn transcode into MPEG_PS_NTSC profile, MPEG4/h264 in native is not supported by Sony TV.
zip wrote:Reading some forums, it looks like -aspect does the same as -vf setdar, but filters are only applied to transcoded streams

Yes confirm, -aspect or -vf setdar are similar.
zip wrote:, so not sure what happens when we remux.

I saw nothing special
zip wrote:Also, do you have an example of a native file with 1280x720 resolution? Can you post ffmpeg -i for it? It seems the SAR/DAR values of your working example are weird. It should be 1:1/16:9 I think.

posting.php?mode=quote&f=11&p=26879#pr26727
Test1_640x336-pad4.ts : Stream #0.0: Video: mpeg2video, yuv420p, 1280x720 [PAR 3:4 DAR 4:3] ==> Display OK
Test1_640x336-pad16.ts : Stream #0.0: Video: mpeg2video, yuv420p, 1280x720 [PAR 1:1 DAR 16:9] ==> Display BAD

It seems that DAR must be 4:3 for MPEG2video source.

Re: incorrect display aspect on Sony Bravia

PostPosted: Wed Nov 16, 2011 3:48 pm
by zip
But it's the PAR 3:4 that seems weird, it means pixel whose height is larger than width :shock:

Re: incorrect display aspect on Sony Bravia

PostPosted: Wed Nov 16, 2011 4:48 pm
by Illico
zip wrote:But it's the PAR 3:4 that seems weird, it means pixel whose height is larger than width :shock:

Yes but the native format is 1280x720 [PAR 1:1 DAR 16:9], with SAR 16:9.
SAR × PAR = DAR.
PAR = DAR/SAR.

But with -vf=setdar 4:3 option, with change DAR=4:3, result 1280x720 [PAR 3:4 DAR 4:3]
PAR = DAR/SAR. = 4:3 / 16:9 = 3:4 (0.75)

http://en.wikipedia.org/wiki/Pixel_aspect_ratio

Re: incorrect display aspect on Sony Bravia

PostPosted: Wed Nov 16, 2011 4:56 pm
by zip
there is also setsar filter, did you try that? It'd probably have to go before the setdar filter in the chain, but not sure

Re: incorrect display aspect on Sony Bravia

PostPosted: Thu Nov 17, 2011 10:01 pm
by Illico
zip wrote:there is also setsar filter, did you try that? It'd probably have to go before the setdar filter in the chain, but not sure

Yes, allready try setsar option, if you use setsar, resulting dar changes, same that using serdar option.

I also try this, give a good result with my 640x336 [PAR 1:1 DAR 40:21] sample

ffmpeg.exe -i "Test1_640x336.avi" -y -threads 2 -vcodec mpeg2video -b 17000k -maxrate 17000k -bufsize 5097k -r 25 -g 15 -vf "scale=iw*16/9:ih","setdar=4:3" -copyts -acodec ac3 -ab 192k -ac 2 -map 0:0 -map 0:1 -sn -f mpegts "Test1_640x336-scale16-9dar4-3.ts"
Result (80 computing fps)
Stream #0.0: Video: mpeg2video, yuv420p, 1137x336 [PAR 13:33 DAR 4927:3696], q=2-31, 17000 kb/s, 90k tbn, 25 tbc

I know that DAR and PAR value are strange, but display is good, no need to use zoom option on sony menu then all pixels are displayed with good ratio.

Re: incorrect display aspect on Sony Bravia

PostPosted: Fri Nov 18, 2011 12:07 am
by zip
i hope it'll work with other renderers as well ;-)

I assume we only can do this for files with certain resolution, ie the target width cannot be higher than 1920. Do we need to add some padding on top/bottom?

Re: incorrect display aspect on Sony Bravia

PostPosted: Fri Nov 18, 2011 8:30 am
by Illico
zip wrote:i hope it'll work with other renderers as well ;-)

Not really sure :) , Sony seems to be alone with that issue...could be a profile option.
zip wrote:I assume we only can do this for files with certain resolution, ie the target width cannot be higher than 1920. Do we need to add some padding on top/bottom?


With my previous "Arrietty" sample 640x336 [PAR 1:1 DAR 40:21] seems good, no need to add padding.
But I'll try with some other sample source with weird DAR value, probably that we need to add padding.
That's why, on my previous example, I always up-scaled to a standard resolution 1280x720 or 1920x1080 HD.
I think we have not finished... :?

Re: incorrect display aspect on Sony Bravia

PostPosted: Fri Nov 18, 2011 10:03 am
by zip
Look here: https://bitbucket.org/xnejp03/serviio/i ... proper-par

I've been collecting links related to this issue.

Re: incorrect display aspect on Sony Bravia

PostPosted: Sat Nov 19, 2011 8:58 pm
by Illico
So I try this option "-vf "scale=iw*16/9:ih","setdar=4:3" with some another samples with different DAR=> Doesn't work.

(November 2011): My conclusion, 2 choices:


1) The best display result but resulting some cpu overhead.
- upscale to a HD resolution with the original source dar.
- padding to the HD 16/9 display ratio
- change the DAR=4/3
With DAR > = 16:9
"-vf "scale=1280:1280/dar/sar","pad=1280:720:(ow-iw)/2:(oh-ih)/2:black","setdar=4:3"
With DAR < 16:9
"-vf "scale=720*dar*sar:720","pad=1280:720:(ow-iw)/2:(oh-ih)/2:black","setdar=4:3"

2) An alternative - same that PS3 Media Server/Mencoder option -, resulting less cpu overhead, but some pixels (16) are lost on left and right side !!
- add padding to have a 16/9 aspect ratio (top/bot or left/right depends of the source format ratio)
- Change DAR=4/3
With DAR > = 16:9
-vf "pad=iw:iw/16*9:(ow-iw)/2:(oh-ih)/2:black","setdar=4:3"
With DAR < 16:9
-vf "pad=ih*16/9:ih:(ow-iw)/2:(oh-ih)/2:black","setdar=4:3"


Sony Bravia - Aspect Ratio fixing Topic update : viewtopic.php?f=11&t=2956&p=18767#p18767

Re: incorrect display aspect on Sony Bravia

PostPosted: Sun Nov 20, 2011 11:52 am
by zip
do you have any content that is more than 1280 wide? would the command still stand or would it actually downscale to 1280?