You have to do the math at least once for your basic config. Either you always adjust the play duration for each photo or video in a layout yourself or you use the modules and functions that come with the xibo cms.
My suggestion would be to use a Webhook for Actions or (Sub-) Playlists. Check out the posts below.
Using Webhooks to trigger a Layout
Sub-Playlists