FAQ  •  Register  •  Login

fix pixel aspect ratio when transcoding

<<

klkr1

Serviio newbie

Posts: 4

Joined: Wed Mar 30, 2011 6:24 pm

Post Wed Mar 30, 2011 6:35 pm

fix pixel aspect ratio when transcoding

Hello,

is it possible to set up transcoding profiles which set the pixel aspect ratio to 1:1 while transcoding (by using the "-s" option of ffmpeg). Samsung B media player ignores pixel aspect ratios not equal to 1:1 but all my DVB recordings have pixel aspect ratio 5:4.

Regards,
klkr
<<

Illico

User avatar

DLNA master

Posts: 4646

Joined: Fri Jul 23, 2010 8:08 am

Location: France

Post Mon Apr 18, 2011 7:23 pm

Re: fix pixel aspect ratio when transcoding

Illico
Sony 2010 KDL-46EX501 | BDP-S373 | SMP-N100 | Windows 8-i7 | Network DD HD-CE1.5TLU2 | Livebox2-UHD86 | ServiiDroid | ServiiGo | BubbleUPnP
Serviio beta tester - Moderator
<<

klkr1

Serviio newbie

Posts: 4

Joined: Wed Mar 30, 2011 6:24 pm

Post Sat Apr 23, 2011 6:31 pm

Re: fix pixel aspect ratio when transcoding

Thx for your reply. On second thought setting target size with -s does not fully solve the problem for me.
My MPEGs are 720x576 with a DisplayAspectRatio of either 4:3 or 16:9 which results in a PixelAspectRatio of 16:15 or 64:45. In order to get a PixelAspectRatio of 1:1 I would have to set -s 720x540 for 4:3 MPEGs but -s 720x405 for 16:9 MPEGs. I experimented with setting ffmpeg.location to a wrapper script which calls ffmpeg -i to get the aspect ratio from the source MPEG and afterwards transcodes it by selecting the target size according to the aspect ratio.
It would be great if Serviio could support such a feature.
<<

sunnyday

Streaming enthusiast

Posts: 36

Joined: Thu Feb 17, 2011 2:17 pm

Location: Stockholm, Sweden

Post Sun Apr 24, 2011 6:37 am

Re: fix pixel aspect ratio when transcoding

I agree - such a feature would be really great for all B-series owners!
Hopefully, it would also make it possible to watch DVD VOB files from hard drive without being distorted.
Samsung UE46D5005XXE | Samsung BD-C6500
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 17212

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Sun Apr 24, 2011 6:22 pm

Re: fix pixel aspect ratio when transcoding

Can you give an example of a couple of videos with different PAR / DAR and resolution (ffmpeg -i) anf the ffmpeg command you have to use to get the DAR correct?
<<

sunnyday

Streaming enthusiast

Posts: 36

Joined: Thu Feb 17, 2011 2:17 pm

Location: Stockholm, Sweden

Post Sun Apr 24, 2011 10:09 pm

Re: fix pixel aspect ratio when transcoding

Thanks for your soon reply, Petr.

As stated by klkr1 above, integrated media player in Samsung B-Series do not recognize other Pixel Aspect Ratio than 1:1.

For HD recorded media this flaw has no implications. But for Standard Definition recodings and DVD VOB-files intended for 16x9, this is fatal.
When playing such media files (either via DLNA / Serviio or via USB plug in TV) video gets horizontally shrinked to 4:3.
This issue has been tracked at Samsung/Cnet in several threads e.g. http://forums.cnet.com/7723-13973_102-348673.html
Samsung has never fixed this problem, but there are working firmware patches available from Samygo project http://www.samygo.tv/. There are are some risks involved applying them on CI+ capable TV sets, though.

It would be really handy if Serviio could take care of this defect instead!

Here are ffmpeg -i for some VOB:s not rendered correctly by B-series

Example 1:
Input #0, mpeg, from 'E:\Filmer\Film 1\VIDEO_TS\VTS_01_1.VOB':
Duration: 00:15:33.18, start: 0.160000, bitrate: 9204 kb/s
Stream #0.0[0x1e0]: Video: mpeg2video, yuv420p, 720x576 [PAR 64:45 DAR 16:9], 8875 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0.1[0x80]: Audio: ac3, 48000 Hz, stereo, s16, 192 kb/s

Example 2:
Input #0, mpeg, from 'E:\Filmer\Film 2\VIDEO_TS\VTS_01_1.VOB':
Duration: 00:07:00.35, start: 0.228544, bitrate: 6838 kb/s
Stream #0.0[0x1e0]: Video: mpeg2video, yuv420p, 720x576 [PAR 64:45 DAR 16:9], 9608 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0.1[0x80]: Audio: ac3, 48000 Hz, stereo, s16, 192 kb/s

