Help with PAL anamorphic renderer

For help and support with Universal Media Server
Forum rules
Please make sure you follow the Problem Reporting Guidelines before posting if you want a reply
Post Reply
oldtechguy
Posts: 5
Joined: Mon Jul 20, 2015 7:50 am

Help with PAL anamorphic renderer

Post by oldtechguy »

Hi,

Trying to set up a Buffalo LinkTheater P4-PLWAG PAL (Scart) renderer to my analogue (CRT) 16:9 widescreen TV via PAL composite.

I realise that everything in my server needs to be transcoded into a 720x576 MPEG2-PS container with the 16:9 anamorphic flag set, so I have tried adding the following

Code: Select all

MaxVideoWidth = 720
MaxVideoHeight = 576

Code: Select all

CustomFFmpegOptions = -target pal-dvd -aspect 16:9
and have tried both values of

Code: Select all

RescaleByRenderer
but any material I try just results in a wrongly-letterboxed image on my TV screen when I try to play the [FFMpeg] item in the #..TRANSCODE..# virtual folder that appears on the LinkTheater.

The aspect ratio of the source also seems not to matter. I have tried playing 640x360, 1280x720 and 480x360 ISO MPEG-4/H264/AAC material and they all end up displaying as double-letterboxed when transcoded with the above settings



Where do I go in to fix this ?
Attachments
ums_dbg.zip
(56.3 KiB) Downloaded 499 times
User avatar
valib
Developer
Posts: 699
Joined: Fri Feb 08, 2013 3:11 am

Re: Help with PAL anamorphic renderer

Post by valib »

Sorry this is a special case we didn't anticipate. We assumed that we should scale or pad only to aspect ratio 1,777 (16/9) not to 1,25.

You can try to add to your renderer .conf

Code: Select all

OverrideFFmpegVideoFilter = scale=iw*min(720/iw\\,576/ih):ih*min(720/iw\\,576/ih)\\,pad=720:576:(720-iw)/2:(576-ih)/2
KeepAspectRatio and RescaleByRenderer in your case doesn't work. I will check what should be done to make it working in UMS.
oldtechguy
Posts: 5
Joined: Mon Jul 20, 2015 7:50 am

Re: Help with PAL anamorphic renderer

Post by oldtechguy »

Thanks for taking the trouble to reply to my problem.

Adding the line you supplied and setting the other two options back to their defaults gets me this...

Code: Select all

