Feature Request: Advanced aspect ratio conrtol

Issue #974 resolved
Former user created an issue

For some scenarios current aspect ratio handling is quite limited (see http://forum.serviio.org/viewtopic.php?f=7&t=22645&p=111229#p111229)

FFMPEG is able to handle aspect ratio changes making use of its filter library. The following code - modularized by function - could handle all aspect ratio / scaling scenarios I could thing of.

Filter module                    Parameter          ffmpeg filter code 
AutoCrop                         true/false         `ffmpeg -ss 60 -i SOURCE.EXT -f matroska -t 10 -an -vf cropdetect=24:16:0 -y -crf 51 -preset ultrafast /dev/null 2>&1 | grep -o crop=.* | sort -bh | uniq -c | sort -bh | tail -n1 | grep -o crop=.*`,scale="trunc(iw/hsub)*hsub:trunc(ih/vsub)*vsub"
Storage Aspect Ratio             [w/h]              scale="trunc(iw*sar/([w/h])/hsub)*hsub:trunc(ih/vsub)*vsub",setsar="[w/h]"
Display Aspect Ratio by padding  [w/h]              pad="trunc(if(lt(dar\,[w/h])\,ih*[w/h]/sar\,iw)/hsub)*hsub:trunc(if(lt(dar\,[w/h])\,ih\,iw/([w/h])*sar)/vsub)*vsub:(ow-iw)/2\:(oh-ih)/2:black",setdar="[w/h]"

Width                            [width]            scale="trunc([width]/hsub)*hsub:trunc(ow*sar/dar/vsub)*vsub"
Height                           [height]           scale="trunc(oh/sar*dar/hsub)*hsub:trunc([height]/vsub)*vsub"
maxWidth                         [max_width]        scale="trunc(if(gt(iw\,[max_width])\,[max_width]\,iw)/hsub)*hsub:trunc(ow*sar/dar/vsub)*vsub"
maxHeight                        [max_height]       scale="trunc(oh/sar*dar/hsub)*hsub:trunc(if(gt(ih\,[max_height])\,[max_height]\,ih)/vsub)*vsub"

It would be great if we could see some of those functions in some future version of Serviio. Of course I would be up for testing.

Comments (6)

  1. Petr Nejedly repo owner

    most of these formulas are inside Serviio (as it needs to know the future dimensions of a file, when browsing - ie before ffmpeg is even invoked). I checked and all the formulas match what Serviio uses.

    I will add squarePixels to the transcoding definitions and also some more available DARs

  2. Log in to comment