Example 3:
Input #0, mpeg, from 'E:\Filmer\Film 3\VTS_01_1.VOB':
Duration: 00:21:00.06, start: 0.287267, bitrate: 6817 kb/s
Stream #0.0[0x1e0]: Video: mpeg2video, yuv420p, 720x576 [PAR 64:45 DAR 16:9], 9000 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0.1[0x80]: Audio: ac3, 48000 Hz, stereo, s16, 192 kb/s


It is possible to make them "B-series understandable" whith the following command:
ffmpeg.exe -i "E:\Film 5\VTS_01_1.VOB" -y -vcodec mpeg2video -vb 9000k -copyts -acodec copy -f mpegts -s 720x405 "C:\Program Files\Serviio\temp.stf"

- or -

ffmpeg.exe -i "E:\Film 5\VTS_01_1.VOB" -y -vcodec mpeg2video -vb 9000k -copyts -acodec copy -f mpegts -s 1024x576 "C:\Program Files\Serviio\temp.stf"

My ffmpeg knowledge is limited, perhaps other important flags are missing. Bitrate 9000k was just something i made up (all inspected DVD:s had a bitrate around 9000). As for the -s switch I dont know what size to fill in. Both of the above seem to work.

Cheers, Peter B
Samsung UE46D5005XXE | Samsung BD-C6500
<<

sunnyday

Streaming enthusiast

Posts: 36

Joined: Thu Feb 17, 2011 2:17 pm

Location: Stockholm, Sweden

Post Tue Apr 26, 2011 7:11 pm

Re: fix pixel aspect ratio when transcoding

After further testing i have found out -s 1024x576 is valid parameter to transform any .VOB-file or PVR recording of Standard Definition 16x9 transmission into 16x9 with Pixel Aspect Ratio 1x1. Thus, recordings becomes playable on Samsung B-series.

Problem remains how to tell ffmpeq what bitrate to use.

Tried to add -sameq (instead of -vb) to command line with the following results:
For .TS files recorded with progdvb -sameq seem to render with correct quality. Size of destination file is 18% larger than source. (Perhaps this increase corresponds to the video information filled into both sides of 4:3 screen)
For some DVD VOB files, bitrate sometimes becomes way too high (in one case 14,7 Mbps) which results in a huge stf file. Have not yet found out why this occurs just in a few cases.
Samsung UE46D5005XXE | Samsung BD-C6500
<<

klkr1

Serviio newbie

Posts: 4

Joined: Wed Mar 30, 2011 6:24 pm

Post Mon May 02, 2011 6:39 pm

Re: fix pixel aspect ratio when transcoding

zip wrote:Can you give an example of a couple of videos with different PAR / DAR and resolution (ffmpeg -i) anf the ffmpeg command you have to use to get the DAR correct?


PAR equals DAR / (ratio of video size).
In order to get PAR 1:1 the video size ratio must be the same as the DAR. If y is the vertical video size then the horizontal size must be set to DAR * y.


16:9
Stream #0.0[0x3f2]: Video: mpeg2video, yuv420p, 720x576 [PAR 64:45 DAR 16:9], 4300 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
16:9 / 720:576 = (16 * 576) : (9 * 720) => PAR 64:45
y = 576 => x = 576 * 16:9 = 1024 => ffmpeg ...... -s 1024x576 .....
y = 405 => x = 405 * 16:9 = 720 => ffmpeg ...... -s 720x405 .....

Stream #0.0[0x1e0]: Video: mpeg2video, yuv420p, 576x576 [PAR 16:9 DAR 16:9], 104857 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
16:9 / 576:576 = (16 * 576) : (9 * 576) => PAR 16:9
y = 576 => x = 576 * 16:9 = 1024 => ffmpeg ...... -s 1024x576 ....
y = 405 => x = 405 * 16:9 = 720 => ffmpeg ...... -s 720x405 .....

4:3
Stream #0.0[0x1e0]: Video: mpeg2video, yuv420p, 720x576 [PAR 16:15 DAR 4:3], 104857 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
4:3 / 720:576 = (4 * 576) : (3 * 720) => PAR 16:15
y = 576 => x = 576 * 4:3 = 768 => ffmpeg ....... -s 768x576 .....
y = 540 => x = 540 * 4:3 = 720 => ffmpeg ....... -s 720x540 .....

Stream #0.0[0x1e0]: Video: mpeg2video, yuv420p, 1024x576 [PAR 3:4 DAR 4:3], 104857 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
4:3 / 1024:576 = (4 * 576) : (3 * 1024) => PAR 3:4
y = 576 => x = 576 * 4:3 = 768 => ffmpeg ....... -s 768x576 .....
y = 540 => x = 540 * 4:3 = 720 => ffmpeg ....... -s 720x540 .....

