RFC: auto play for infinite length producers
Description
Using LOADBG AUTO is the most reliable way to get frame-accurate playlist functionality. For infinite length producers (FFMPEG with LOOP, ROUTE, DECKLINK, IMAGE, etc) AUTO is not an option. It would be very useful if the user could set the auto play length for any producer...even an infinite length one.
Solution suggestion
I see two options for implementing this...
- modify all producers to honor a length property for auto play purposes (even ffmpeg with loop), or
- Add a new AMCP token to set the auto play duration in LOADBG
What do you all think?
After tinkering with an implementation I realize that this feature should probably be called something else and we should introduce a new AMCP token like AUTO_LENGTH. This way producer behavior doesn't change in regards to LENGTH handling. AUTO_LENGTH would be an override at the layer level for auto play behavior.
I would also like to add CALL interception at the layer level so the user could do CALL AUTO_LENGTH to reset the AUTO_LENGTH, effectively setting a new frames_left countdown timer at runtime.
And now I'm realizing that AUTO_LENGTH might be confusing when setting that with LOADBG with AUTO. Not sure what else to call this new feature AUTO_LENGTH still seems to be the best choice.
...or should we just use LENGTH and document the edge case behaviors that layer level length override brings?
I think I've landed on an API for this enhancement, see #1650
And now I'm realizing that AUTO_LENGTH might be confusing when setting that with LOADBG with AUTO. Not sure what else to call this new feature AUTO_LENGTH still seems to be the best choice.
Alternate name ideas: PLAYTIME, PLAY_TIME, PLAY_LENGTH, DURATION
I think AUTO_LENGTH is still the best choice. It's only for AUTO play purposes which is already slightly quirky on it's own due to how you have to set it on the background producer. That's what I'm going to proceed with in #1650.
I have added layer level CALL FRAMES_LEFT X that sets an AUTO_LEGTH to current frame + X to allow for runtime auto play "auto transition in X from now" behavior.
I think I will also add a layer level CALL(and CALLBG) AUTO_LENGTH to explicitly set AUTO_LENGTH to at runtime as well.
I think AUTO_LENGTH is still the best choice. It's only for AUTO play purposes which is already slightly quirky on it's own due to how you have to set it on the background producer.
@TomKaltz Oh OK. Sorry, somehow I got the idea that it could also be used with the PLAY command, and thought
PLAY 1-10 foobar LOOP PLAYTIME 88008
would make more sense than
PLAY 1-10 foobar LOOP AUTO_LENGTH 88008
But, if that's not the case, never mind then. 😳
This is good feedback. AUTO_LENGTH in #1650 currently follows the producer it was set on just like LENGTH would. That measn you can set AUTO_LENGTH for a producer via PLAY, LOAD and LOADBG. If you do...
PLAY 1-10 firstclip LOOP AUTO_LENGTH 1000
LOADBG 1-10 secondclip LOOP AUTO_LENGTH 500 AUTO
wait for secondclip to automatically transition to foreground
LOADBG 1-10 thirdclip AUTO
firstclip loops for 1000 totals frames and then transition to secondclip clip where it will play for 500 frames and so on. Does this make sense? This setting is only for AUTO play purporses which is why I feel so strongly about the current API in #1650.
Oh... so, it does work with the PLAY command as well. In that case, yes AUTO_LENGTH is somewhat confusing. Even in the context of LOADBG. When I see AUTO_LENGTH, it makes me think it has something to do with the length of auto transition. 🤷🏻
To clarify, I love the API and I think this is a great addition. I just think the name AUTO_LENGTH is not the best choice. 😅
What about AUTOPLAY_LENGTH or something along those lines? The “length” concept in classic CasparCG never pertained to transition duration and always pertained to clip duration in the ffmpeg producer...which is another good reason reason to stick with that concept. AUTO is also a well-known concept and this new feature pertains only to AUTO play timing.
I really wanted to just make it LENGTH to extend the currently known API to all producer types…but there would be strange edge cases with ffmpeg producer in the certain case, for example with LOOP and/or SEEK since the layer and the producer would be using the same values in different ways. Although the more I think about it I'm not sure it would break anyone's current usage of LENGTH except that LOOP is essentially now negated if LENGTH is specified. Previous behavior with LOOP and LENGTH is that AUTO play was never triggered.
Again, this feature only pertains to clip playout length/duration for auto transition purposes. If AUTO_LENGTH is not set for a producer OR if AUTO_LENGTH is set but there is no background producer set with AUTO then the foreground producer is played out to its natural LENGTH/duration and then paused on last frame.
What about keeping AUTO and adding another parameter like DURATION xxxxx after it for overwriting the media duration itself?
AUTO is not changing. It can be used when doing LOAD, LOADBG. This new feature overrides how/when auto play is triggered.
DURATION could be an option but I’m trying to make it clear with AUTO_LENGTH that the setting only applies when using AUTO. Setting DURATION without AUTO is confusing because it would have no effect.
On Fri, Jul 4, 2025 at 01:11 premultiply @.***> wrote:
premultiply left a comment (CasparCG/server#1644) https://github.com/CasparCG/server/issues/1644#issuecomment-3034559656
What about keeping AUTO and adding another parameter like DURATION xxxxx after it for overwriting the media duration itself?
— Reply to this email directly, view it on GitHub https://github.com/CasparCG/server/issues/1644#issuecomment-3034559656, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWT6IK4BH4ZEFKCM47SQ5D3GYEJVAVCNFSM6AAAAAB7NRS65OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTAMZUGU2TSNRVGY . You are receiving this because you were mentioned.Message ID: @.***>
@TomKaltz sorry got distracted. Would it be too much hassle to make it work the regular PLAY command? This is what I thought it did in the beginning. I believe @premultiply also got that idea.
It would be cool if we could do:
PLAY 1-10 foobar LOOP DURATION 8008
Then it would also be used for LOADBG with or without AUTO, and it would always do the same thing. What do you say?
I kind of like that idea I’ll think about that. I believe we would just return the last frame upon reaching that frame count (or perhaps pause the producer). That way the producer pauses if there is no autoplay enabled clip loaded similar to how LENGTH currently works with ffmpeg producer.
Your request makes me think we should just go back to using LENGTH instead of introducing a new concept and just document the changes in how LENGTH now works. Basically LENGTH would now work for all producers. We would just need to advise users to use IN-OUT for sub-clipping with ffmpeg producer from now on. (in case they use features like CALL SEEK, or any other edge case where a layer level LENGTH override would cause pre-mature pausing of the producer).
@Julusian would you support deprecation of LENGTH as a parameter in the ffmpeg producer in favor of layer level LENGTH handling which essentially keeps the same behavior for most ffmpeg producer cases but would extend LENGTH capability to all producers?
IMHO LENGTH can still be useful... for the lazy people like me :) It saves one from having to compute the OUT parameter. But, I am willing to forgo it for the sake of the above. Alternatively, DURATION and PLAYTIME are good candidates too. Just my 2 cents.
I think I could get behind DURATION now that this will affect more than just AUTO play. Anyone else have any votes? LENGTH, DURATION, PLAYTIME, anything?