Skip to content

Conversation

@TomKaltz
Copy link
Member

@TomKaltz TomKaltz commented Jun 26, 2025

This PR adds layer level AUTO_LENGTH to PLAY, LOADBG and LOAD to override auto play behavior at the layer level. This allows auto play functionality with infinite length producers (decklink, bluefish, looping content, etc.). Previously, infinite length producers couldn't use timed auto play since their nb_frames() returns infinity. With this change, users can now specify AUTO_LENGTH with any producer to override nb_franes. The implementation tracks separate auto_length overrides for foreground and background producers at the layer level.

This PR also adds a layer level CALL FRAMES_LEFT that allows you to query, set and clear the AUTO_LENGTH overide to augment auto play functionality at runtime. CALL 1-0 FRAMES_LEFT 200 will change the AUTO_LENGTH override so that the auto transition will occur 200 frames from when the command was executed, effectively starting a countdown clock of the specified frames. It will also set AUTO play to true if there is a background producer loaded. CALL 1-0 FRAMES LEFT CLEAR will remove any AUTO_LENGTH override and also disable auto play.

notable autoplay behavior

  • If a producer's actual length is shorter than the supplied AUTO_LENGTH (ffmpeg producer with short file or IN, OUT creating a shorter than AUTO_LENGTH clip), then the last frame is repeated until LENGTH frame count is achieved.
  • You can use IN, OUT(or LENGTH), LOOP and AUTO_LENGTH together with ffmpeg producer to create a custom looping clip that will loop until AUTO_LENGTH frame count is achieved.

closes #1644

@TomKaltz TomKaltz force-pushed the tk-length-override branch from 686f853 to 4d218f4 Compare June 26, 2025 04:04
TomKaltz added 2 commits June 28, 2025 09:51
-add layer level call with FRAMES_LEFT overrides
@TomKaltz TomKaltz changed the title implement layer level LENGTH override to support AUTO play for all producers implement layer level AUTO_LENGTH override to support AUTO play for all producers Jun 29, 2025
@TomKaltz TomKaltz marked this pull request as ready for review June 29, 2025 03:49
@TomKaltz TomKaltz requested a review from Julusian June 29, 2025 03:49
foreground_ = frame_producer::empty();
auto_play_ = false;
foreground_auto_length_override_.reset();
background_auto_length_override_.reset();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is correct, as we aren't disposing of background_

Suggested change
background_auto_length_override_.reset();

std::wstring value = boost::to_upper_copy(params[1]);
if (value == L"CLEAR" || value == L"RESET") {
foreground_auto_length_override_.reset();
auto_play_ = false; // Disable AUTO entirely
Copy link
Member

@Julusian Julusian Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If doing this, there should be a way to reverse this and to re-enable auto-play with the default duration

perhaps FRAMES_LEFT AUTO would be how to do this?

L"FRAMES_LEFT SET TO " + boost::lexical_cast<std::wstring>(frames_left_value)));
}
} catch (const boost::bad_lexical_cast&) {
return make_ready_future(std::wstring(L"ERROR: Invalid frames value"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should throw an error, otherwise AMCP will report a 2xx status code, indicating that it was ok.

}
}

std::future<std::wstring> call(const std::vector<std::wstring>& params)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of the AMCP responses from this are unusual. They say things like AUTO PLAY NOT ACTIVE which will be annoying to parse in a library in any kind of generic way.
It would be better to simply return FRAMES_LEFT TRUE 123. While less human readable, it will be much easier to parse without needing to consider every route through the code.

virtual std::future<void> clear_transforms() = 0;
virtual std::future<frame_transform> get_current_transform(int index) = 0;
virtual std::future<void>
load(int index, const spl::shared_ptr<frame_producer>& producer, bool preview = false, bool auto_play = false) = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nicer to replace these other methods, instead of adding more with extra parameters.
The new parameter could have a default value of none, so to the couple of callsites that havent been touched in this PR could continue that way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RFC: auto play for infinite length producers

2 participants