The rest of the ffmpeg command should look something like posted by sunnyday.
It would be great if the value for y was configurable and also if there would be another option where additional ffmpeg options such as bitrate could be configured.
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 17212

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Mon May 02, 2011 9:43 pm

Re: fix pixel aspect ratio when transcoding

Brilliant, thanks for this. So the -aspect parameter has no use?
<<

klkr1

Serviio newbie

Posts: 4

Joined: Wed Mar 30, 2011 6:24 pm

Post Wed May 04, 2011 7:50 pm

Re: fix pixel aspect ratio when transcoding

the parameter -aspect sets the DAR. In normal cases this should be enough to get an undistorted view. In my case the DAR is already correct but the samsung implementation ignores this setting and takes the video aspect ratio instead of the DAR or in other words assumes that the pixels in the video are of size 1:1. Therefore the video aspect ratio has to be the same as the DAR.
<<

Illico

User avatar

DLNA master

Posts: 4646

Joined: Fri Jul 23, 2010 8:08 am

Location: France

Post Sun Jul 31, 2011 6:36 pm

Re: fix pixel aspect ratio when transcoding

That could be find to use "-s" and "-aspect" ffmpeg option to transcode file with correct display ratio.

Such as "-vf softskip,expand=::::1:16/9,dsize=4/3" Mencoder option (used with PS3 Media Server that solved Sony Bravia Aspect Ratio issue).
http://www.ps3mediaserver.org/forum/vie ... lem#p46357

The klkr1 post is a good start.
Illico
Sony 2010 KDL-46EX501 | BDP-S373 | SMP-N100 | Windows 8-i7 | Network DD HD-CE1.5TLU2 | Livebox2-UHD86 | ServiiDroid | ServiiGo | BubbleUPnP
Serviio beta tester - Moderator
<<

Illico

User avatar

DLNA master

Posts: 4646

Joined: Fri Jul 23, 2010 8:08 am

Location: France

Post Sat Aug 06, 2011 6:41 pm

Re: fix pixel aspect ratio when transcoding

klkr1 wrote:PAR equals DAR / (ratio of video size).
In order to get PAR 1:1 the video size ratio must be the same as the DAR. If y is the vertical video size then the horizontal size must be set to DAR * y.


16:9
Stream #0.0[0x3f2]: Video: mpeg2video, yuv420p, 720x576 [PAR 64:45 DAR 16:9], 4300 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
16:9 / 720:576 = (16 * 576) : (9 * 720) => PAR 64:45
y = 576 => x = 576 * 16:9 = 1024 => ffmpeg ...... -s 1024x576 .....
y = 405 => x = 405 * 16:9 = 720 => ffmpeg ...... -s 720x405 .....

Stream #0.0[0x1e0]: Video: mpeg2video, yuv420p, 576x576 [PAR 16:9 DAR 16:9], 104857 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
16:9 / 576:576 = (16 * 576) : (9 * 576) => PAR 16:9
y = 576 => x = 576 * 16:9 = 1024 => ffmpeg ...... -s 1024x576 ....
y = 405 => x = 405 * 16:9 = 720 => ffmpeg ...... -s 720x405 .....

4:3
Stream #0.0[0x1e0]: Video: mpeg2video, yuv420p, 720x576 [PAR 16:15 DAR 4:3], 104857 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
4:3 / 720:576 = (4 * 576) : (3 * 720) => PAR 16:15
y = 576 => x = 576 * 4:3 = 768 => ffmpeg ....... -s 768x576 .....
y = 540 => x = 540 * 4:3 = 720 => ffmpeg ....... -s 720x540 .....

Stream #0.0[0x1e0]: Video: mpeg2video, yuv420p, 1024x576 [PAR 3:4 DAR 4:3], 104857 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
4:3 / 1024:576 = (4 * 576) : (3 * 1024) => PAR 3:4
y = 576 => x = 576 * 4:3 = 768 => ffmpeg ....... -s 768x576 .....
y = 540 => x = 540 * 4:3 = 720 => ffmpeg ....... -s 720x540 .....


Thanks, but this solution only work for original file with DAR = 4:3 or 16:9.
When its different (for exmpla 19:10, 40:21, 20:11), you have to expand (add top/bot padding) the original file resolution to match a 4:3 or 16:9 DAR.
I'm working on using -vf "pad=w:h:x:y:black" ffmpeg option.
Illico
Sony 2010 KDL-46EX501 | BDP-S373 | SMP-N100 | Windows 8-i7 | Network DD HD-CE1.5TLU2 | Livebox2-UHD86 | ServiiDroid | ServiiGo | BubbleUPnP
Serviio beta tester - Moderator

Return to Transcoding

Who is online

Users browsing this forum: No registered users and 18 guests

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.