Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Cap Animate frames before alignment

Bittiac274a67cea9
diff --git a/docs/video-references.md b/docs/video-references.md
index 8c11825..1732b87 100644
--- a/docs/video-references.md
+++ b/docs/video-references.md
@@ -8,6 +8,12 @@ inspector. The image should be a frame of the driving scene with the character
repainted, preserving pose, framing, background and lighting. A standalone
portrait is not an equivalent input. Continuation and refmods are unsupported.
+Animate output is capped at **345 frames (14.375 seconds)**. SlopFab aligns
+frame counts upward to `17*k + 5`; a 15-second request (360 frames at 24 fps)
+would become 362 frames and exceed its 360-frame limit. Slopus caps requests
+within the 15-second range at 345 frames before planning and generation, so
+selecting 14.5 or 15 seconds produces 14.375 seconds of output.
+
Slopus enables SlopFab C API 1.10's Animate recipe and supplies the downloaded
362-token embedding and modality tags. Qwen and the tokenizer are neither
downloaded nor passed to Animate. The bundled fixed prompt remains descriptive
diff --git a/src-tauri/src/slopfab.rs b/src-tauri/src/slopfab.rs
index 001e75d..6623125 100644
--- a/src-tauri/src/slopfab.rs
+++ b/src-tauri/src/slopfab.rs
@@ -19,6 +19,8 @@ use tauri::{AppHandle, Emitter};
const DLL_FILE_NAME: &str = "slopfab.dll";
// https://huggingface.co/Viggle/Viggle-Animate/raw/main/assets/fixed_prompt.txt
const ANIMATE_PROMPT: &str = include_str!("../assets/viggle-animate-fixed-prompt.txt");
+// SlopFab rounds up to 17*k + 5 frames but rejects Animate plans over 360.
+const ANIMATE_MAX_ALIGNED_FRAMES: i32 = (360 - 5) / 17 * 17 + 5;
/// Tauri stages the repository's runtime resources in development and release
/// builds. Installers and portable folders use the same relative layout.
pub fn default_dll_path() -> PathBuf {
@@ -741,7 +743,12 @@ fn configure_request(
api.set_prompt_embedding(handle, &embedding)?;
}
api.set_prompt(handle, if configuration.animate { ANIMATE_PROMPT } else { &request.prompt })?;
- api.set_frames(handle, request.frames)?;
+ // Keep lengths within the advertised 15-second range from rounding past
+ // Animate's limit. Leave out-of-range requests to the DLL's validation.
+ let frames = if configuration.animate && request.frames <= 360 {
+ request.frames.min(ANIMATE_MAX_ALIGNED_FRAMES)
+ } else { request.frames };
+ api.set_frames(handle, frames)?;
if request.still_image {
api.set_still_image(handle)?;
}
@@ -1897,6 +1904,55 @@ mod tests {
result.unwrap();
}
+ #[test]
+ fn animate_duration_limit_resolves_with_bundled_dll() {
+ let root = tempfile::tempdir().unwrap();
+ let embedding = root.path().join("conditioning.safetensors");
+ crate::conditioning::fixture(&embedding);
+ let settings = BTreeMap::new();
+ let mut configuration = Configuration::from_settings(&settings);
+ configuration.animate = true;
+ configuration.prompt_embedding = Some(embedding);
+ let api = ffi::Api::load(&configuration.dll_path).unwrap();
+ let id = create_reference_video(15.0, &settings).unwrap();
+ let result = (|| -> Result<(), String> {
+ append_reference_video(&id, &vec![127; 64 * 64 * 4], 64, 64, 0.0)?;
+ let mut request = GenerationRequest {
+ prompt: "A dancer.".into(), steps: 4, seed: 1,
+ canvas_width: 736, canvas_height: 416, reference_video_ids: vec![id.clone()],
+ reference_paths: vec!["repainted.png".into()],
+ ..Default::default()
+ };
+ for platform in [ComputePlatform::Cuda13, ComputePlatform::Vulkan] {
+ for include_models in [false, true] {
+ for (frames, expected) in [(48, 56), (336, 345), (345, 345), (346, 345), (348, 345), (359, 345), (360, 345)] {
+ request.frames = frames;
+ let handle = RequestHandle::new(&api)?;
+ configure_request(&api, handle.0, &request, &configuration, platform, include_models)?;
+ let plan = api.resolve(handle.0)?;
+ assert_eq!(plan.aligned_frames, expected, "requested {frames} frames");
+ assert_eq!(plan.duration_seconds, f64::from(expected) / 24.0);
+ assert_eq!(scene_frame_window(&request, plan.aligned_frames)?, (0, expected));
+ }
+ }
+ }
+ request.frames = 361;
+ let handle = RequestHandle::new(&api)?;
+ configure_request(&api, handle.0, &request, &configuration, ComputePlatform::Cuda13, false)?;
+ assert!(api.resolve(handle.0).err().unwrap().contains("at most 15 seconds"));
+
+ // Other generators keep their existing upward alignment at 15 s.
+ configuration.animate = false;
+ request.frames = 360;
+ let handle = RequestHandle::new(&api)?;
+ configure_request(&api, handle.0, &request, &configuration, ComputePlatform::Cuda13, false)?;
+ assert_eq!(api.resolve(handle.0)?.aligned_frames, 362);
+ Ok(())
+ })();
+ release_reference_videos(&[id]).unwrap();
+ result.unwrap();
+ }
+
#[test]
fn animate_reports_missing_runtime_api() {
let mut api = ffi::Api::load(&default_dll_path()).unwrap();
diff --git a/src/components/workspace/SceneEditor.tsx b/src/components/workspace/SceneEditor.tsx
index 641ed99..a0cc51f 100644
--- a/src/components/workspace/SceneEditor.tsx
+++ b/src/components/workspace/SceneEditor.tsx
@@ -399,6 +399,7 @@ export function SceneInspector({ job, shots, references, previousScene, defaultS
</section>
<section className="scene-settings" aria-labelledby={`${job.id}-generation-settings`}>
<h3 id={`${job.id}-generation-settings`}>Generation</h3>
+ {animate && <p>Animate output is limited to 14.375 seconds. Longer scene lengths are shortened to fit.</p>}
<div className="scene-settings__numbers">
<label className="scene-settings__field">
<span>Steps</span>