DEBUG 05:47:39.868 [ffmpeg.exe-2] Starting C:\Program Files\Universal Media Server\win32\ffmpeg.exe -y -loglevel info -i F:\Video\ASMR\___ Oh such a good 3D-sound ASMR video ___ - YouTube.mp4 -filter_complex scale=iw*min(720/iw\,576/ih):ih*min(720/iw\,576/ih)\,pad=720:576:(720-iw)/2:(576-ih)/2 -bufsize 1835000 -maxrate 44000000 -g 5 -q:v 1 -qmin 2 -qmax 3 -ab 448k -c:a ac3 -c:v mpeg2video -f vob \\.\pipe\ffmpegvideo_51_1437540459567
DEBUG 05:47:39.872 [ffmpeg.exe-2] Reading pipe: \\.\pipe\ffmpegvideo_51_1437540459567
TRACE 05:47:39.974 [ffmpeg.exe-2] Successfully initialized buffer to 52,428,800 bytes.
DEBUG 05:47:39.974 [ffmpeg.exe-2] Attaching thread: ffmpeg.exe-2
TRACE 05:47:39.976 [ffmpeg.exe-2-Timer] buffered: 0 bytes / inputs: 0
DEBUG 05:47:40.023 [ffmpeg.exe-2-2] ffmpeg version N-72259-g0b9d636 Copyright (c) 2000-2015 the FFmpeg developers
DEBUG 05:47:40.023 [ffmpeg.exe-2-2]   built with gcc 4.9.2 (GCC)
DEBUG 05:47:40.023 [ffmpeg.exe-2-2]   configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
DEBUG 05:47:40.023 [ffmpeg.exe-2-2]   libavutil      54. 23.101 / 54. 23.101
DEBUG 05:47:40.023 [ffmpeg.exe-2-2]   libavcodec     56. 39.101 / 56. 39.101
DEBUG 05:47:40.023 [ffmpeg.exe-2-2]   libavformat    56. 33.101 / 56. 33.101
DEBUG 05:47:40.023 [ffmpeg.exe-2-2]   libavdevice    56.  4.100 / 56.  4.100
DEBUG 05:47:40.023 [ffmpeg.exe-2-2]   libavfilter     5. 16.101 /  5. 16.101
DEBUG 05:47:40.023 [ffmpeg.exe-2-2]   libswscale      3.  1.101 /  3.  1.101
DEBUG 05:47:40.023 [ffmpeg.exe-2-2]   libswresample   1.  1.100 /  1.  1.100
DEBUG 05:47:40.023 [ffmpeg.exe-2-2]   libpostproc    53.  3.100 / 53.  3.100
DEBUG 05:47:40.040 [ffmpeg.exe-2-2] Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'F:\Video\ASMR\___ Oh such a good 3D-sound ASMR video ___ - YouTube.mp4':
DEBUG 05:47:40.040 [ffmpeg.exe-2-2]   Metadata:
DEBUG 05:47:40.040 [ffmpeg.exe-2-2]     major_brand     : mp42
DEBUG 05:47:40.040 [ffmpeg.exe-2-2]     minor_version   : 0
DEBUG 05:47:40.040 [ffmpeg.exe-2-2]     compatible_brands: isommp42
DEBUG 05:47:40.040 [ffmpeg.exe-2-2]     creation_time   : 2014-01-07 02:56:21
DEBUG 05:47:40.040 [ffmpeg.exe-2-2]   Duration: 00:16:21.41, start: 0.000000, bitrate: 476 kb/s
DEBUG 05:47:40.040 [ffmpeg.exe-2-2]     Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 640x360, 377 kb/s, 29.97 fps, 29.97 tbr, 60k tbn, 59.94 tbc (default)
DEBUG 05:47:40.040 [ffmpeg.exe-2-2]     Metadata:
DEBUG 05:47:40.040 [ffmpeg.exe-2-2]       handler_name    : VideoHandler
DEBUG 05:47:40.040 [ffmpeg.exe-2-2]     Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 96 kb/s (default)
DEBUG 05:47:40.040 [ffmpeg.exe-2-2]     Metadata:
DEBUG 05:47:40.040 [ffmpeg.exe-2-2]       creation_time   : 2014-01-07 02:56:23
DEBUG 05:47:40.040 [ffmpeg.exe-2-2]       handler_name    : IsoMedia File Produced by Google, 5-11-2011
DEBUG 05:47:40.041 [ffmpeg.exe-2-2] [scale @ 03c78cc0] [Eval @ 0022ed5c] Undefined constant or missing '(' in 'iw)/2'
DEBUG 05:47:40.041 [ffmpeg.exe-2-2] [scale @ 03c78cc0] Unable to parse option value "(720-iw)/2"
DEBUG 05:47:40.041 [ffmpeg.exe-2-2] [scale @ 03c78cc0] [Eval @ 0022edbc] Undefined constant or missing '(' in 'iw)/2'
DEBUG 05:47:40.041 [ffmpeg.exe-2-2] [scale @ 03c78cc0] Unable to parse option value "(720-iw)/2"
DEBUG 05:47:40.041 [ffmpeg.exe-2-2] [scale @ 03c78cc0] Error setting option interl to value (720-iw)/2.
DEBUG 05:47:40.041 [ffmpeg.exe-2-2] [Parsed_scale_0 @ 03c78c40] Error applying options to the filter.
DEBUG 05:47:40.041 [ffmpeg.exe-2-2] [AVFilterGraph @ 03bbd860] Error initializing filter 'scale' with args 'iw*min(720/iw,576/ih):ih*min(720/iw,576/ih),pad=720:576:(720-iw)/2:(576-ih)/2'
DEBUG 05:47:40.041 [ffmpeg.exe-2-2] Error configuring filters.
TRACE 05:47:40.068 [nioEventLoopGroup-3-4] Sleeping for 2500 milliseconds
TRACE 05:47:41.050 [ffmpeg.exe-2] EOF
INFO  05:47:41.050 [ffmpeg.exe-2] Process C:\Program Files\Universal Media Server\win32\ffmpeg.exe has a return code of 1! Maybe an error occurred... check the log file
oldtechguy
Posts: 5
Joined: Mon Jul 20, 2015 7:50 am

