It is possible to set scaler output resolution dynamically. Refer the API documentation of SCLR_LINK_CMD_SET_OUTPUTRESOLUTION cmd. You can do SCLR_LINK_CMD_GET_OUTPUTRESOLUTION and then do SET by changing the required params.
Scaler will however not insert LetterBox/PillarBox on the video frame. If you want to apply letterBix/PillarBox it is better you use SwMs and create a 1x1 layout of required dimension. The background of SwMs will be blanked out .
The aspect ratio info can be got from the H264 decoder but this info is not exported to the application. SOme minor changes are required in decLink to support this.
For the encoder VUI info , changes are required to the encoder dynamic params API to accept aspect ratio info from the application and then set the encoder VUI info accordingly. This requires some changes in encLink.