Official Python inference and LoRA trainer package for the LTX-2 audio–video generative model.
Automated PR - 2026-09-30
github-actions[bot]2d6e71c88be3
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 745395e..9087fd3 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -1,5 +1,11 @@# Changelog+## 1.4.1 - 2026-09-30++### Changed++- HDR video encoding streams decoded chunks directly into EXR and HLG outputs instead of retaining the full clip in memory.+## 1.4.0 - 2026-09-29### Addeddiff --git a/packages/ltx-core/pyproject.toml b/packages/ltx-core/pyproject.tomlindex 106970b..0b6d888 100644--- a/packages/ltx-core/pyproject.toml+++ b/packages/ltx-core/pyproject.toml@@ -1,6 +1,6 @@[project]name = "ltx-core"-version = "1.4.0"+version = "1.4.1"description = "Core implementation of Lightricks' LTX-2 model"readme = "README.md"requires-python = ">=3.10"diff --git a/packages/ltx-core/src/ltx_core/color/hlg.py b/packages/ltx-core/src/ltx_core/color/hlg.pyindex 4660fde..5916f2b 100644--- a/packages/ltx-core/src/ltx_core/color/hlg.py+++ b/packages/ltx-core/src/ltx_core/color/hlg.py@@ -196,9 +196,6 @@ def _hlg_encode_planes_threaded(encoder: HlgPyAVEncoder,plane_chunks: Iterator[tuple[np.ndarray, np.ndarray, np.ndarray]],progress_total: int | None = None,- *,- audio: Audio | None = None,- audio_stream: av.audio.AudioStream | None = None,) -> int:"""libx265-encode planar uint16 chunks on a background thread (1-slot queue)."""chunk_queue: Queue[tuple[np.ndarray, np.ndarray, np.ndarray] | None] = Queue(maxsize=1)@@ -223,9 +220,6 @@ def _hlg_encode_planes_threaded(if error is None:try:encoder.flush()- if audio is not None and audio_stream is not None:- write_audio(encoder.container, audio_stream, audio)- encoder.container.close()except Exception as e:error = eelse:@@ -273,13 +267,27 @@ def encode_linear_hdr_frames_to_hlg_mp4( # noqa: PLR0913progress: bool = False,progress_total: int | None = None,thread_count: int = 0,- audio: Audio | None = None,+ audio: Audio | Iterator[Audio] | None = None,device: torch.device | None = None,+ audio_sampling_rate: int | None = None,) -> int:"""Encode scene-linear HDR frames to BT.2020/HLG/10-bit HEVC mp4 via PyAV.Consumes ``HxWx3`` / ``FxHxWx3`` chunks one at a time. Conversion runs on- ``device``; the encoder thread only muxes planar uint16 into libx265.+ ``device``; the encoder thread only muxes planar uint16 into libx265. An+ audio iterator is pulled after all frame chunks have been consumed; pass+ ``audio_sampling_rate`` so its AAC stream can be opened up front."""+ if isinstance(audio, Audio):+ validate_audio_waveform(audio)+ if audio_sampling_rate is not None and audio_sampling_rate != audio.sampling_rate:+ raise ValueError(+ f"audio_sampling_rate {audio_sampling_rate} does not match audio sampling rate {audio.sampling_rate}"+ )+ audio_sampling_rate = audio.sampling_rate+ audio = iter((audio,))+ elif audio is not None and audio_sampling_rate is None:+ raise ValueError("audio_sampling_rate is required when muxing an audio iterator")+converter = HlgGpuConverter.create(primaries, white_signal, rolloff_k, device=device)it = iter(frames)@@ -299,11 +307,6 @@ def encode_linear_hdr_frames_to_hlg_mp4( # noqa: PLR0913thread_count=thread_count,)- audio_stream: av.audio.AudioStream | None = None- if audio is not None:- validate_audio_waveform(audio)- audio_stream = prepare_audio_stream(encoder.container, audio.sampling_rate)-def plane_chunks() -> Iterator[tuple[np.ndarray, np.ndarray, np.ndarray]]:y, u, v = converter(first_t)yield y.cpu().numpy(), u.cpu().numpy(), v.cpu().numpy()@@ -312,16 +315,26 @@ def encode_linear_hdr_frames_to_hlg_mp4( # noqa: PLR0913yield y.cpu().numpy(), u.cpu().numpy(), v.cpu().numpy()try:+ audio_stream: av.audio.AudioStream | None = None+ if audio is not None:+ assert audio_sampling_rate is not None+ audio_stream = prepare_audio_stream(encoder.container, audio_sampling_rate)n = _hlg_encode_planes_threaded(encoder,plane_chunks(),progress_total=progress_total if progress or progress_total is not None else None,- audio=audio,- audio_stream=audio_stream,)- except Exception:+ mux_audio = next(audio, None) if audio is not None else None+ if mux_audio is not None:+ validate_audio_waveform(mux_audio)+ assert audio_stream is not None+ write_audio(encoder.container, audio_stream, mux_audio)+ except BaseException:Path(out_path).unlink(missing_ok=True)raise+ finally:+ with contextlib.suppress(Exception):+ encoder.container.close()if progress:logger.info(" %d frames", n)return ndiff --git a/packages/ltx-kernels/pyproject.toml b/packages/ltx-kernels/pyproject.tomlindex a510a77..f6f75e9 100644--- a/packages/ltx-kernels/pyproject.toml+++ b/packages/ltx-kernels/pyproject.toml@@ -8,7 +8,7 @@ build-backend = "setuptools.build_meta"[project]name = "ltx-kernels"-version = "1.4.0"+version = "1.4.1"dependencies = ["torch","triton>=3.0",diff --git a/packages/ltx-pipelines/pyproject.toml b/packages/ltx-pipelines/pyproject.tomlindex 39f67c3..6e80567 100644--- a/packages/ltx-pipelines/pyproject.toml+++ b/packages/ltx-pipelines/pyproject.toml@@ -1,6 +1,6 @@[project]name = "ltx-pipelines"-version = "1.4.0"+version = "1.4.1"description = "Pipelines implementation for Lightricks' LTX-2 model"readme = "README.md"requires-python = ">=3.10"diff --git a/packages/ltx-pipelines/src/ltx_pipelines/a2vid_two_stage.py b/packages/ltx-pipelines/src/ltx_pipelines/a2vid_two_stage.pyindex 4c88181..744adb7 100644--- a/packages/ltx-pipelines/src/ltx_pipelines/a2vid_two_stage.py+++ b/packages/ltx-pipelines/src/ltx_pipelines/a2vid_two_stage.py@@ -100,6 +100,7 @@ class _A2VidRunContext:stage_1_height: intencoded_audio_latent: torch.Tensorsource_audio: Audio+ chunk_config: ChunkConfigclass A2VidPipelineTwoStage:@@ -215,6 +216,7 @@ class A2VidPipelineTwoStage:enhance_static_cache: bool,generated_keyframes: int | Sequence[int] = 0,decode_with_keyframes: bool = False,+ chunk_config: ChunkConfig | None = None,) -> _A2VidRunContext:"""Validate inputs, decode/encode audio, and resolve frame count / tiling before chunk planning."""images = self.image_conditioner.resolve_crf(images)@@ -241,6 +243,9 @@ class A2VidPipelineTwoStage:)num_frames = snap_frames_to_grid(num_frames)+ if chunk_config is None:+ chunk_config = ChunkConfig(chunk_pixel_frames=num_frames, next_video_carry_frames=0)+ctx_p, ctx_n = self.prompt_encoder([prompt, negative_prompt],enhance_first_prompt=enhance_prompt,@@ -255,7 +260,13 @@ class A2VidPipelineTwoStage:tiling_config,scale_factors=scale_factors,vae_checkpoint_path=self.video_decoder.checkpoint_path,- video_shape=VideoPixelShape(batch=1, frames=num_frames, height=height, width=width, fps=frame_rate),+ video_shape=VideoPixelShape(+ batch=1,+ frames=min(num_frames, chunk_config.chunk_pixel_frames),+ height=height,+ width=width,+ fps=frame_rate,+ ),diffvae_optimization=self.video_decoder.diffvae_optimization,device=self.device,keyframes=decode_with_keyframes,@@ -284,6 +295,7 @@ class A2VidPipelineTwoStage:stage_1_height=height // 2,encoded_audio_latent=encoded_audio_latent,source_audio=source_audio,+ chunk_config=chunk_config,)def _video_conditionings(@@ -412,9 +424,8 @@ class A2VidPipelineTwoStage:enhance_static_cache=enhance_static_cache,generated_keyframes=generated_keyframes,decode_with_keyframes=decode_with_keyframes,+ chunk_config=chunk_config,)- if chunk_config is None:- chunk_config = ChunkConfig(chunk_pixel_frames=ctx.num_frames, next_video_carry_frames=0)sigmas = (stage_1_sigmas if stage_1_sigmas is not None else self._scheduler.execute(steps=num_inference_steps)@@ -445,7 +456,7 @@ class A2VidPipelineTwoStage:context=VideoAudio(video=ctx.v_context_p, audio=ctx.a_context_p),device=self.device,dtype=ctx.dtype,- config=chunk_config,+ config=ctx.chunk_config,video_scale_factors=self.stage_1.video_scale_factors,audio_latent=ctx.encoded_audio_latent,make_video_conditionings=self._video_conditionings(ctx.images, ctx.num_frames, color_space),diff --git a/packages/ltx-pipelines/src/ltx_pipelines/distilled.py b/packages/ltx-pipelines/src/ltx_pipelines/distilled.pyindex 3ec33f4..b80b0ee 100644--- a/packages/ltx-pipelines/src/ltx_pipelines/distilled.py+++ b/packages/ltx-pipelines/src/ltx_pipelines/distilled.py@@ -153,6 +153,7 @@ class _DistilledRunContext:tiling_config: TilingConfigstage_1_width: intstage_1_height: int+ chunk_config: ChunkConfigclass DistilledPipeline:@@ -254,6 +255,7 @@ class DistilledPipeline:enhance_static_cache: bool,generated_keyframes: int | Sequence[int],decode_with_keyframes: bool,+ chunk_config: ChunkConfig | None = None,) -> _DistilledRunContext:"""Validate inputs, encode prompts, and resolve frame count / tiling before chunk planning."""require_num_frames_source(num_frames, self.duration_predictor)@@ -285,13 +287,20 @@ class DistilledPipeline:))+ if chunk_config is None:+ chunk_config = ChunkConfig(chunk_pixel_frames=resolved_num_frames, next_video_carry_frames=0)+scale_factors = tiling_scale_factors_for_vae(self.video_decoder.checkpoint_path)resolved_tiling_config = ensure_tiling_config(tiling_config,scale_factors=scale_factors,vae_checkpoint_path=self.video_decoder.checkpoint_path,video_shape=VideoPixelShape(- batch=1, frames=resolved_num_frames, height=height, width=width, fps=frame_rate+ batch=1,+ frames=min(resolved_num_frames, chunk_config.chunk_pixel_frames),+ height=height,+ width=width,+ fps=frame_rate,),diffvae_optimization=self.video_decoder.diffvae_optimization,device=self.device,@@ -310,6 +319,7 @@ class DistilledPipeline:tiling_config=resolved_tiling_config,stage_1_width=width // 2,stage_1_height=height // 2,+ chunk_config=chunk_config,)def _sampler_kwargs(self, seed: int, noise_seed_offset: int) -> dict[str, Any]:@@ -435,9 +445,8 @@ class DistilledPipeline:enhance_static_cache=enhance_static_cache,generated_keyframes=generated_keyframes,decode_with_keyframes=decode_with_keyframes,+ chunk_config=chunk_config,)- if chunk_config is None:- chunk_config = ChunkConfig(chunk_pixel_frames=ctx.num_frames, next_video_carry_frames=0)stage_1_sigmas = stage_1_sigmas.to(dtype=torch.float32, device=self.device)stage_2_sigmas = stage_2_sigmas.to(dtype=torch.float32, device=self.device)@@ -454,7 +463,7 @@ class DistilledPipeline:context=VideoAudio(video=ctx.video_context, audio=ctx.audio_context),device=self.device,dtype=ctx.dtype,- config=chunk_config,+ config=ctx.chunk_config,video_scale_factors=self.stage.video_scale_factors,make_video_conditionings=self._video_conditionings(ctx.images, ctx.num_frames, color_space),generated_keyframes=generated_keyframes,diff --git a/packages/ltx-pipelines/src/ltx_pipelines/dubit.py b/packages/ltx-pipelines/src/ltx_pipelines/dubit.pyindex b42609e..0f00d5e 100644--- a/packages/ltx-pipelines/src/ltx_pipelines/dubit.py+++ b/packages/ltx-pipelines/src/ltx_pipelines/dubit.py@@ -105,6 +105,7 @@ class _DubItRunContext:ref_audio_latent: torch.Tensorreference_video_path: strreference_strength: float+ chunk_config: ChunkConfigclass DubItPipeline:@@ -211,6 +212,7 @@ class DubItPipeline:tiling_config: TilingConfig | AutoTiling | None,generated_keyframes: int | Sequence[int] = 0,decode_with_keyframes: bool = False,+ chunk_config: ChunkConfig | None = None,) -> _DubItRunContext:"""Validate inputs, encode prompts/reference, and resolve frame count / tiling before chunk planning."""images = self.image_conditioner.resolve_crf(images)@@ -221,6 +223,9 @@ class DubItPipeline:num_frames = snap_frames_to_grid(meta.frames)frame_rate = float(meta.fps)+ if chunk_config is None:+ chunk_config = ChunkConfig(chunk_pixel_frames=num_frames, next_video_carry_frames=0)+generator = torch.Generator(device=self.device).manual_seed(seed)noiser = GaussianNoiser(generator=generator)resolved_vae_dtype = self.dtype if vae_dtype is None else vae_dtype@@ -238,7 +243,13 @@ class DubItPipeline:tiling_config,scale_factors=scale_factors,vae_checkpoint_path=self.video_decoder.checkpoint_path,- video_shape=VideoPixelShape(batch=1, frames=num_frames, height=height, width=width, fps=frame_rate),+ video_shape=VideoPixelShape(+ batch=1,+ frames=min(num_frames, chunk_config.chunk_pixel_frames),+ height=height,+ width=width,+ fps=frame_rate,+ ),diffvae_optimization=self.video_decoder.diffvae_optimization,device=self.device,keyframes=decode_with_keyframes,@@ -260,6 +271,7 @@ class DubItPipeline:ref_audio_latent=ref_audio_latent,reference_video_path=reference_video_path,reference_strength=reference_strength,+ chunk_config=chunk_config,)def _video_conditionings(@@ -382,9 +394,8 @@ class DubItPipeline:tiling_config=tiling_config,generated_keyframes=generated_keyframes,decode_with_keyframes=decode_with_keyframes,+ chunk_config=chunk_config,)- if chunk_config is None:- chunk_config = ChunkConfig(chunk_pixel_frames=ctx.num_frames, next_video_carry_frames=0)stage_1_sigmas = stage_1_sigmas.to(dtype=torch.float32, device=self.device)stage_2_sigmas = stage_2_sigmas.to(dtype=torch.float32, device=self.device)@@ -412,7 +423,7 @@ class DubItPipeline:context=VideoAudio(video=ctx.video_context, audio=ctx.audio_context),device=self.device,dtype=ctx.dtype,- config=chunk_config,+ config=ctx.chunk_config,video_scale_factors=self.stage.video_scale_factors,make_video_conditionings=make_video,make_audio_conditionings=self._audio_conditionings(latent=ctx.ref_audio_latent, fps=ctx.frame_rate),diff --git a/packages/ltx-pipelines/src/ltx_pipelines/ic_lora.py b/packages/ltx-pipelines/src/ltx_pipelines/ic_lora.pyindex 1b89696..46baa6a 100644--- a/packages/ltx-pipelines/src/ltx_pipelines/ic_lora.py+++ b/packages/ltx-pipelines/src/ltx_pipelines/ic_lora.py@@ -279,6 +279,7 @@ class _ICLoraRunContext:conditioning_attention_mask: torch.Tensor | Nonedecode_with_keyframes: boolcolor_space: EXRColorSpace | None+ chunk_config: ChunkConfigclass ICLoraPipeline:@@ -439,6 +440,7 @@ class ICLoraPipeline:color_space: EXRColorSpace | None,generated_keyframes: int | Sequence[int] = 0,decode_with_keyframes: bool = False,+ chunk_config: ChunkConfig | None = None,) -> _ICLoraRunContext:images = self.image_conditioner.resolve_crf(images)assert_generated_keyframes_request(@@ -464,6 +466,10 @@ class ICLoraPipeline:)resolved_num_frames = snap_frames_to_grid(num_frames)++ if chunk_config is None:+ chunk_config = ChunkConfig(chunk_pixel_frames=resolved_num_frames, next_video_carry_frames=0)+generator = torch.Generator(device=self.device).manual_seed(seed)noiser = GaussianNoiser(generator=generator)resolved_vae_dtype = self.dtype if vae_dtype is None else vae_dtype@@ -483,7 +489,7 @@ class ICLoraPipeline:vae_checkpoint_path=self.video_decoder.checkpoint_path,video_shape=VideoPixelShape(batch=1,- frames=resolved_num_frames,+ frames=min(resolved_num_frames, chunk_config.chunk_pixel_frames),height=height,width=width,fps=frame_rate,@@ -512,6 +518,7 @@ class ICLoraPipeline:conditioning_attention_mask=conditioning_attention_mask,decode_with_keyframes=decode_with_keyframes,color_space=color_space,+ chunk_config=chunk_config,)def _video_conditionings(@@ -711,9 +718,8 @@ class ICLoraPipeline:color_space=color_space,generated_keyframes=generated_keyframes,decode_with_keyframes=decode_with_keyframes,+ chunk_config=chunk_config,)- if chunk_config is None:- chunk_config = ChunkConfig(chunk_pixel_frames=ctx.num_frames, next_video_carry_frames=0)target = VideoPixelShape(batch=1,@@ -737,7 +743,7 @@ class ICLoraPipeline:context=VideoAudio(video=ctx.video_context, audio=ctx.audio_context),device=self.device,dtype=ctx.dtype,- config=chunk_config,+ config=ctx.chunk_config,video_scale_factors=self._diffusion_stage.video_scale_factors,generated_keyframes=generated_keyframes,)diff --git a/packages/ltx-pipelines/src/ltx_pipelines/ti2vid_two_stages.py b/packages/ltx-pipelines/src/ltx_pipelines/ti2vid_two_stages.pyindex afe063e..8238658 100644--- a/packages/ltx-pipelines/src/ltx_pipelines/ti2vid_two_stages.py+++ b/packages/ltx-pipelines/src/ltx_pipelines/ti2vid_two_stages.py@@ -100,6 +100,7 @@ class _TI2VidRunContext:tiling_config: TilingConfigstage_1_width: intstage_1_height: int+ chunk_config: ChunkConfigclass TI2VidTwoStagesPipeline:@@ -217,6 +218,7 @@ class TI2VidTwoStagesPipeline:enhance_static_cache: bool,generated_keyframes: int | Sequence[int],decode_with_keyframes: bool,+ chunk_config: ChunkConfig | None = None,) -> _TI2VidRunContext:"""Validate inputs, encode prompts, and resolve frame count / tiling before chunk planning."""require_num_frames_source(num_frames, self.duration_predictor)@@ -248,13 +250,20 @@ class TI2VidTwoStagesPipeline:))+ if chunk_config is None:+ chunk_config = ChunkConfig(chunk_pixel_frames=resolved_num_frames, next_video_carry_frames=0)+scale_factors = tiling_scale_factors_for_vae(self.video_decoder.checkpoint_path)resolved_tiling_config = ensure_tiling_config(tiling_config,scale_factors=scale_factors,vae_checkpoint_path=self.video_decoder.checkpoint_path,video_shape=VideoPixelShape(- batch=1, frames=resolved_num_frames, height=height, width=width, fps=frame_rate+ batch=1,+ frames=min(resolved_num_frames, chunk_config.chunk_pixel_frames),+ height=height,+ width=width,+ fps=frame_rate,),diffvae_optimization=self.video_decoder.diffvae_optimization,device=self.device,@@ -275,6 +284,7 @@ class TI2VidTwoStagesPipeline:tiling_config=resolved_tiling_config,stage_1_width=width // 2,stage_1_height=height // 2,+ chunk_config=chunk_config,)def _video_conditionings(@@ -396,9 +406,8 @@ class TI2VidTwoStagesPipeline:enhance_static_cache=enhance_static_cache,generated_keyframes=generated_keyframes,decode_with_keyframes=decode_with_keyframes,+ chunk_config=chunk_config,)- if chunk_config is None:- chunk_config = ChunkConfig(chunk_pixel_frames=ctx.num_frames, next_video_carry_frames=0)sigmas = (stage_1_sigmas if stage_1_sigmas is not None else self._scheduler.execute(steps=num_inference_steps)@@ -429,7 +438,7 @@ class TI2VidTwoStagesPipeline:context=VideoAudio(video=ctx.v_context_p, audio=ctx.a_context_p),device=self.device,dtype=ctx.dtype,- config=chunk_config,+ config=ctx.chunk_config,video_scale_factors=self.stage_1.video_scale_factors,make_video_conditionings=self._video_conditionings(ctx.images, ctx.num_frames, color_space),generated_keyframes=generated_keyframes,diff --git a/packages/ltx-pipelines/src/ltx_pipelines/utils/media_io/encode.py b/packages/ltx-pipelines/src/ltx_pipelines/utils/media_io/encode.pyindex ae07fc4..bd70b14 100644--- a/packages/ltx-pipelines/src/ltx_pipelines/utils/media_io/encode.py+++ b/packages/ltx-pipelines/src/ltx_pipelines/utils/media_io/encode.py@@ -30,56 +30,55 @@ logger = logging.getLogger(__name__)def _encode_hdr_video_outputs(- chunks: Iterator[torch.Tensor],+ video: Iterator[torch.Tensor],output_path: Path,fps: float,color_space: EXRColorSpace,*,max_workers: int = 8,audio: Iterator[Audio] | None = None,+ audio_sampling_rate: int | None = None,device: torch.device | None = None,) -> Path:"""Write EXR frames plus a BT.2020/HLG master.- One pass over ``chunks`` feeds two independent sinks:+ One pass over ``video`` feeds two independent sinks:* **HLG** — always Rec.709 scene-linear (``decode_hdr_video`` default).* **EXR** — matches ``color_space``: log codes when :attr:`~EXRColorSpace.is_log_working`,else scene-linear in ``color_space.source_primaries`` (reuse the HLG tensor when thatis already Rec.709).- Chunks are collected first so a stitch iterator can be pulled before HLG- (which takes a single :class:`~ltx_core.types.Audio`). EXR and HLG then share- that list.+ Video tensors flow directly from decode through both sinks. When ``audio`` is+ deferred, HLG opens its AAC stream from ``audio_sampling_rate`` and pulls+ the completed track only after this iterator is exhausted.Args:- chunks: Per-chunk VAE decode output, each ``[F, H, W, C]`` float in ``[0, 1]``- (the compressed working-space signal).+ video: VAE decode output as an iterator of ``[F, H, W, C]`` float tensors in+ ``[0, 1]`` (the compressed working-space signal), e.g. from+ :func:`~ltx_pipelines.chunks.split_decoded_chunks`.output_path: Destination of the HLG master. EXR frames go to``<stem>_<label>_exr/`` where ``label`` is :func:`~ltx_pipelines.utils.media_io.exr.exr_dir_label`.fps: Output frame rate.color_space: HDR colour space for EXR tags / linear EXR primaries.max_workers: Number of EXR writer threads.- audio: Optional stereo track muxed into the HLG master. Drain of ``chunks``- fills a lazy stitch iterator; pull it before HLG.+ audio: Optional stereo track muxed into the HLG master. It may be filled+ lazily while ``video`` is consumed.+ audio_sampling_rate: AAC sample rate, required when ``audio`` is set.device: Device for the HLG colour conversion. Defaults to CUDA when available.Returns:The directory the EXR frames were written to.Raises:- ValueError: If ``chunks`` yields nothing.+ ValueError: If ``video`` yields nothing."""exr_dir = output_path.parent / f"{output_path.stem}_{exr_dir_label(color_space)}_exr"exr_dir.mkdir(parents=True, exist_ok=True)exr_primaries = color_space.source_primariesexr_color_space = exr_colorspace_tag(color_space)frames_written = 0- chunk_list = list(chunks)- mux_audio = next(audio, None) if audio is not None else None- if mux_audio is not None:- validate_audio_waveform(mux_audio)def hlg_chunks() -> Iterator[torch.Tensor]:"""Write EXR for each chunk, then yield Rec.709 linear for the HLG encoder."""nonlocal frames_writtenwith ThreadPoolExecutor(max_workers=max_workers) as executor:pending: deque[Future[None]] = deque()- for chunk in chunk_list:+ for chunk in video:# HLG sink: always Rec.709 scene-linear.hlg_linear = decode_hdr_video(chunk)@@ -108,17 +107,18 @@ def _encode_hdr_video_outputs(logger.info("Encoding BT.2020/HLG/10-bit master%s: %s",- " (with audio)" if mux_audio is not None else "",+ " (with audio)" if audio is not None else "",output_path,)- # Empty ``chunks`` raises inside the HLG encoder (after EXR side effects are none).+ # Empty ``video`` raises inside the HLG encoder (after EXR side effects are none).encode_linear_hdr_frames_to_hlg_mp4(hlg_chunks(),output_path,fps=fps,primaries=Primaries.REC709,- audio=mux_audio,+ audio=audio,device=device,+ audio_sampling_rate=audio_sampling_rate,)logger.info("Wrote %d EXR frames (%s/%s) to %s",@@ -248,9 +248,8 @@ def encode_video( # noqa: PLR0913or None for a video-only file. Pass:func:`~ltx_pipelines.chunks.deferred_stitch_audio` when parts are collectedwhile ``video`` is consumed, and set ``audio_sampling_rate`` so AAC can open- before any video packets (SDR). HDR drains ``video`` first, then pulls that- iterator and passes one :class:`~ltx_core.types.Audio` to HLG. Waveforms must- be stereo ``(2, N)`` or ``(N, 2)``.+ before any video packets. Both SDR and HDR pull the iterator only after+ draining ``video``. Waveforms must be stereo ``(2, N)`` or ``(N, 2)``.output_path: Destination path. Parent directories are created if missing.Partial SDR output is removed if encoding fails. HDR writes EXR under``<stem>_<label>_exr/`` (see :func:`~ltx_pipelines.utils.media_io.exr.exr_dir_label`) and an@@ -263,7 +262,7 @@ def encode_video( # noqa: PLR0913color_space: HDR colour space for the encode sink. ``None`` (default) is SDR.When set, writes half EXR frames + HLG master.audio_sampling_rate: AAC sample rate. Inferred when ``audio`` is an- :class:`~ltx_core.types.Audio`; required for an audio iterator on the SDR path.+ :class:`~ltx_core.types.Audio`; required for an audio iterator.Returns:EXR output directory when HDR, else ``None``.Raises:@@ -271,6 +270,7 @@ def encode_video( # noqa: PLR0913explicit and embedded audio sampling rates."""if isinstance(audio, Audio):+ validate_audio_waveform(audio)if audio_sampling_rate is not None and audio_sampling_rate != audio.sampling_rate:raise ValueError(f"audio_sampling_rate {audio_sampling_rate} does not match audio sampling rate {audio.sampling_rate}"@@ -288,6 +288,7 @@ def encode_video( # noqa: PLR0913fps=float(fps),color_space=color_space,audio=audio,+ audio_sampling_rate=audio_sampling_rate,)encode_sdr_h264(diff --git a/packages/ltx-trainer/pyproject.toml b/packages/ltx-trainer/pyproject.tomlindex 8294196..6a79f61 100644--- a/packages/ltx-trainer/pyproject.toml+++ b/packages/ltx-trainer/pyproject.toml@@ -1,6 +1,6 @@[project]name = "ltx-trainer"-version = "1.4.0"+version = "1.4.1"description = "LTX-2 training, democratized."readme = "README.md"authors = [