Re: Help with PAL anamorphic renderer

Post by oldtechguy »

OK, I fixed the syntax error - only the commas in the min() function need to be escaped, so I put

Code: Select all

OverrideFFmpegVideoFilter = scale=iw*min(720/iw\\,576/ih):ih*min(720/iw\\,576/ih),pad=720:576:(720-iw)/2:(576-ih)/2
and this is accepted by FFMpeg, but it has exactly no effect - I'm still seeing double-letterboxing on a YouTube 640x360 clip
Attachments
ums_dbg_22072015.zip
(51.33 KiB) Downloaded 479 times
User avatar
valib
Developer
Posts: 699
Joined: Fri Feb 08, 2013 3:11 am

Re: Help with PAL anamorphic renderer

Post by valib »

What about to try

Code: Select all

OverrideFFmpegVideoFilter = pad=iw:iw/(16/9):0:(oh-ih)/2
CustomFFmpegOptions = -target pal-dvd -aspect 16:9
If your TV will add any letterbox to the video with AR 640x360 (which is 16/9) it could mean that the TV needs other AR then 720x576
oldtechguy
Posts: 5
Joined: Mon Jul 20, 2015 7:50 am

Re: Help with PAL anamorphic renderer

Post by oldtechguy »

certainly I think the pad has to come before the scale otherwise a 16:9 movie will never fill the 720x576 PAL anamorphic container.

The pad has to create a 16:9 source, then that has to be squashed by scale to 720x576, e.g. cinematic 1.85:1 source of size 888x480 has to be first letterboxed to 888x500 (16:9 with /4 rounding), then scaled to 720x576

similarly 4:3 source of 640x480 has to be pillarboxed to 852x480 ( 16:9 with /4 rounding), then scaled to 720x576

Native 16:9 source less than SD, e.g. 640x360 should have no padding and be directly scaled up to 720x576

Native 16:9 source greater than SD again has no padding and is scaled down.

I have found a nice 'divisible by 4' rounding function

Code: Select all

((iwh % 4) > 2) ? (iwh + 4 - (iwh % 4)) : (iwh - (iwh % 4))
in Java/C - where iwh is either iw or ih. In FFMpeg this would use Mod(x,y) and If(x,y,z)

The TV is set to 'FULL' zoom setting ( a JVC model) which assumes that the 720x576 has a DAR of 16:9 and should fill the screen with it without letter or pillar boxes.
oldtechguy
Posts: 5
Joined: Mon Jul 20, 2015 7:50 am

Re: Help with PAL anamorphic renderer

Post by oldtechguy »

This works

Code: Select all

CustomFFmpegOptions = -aspect 4:3

Code: Select all

OverrideFFmpegVideoFilter = pad=max(iw\\,ih*(16/9)):ow/(16/9):(ow-iw)/2:(oh-ih)/2,scale=pal
The Buffalo LinkTheater P4-PLWAG requires the MPEG2 anamorphic flag to be UNSET when receiving anamorphic material that is to be displayed on a 16:9 aspect PAL CRT TV as it is too stupid to know about anything other than a 4:3 aspect PAL CRT display. If -aspect 16:9 is set, the LinkTheater letterboxes it for a 4:3 display. There are no menu options on the box to tell it what the aspect ratio of the TV is - it is too old.

The pad magic is to be found in an ffmpeg mailing list somewhere.

For some reason, the LinkTheater still adds a small letterbox when it receives 720x576 [SAR=16/15, DAR=4/3] material. This is just broken - that spec should fill the screen.

I tried putting

Code: Select all

...,scale=pal,setsar=ratio=1/1
but this is ignored and the final SAR is always 16/15


How you stop ffmpeg from overriding the explicit setsar, I have no idea.

Any clues anyone ?
Post Reply