EN / RU README
EN: Two-stage pipeline: (1) split videos into scenes with TransNetV2 + FFmpeg (NVENC), (2) outpaint scenes with WAN 2.1 VACE (FusionX) via Diffusers. RU: Двухэтапный конвейер: (1) разбиение видео на сцены TransNetV2 + FFmpeg (NVENC), (2) дорисовка сцен WAN 2.1 VACE (FusionX) через Diffusers.
1__sceneSeparator.py — EN: scene detection + export per-scene MP4 (NVENC, 720p). RU: детект сцен + экспорт отдельных MP4 (NVENC, 720p).2__Outpaint.py — EN: reads scenes, builds masks, BLIP2 captions, runs WAN outpaint, writes video. RU: читает сцены, строит маски, генерирует подписи BLIP2, запускает WAN outpaint, пишет видео.repo/
├─ 1__sceneSeparator.py
├─ 2__Outpaint.py
└─ README.md (this file / этот файл)
Hardware / Железо
Software / Софт
h264_nvenc)Python packages / Пакеты Python
pip install --upgrade pip
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu121
pip install opencv-python pillow numpy tqdm accelerate transformers diffusers huggingface_hub
pip install transnetv2pt
Windows + FFmpeg: verify
ffmpeg -hide_banner -encoders | findstr nvencshowsh264_nvenc. Windows + FFmpeg: проверьте, чтоffmpeg -hide_banner -encoders | findstr nvencпоказываетh264_nvenc.
Put source videos into D:/Experiments/1__original (*.mkv).
Сложите исходные видео в D:/Experiments/1__original (*.mkv).
Split scenes:
python 1__sceneSeparator.py
Outputs to D:/Experiments/2__scenes_all/ as video-{series}-{scene}.mp4.
python 2__Outpaint.py
Reads scenes from 2__scenes_all, writes outpainted videos to D:/Experiments/Video_Outpaint/3__outpaint.
1__sceneSeparator.py)-ss and -t. Output is H.264 NVENC, scaled to 720p height, format yuv420p.-ss и -t. Выход — H.264 NVENC, масштаб до 720p по высоте, формат yuv420p.Note / Важно: with
scale+yuv420pvideo is not truly lossless despite-tune lossless. Приscale+yuv420pвидео не полностью без потерь, несмотря на-tune lossless.
2__Outpaint.py)0=keep, 255=fill. Optional BLIP2 captions merge with your base PROMPT. WAN VACE runs in overlapping batches (BATCH_SIZE) to keep temporal context.0=оставить, 255=дорисовать. Опциональные подписи BLIP2 объединяются с базовым PROMPT. WAN VACE работает батчами с перекрытием (BATCH_SIZE) для сохранения контекста.In 1__sceneSeparator.py
FFMPEG_OUT_OPTS:
-vf "scale=-2:720,format=yuv420p" — EN: keep width multiple of 2, 720p height. RU: ширина кратна 2, высота 720p.-c:v h264_nvenc -preset p7 -tune lossless — EN: slow/high quality; not truly lossless due to scale/4:2:0. RU: медленно/качественно; не полностью без потерь из-за масштаба/4:2:0.In 2__Outpaint.py
Resolution / Разрешение: TARGET_WIDTH, TARGET_HEIGHT, SCALE_FACTOR (internal up/down, resampled back).
Diffusion params / Параметры диффузии:
NUM_INFERENCE_STEPS (e.g., 9..32) — speed/quality trade-off.GUIDANCE_SCALE (e.g., 4–6) — prompt adherence vs flicker.FLOW_SHIFT (e.g., 4–6) — sampler’s denoise flow tweak.Batching: BATCH_SIZE (e.g., 5). Larger batch = more VRAM, fewer calls.
Mask feather / Растушёвка маски: GRADIENT_WIDTH (e.g., 25 px).
Prompts: PROMPT, NEGATIVE_PROMPT. BLIP2 adds captions per chunk.
2__Outpaint.py calls download_models() to prefetch:
Cache / Кэш: uses Hugging Face cache. Enable fast transport automatically. Кэш: использует кэш HF. Быстрая загрузка включается автоматически.
Fast profile idea / Быстрый профиль (идея):
enable_model_cpu_offload()), prefer fp16 VAE, smaller steps (e.g., 28–32 for higher quality, ≤16 for speed), moderate guidance (4.5–5.5).Safe profile / Безопасный профиль:
Quantization / Квантизация:
Attention backend / Бэкенд внимания:
sage is stable for masks; if running without masks, sdpa can be faster (toggle before calling).Windows env tweak / Настройка окружения:
set PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True to reduce VRAM fragmentation.The provided script currently uses
enable_model_cpu_offload()for VAE to save VRAM. You can comment it out for speed if memory allows. Скрипт сейчас включаетenable_model_cpu_offload()для экономии VRAM. Для скорости можно отключить, если памяти хватает.
1__sceneSeparator.py takes the 4th underscore-separated token; otherwise uses filename stem.-accurate_seek) or pre-conversion.-tune lossless.0 = keep, 255 = outpaint.h264_nvenc not found: install FFmpeg with NVENC; update NVIDIA driver.
h264_nvenc не найден: поставьте FFmpeg с NVENC; обновите драйвер NVIDIA.BATCH_SIZE, reduce TARGET_*, switch GGUF to Q5_K/Q4_K, enable CPU offload.
Недостаточно VRAM: уменьшите BATCH_SIZE, TARGET_*, снижайте квант, включайте оффлоад.GUIDANCE_SCALE, keep FLOW_SHIFT moderate, ensure consistent prompts.
Мерцание: снизьте GUIDANCE_SCALE, держите FLOW_SHIFT умеренным, стабилизируйте промпты.INPUT_DIR, OUTPUT_DIR in both scripts as needed.PROMPT and skipping generate_prompts_with_blip.pipe.transformer.set_attention_backend("sage" | "sdpa") per use-case.FFMPEG_OUT_OPTS (e.g., HEVC hevc_nvenc, different scale, CRF-based SDR, etc.).*.mkv to D:/Experiments/1__originalpython 1__sceneSeparator.py → scenes in 2__scenes_allpython 2__Outpaint.py → outpainted in 3__outpaintNUM_INFERENCE_STEPS, GUIDANCE_SCALE, FLOW_SHIFT, BATCH_SIZE as neededЕсли нужно — сделаю отдельные EN-only и RU-only варианты README или добавлю раздел «Advanced tuning» с готовыми профилями под вашу видеокарту.
6 commits
Python
100.0%
EN / RU README
EN: Two-stage pipeline: (1) split videos into scenes with TransNetV2 + FFmpeg (NVENC), (2) outpaint scenes with WAN 2.1 VACE (FusionX) via Diffusers. RU: Двухэтапный конвейер: (1) разбиение видео на сцены TransNetV2 + FFmpeg (NVENC), (2) дорисовка сцен WAN 2.1 VACE (FusionX) через Diffusers.
1__sceneSeparator.py — EN: scene detection + export per-scene MP4 (NVENC, 720p). RU: детект сцен + экспорт отдельных MP4 (NVENC, 720p).2__Outpaint.py — EN: reads scenes, builds masks, BLIP2 captions, runs WAN outpaint, writes video. RU: читает сцены, строит маски, генерирует подписи BLIP2, запускает WAN outpaint, пишет видео.repo/
├─ 1__sceneSeparator.py
├─ 2__Outpaint.py
└─ README.md (this file / этот файл)
Hardware / Железо
Software / Софт
h264_nvenc)Python packages / Пакеты Python
pip install --upgrade pip
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu121
pip install opencv-python pillow numpy tqdm accelerate transformers diffusers huggingface_hub
pip install transnetv2pt
Windows + FFmpeg: verify
ffmpeg -hide_banner -encoders | findstr nvencshowsh264_nvenc. Windows + FFmpeg: проверьте, чтоffmpeg -hide_banner -encoders | findstr nvencпоказываетh264_nvenc.
Put source videos into D:/Experiments/1__original (*.mkv).
Сложите исходные видео в D:/Experiments/1__original (*.mkv).
Split scenes:
python 1__sceneSeparator.py
Outputs to D:/Experiments/2__scenes_all/ as video-{series}-{scene}.mp4.
python 2__Outpaint.py
Reads scenes from 2__scenes_all, writes outpainted videos to D:/Experiments/Video_Outpaint/3__outpaint.
1__sceneSeparator.py)-ss and -t. Output is H.264 NVENC, scaled to 720p height, format yuv420p.-ss и -t. Выход — H.264 NVENC, масштаб до 720p по высоте, формат yuv420p.Note / Важно: with
scale+yuv420pvideo is not truly lossless despite-tune lossless. Приscale+yuv420pвидео не полностью без потерь, несмотря на-tune lossless.
2__Outpaint.py)0=keep, 255=fill. Optional BLIP2 captions merge with your base PROMPT. WAN VACE runs in overlapping batches (BATCH_SIZE) to keep temporal context.0=оставить, 255=дорисовать. Опциональные подписи BLIP2 объединяются с базовым PROMPT. WAN VACE работает батчами с перекрытием (BATCH_SIZE) для сохранения контекста.In 1__sceneSeparator.py
FFMPEG_OUT_OPTS:
-vf "scale=-2:720,format=yuv420p" — EN: keep width multiple of 2, 720p height. RU: ширина кратна 2, высота 720p.-c:v h264_nvenc -preset p7 -tune lossless — EN: slow/high quality; not truly lossless due to scale/4:2:0. RU: медленно/качественно; не полностью без потерь из-за масштаба/4:2:0.In 2__Outpaint.py
Resolution / Разрешение: TARGET_WIDTH, TARGET_HEIGHT, SCALE_FACTOR (internal up/down, resampled back).
Diffusion params / Параметры диффузии:
NUM_INFERENCE_STEPS (e.g., 9..32) — speed/quality trade-off.GUIDANCE_SCALE (e.g., 4–6) — prompt adherence vs flicker.FLOW_SHIFT (e.g., 4–6) — sampler’s denoise flow tweak.Batching: BATCH_SIZE (e.g., 5). Larger batch = more VRAM, fewer calls.
Mask feather / Растушёвка маски: GRADIENT_WIDTH (e.g., 25 px).
Prompts: PROMPT, NEGATIVE_PROMPT. BLIP2 adds captions per chunk.
2__Outpaint.py calls download_models() to prefetch:
Cache / Кэш: uses Hugging Face cache. Enable fast transport automatically. Кэш: использует кэш HF. Быстрая загрузка включается автоматически.
Fast profile idea / Быстрый профиль (идея):
enable_model_cpu_offload()), prefer fp16 VAE, smaller steps (e.g., 28–32 for higher quality, ≤16 for speed), moderate guidance (4.5–5.5).Safe profile / Безопасный профиль:
Quantization / Квантизация:
Attention backend / Бэкенд внимания:
sage is stable for masks; if running without masks, sdpa can be faster (toggle before calling).Windows env tweak / Настройка окружения:
set PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True to reduce VRAM fragmentation.The provided script currently uses
enable_model_cpu_offload()for VAE to save VRAM. You can comment it out for speed if memory allows. Скрипт сейчас включаетenable_model_cpu_offload()для экономии VRAM. Для скорости можно отключить, если памяти хватает.
1__sceneSeparator.py takes the 4th underscore-separated token; otherwise uses filename stem.-accurate_seek) or pre-conversion.-tune lossless.0 = keep, 255 = outpaint.h264_nvenc not found: install FFmpeg with NVENC; update NVIDIA driver.
h264_nvenc не найден: поставьте FFmpeg с NVENC; обновите драйвер NVIDIA.BATCH_SIZE, reduce TARGET_*, switch GGUF to Q5_K/Q4_K, enable CPU offload.
Недостаточно VRAM: уменьшите BATCH_SIZE, TARGET_*, снижайте квант, включайте оффлоад.GUIDANCE_SCALE, keep FLOW_SHIFT moderate, ensure consistent prompts.
Мерцание: снизьте GUIDANCE_SCALE, держите FLOW_SHIFT умеренным, стабилизируйте промпты.INPUT_DIR, OUTPUT_DIR in both scripts as needed.PROMPT and skipping generate_prompts_with_blip.pipe.transformer.set_attention_backend("sage" | "sdpa") per use-case.FFMPEG_OUT_OPTS (e.g., HEVC hevc_nvenc, different scale, CRF-based SDR, etc.).*.mkv to D:/Experiments/1__originalpython 1__sceneSeparator.py → scenes in 2__scenes_allpython 2__Outpaint.py → outpainted in 3__outpaintNUM_INFERENCE_STEPS, GUIDANCE_SCALE, FLOW_SHIFT, BATCH_SIZE as neededЕсли нужно — сделаю отдельные EN-only и RU-only варианты README или добавлю раздел «Advanced tuning» с готовыми профилями под вашу видеокарту.
6 commits
Python
100.0%