Skip to content
theStxvePublic

About

python skript for making loops from videos as clean as possible

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

AutoLoop

Automated High-Precision Video Seamless Loop Generator

AutoLoop analyzes video footage to detect exact or optimal matching frame pairs, ensuring continuous, stutter-free seamless video loops. The matching engine evaluates structural similarity (SSIM), color distribution, localized block deviations, and motion flow continuity.


Features

  • Multi-Metric Frame Matching:
    • Full-resolution Structural Similarity (SSIM) analysis.
    • Local Patch & Worst-Block Error Analysis (detects transient entities, hand motions, HUD fluctuations).
    • Pixel-Level Outlier Thresholding with exponential penalty curves.
    • Motion Flow Continuity Matching (aligns velocity vectors across transitions).
  • Configurable Constraints:
    • Minimum loop distance in seconds (min_distance).
    • Optional maximum duration limit.
    • Adjustable motion flow weighting.
  • Hardware-Friendly Processing:
    • Fast vectorized coarse matrix search via SIMD/BLAS.
    • Forward-ordered high-resolution frame caching (eliminates random seek overhead).
  • Interactive GUI (German UI):
    • Simple 3-step workflow: find loops → pick a loop → export.
    • Drag-and-drop file ingestion.
    • Buffered live loop player with "check transition" button that jumps right before the seam.
    • Side-by-side frame comparison and enhanced difference heatmap (|A - B|).
    • Ranked candidate matches with quality rating, duration and time range.
    • Analysis and export run in the background and can be cancelled at any time.
    • Settings are remembered between sessions.
  • Flexible Export:
    • Frame-exact: frames are decoded with the same indexing the analyzer uses.
    • MP4 (H.264 / H.265 with quality presets).
    • Lossless H.264.
    • Apple ProRes 422 HQ.
    • WebM (VP9).
    • High-quality palette GIF (max. 800 px wide).
    • Optional seam crossfade (0 to 30 frames) and optional audio track.
    • Automatic OpenCV fallback (MP4) when FFmpeg is not installed.

Keyboard Shortcuts

Key Action
Ctrl+O Open video
Ctrl+Enter / F5 Find loops
Esc Cancel analysis / export
Space Play / pause preview
N Jump right before the loop seam
Ctrl+E / double-click Export selected loop

Quick Start

Installation

Clone the repository and install the dependencies:

git clone https://github.com/theStxve/autoLoop.git
cd autoLoop
pip install -r requirements.txt

GUI Mode

Launch the graphical user interface:

python autoloop.py

On Windows, you can also double-click:

run_autoloop.bat

CLI Mode

Run headlessly via command line:

python autoloop.py "input_video.mp4" --min-gap 2.5 --output "loop_output.mp4" --cli

CLI Reference

usage: autoloop.py [-h] [--min-gap MIN_GAP] [--max-gap MAX_GAP]
                   [--output OUTPUT] [--top TOP]
                   [--format {mp4_h264,mp4_h265,lossless,prores,webm,gif}]
                   [--crf CRF] [--motion-weight MOTION_WEIGHT]
                   [--resolution {64,128,256}] [--crossfade CROSSFADE]
                   [--audio] [--cli]
                   [input]

Options

Parameter Short Default Description
input - None Path to the input video file.
--min-gap -m 2.0 Minimum loop duration in seconds.
--max-gap -M None Maximum loop duration in seconds.
--output -o Auto Output video path.
--top -k 10 Number of best candidate pairs to return.
--format -f mp4_h264 Export format (mp4_h264, mp4_h265, lossless, prores, webm, gif).
--crf -q 17 Encoding quality constant rate factor (lower = higher quality).
--motion-weight -w 0.35 Motion velocity continuity weighting (0.0 to 1.0).
--resolution -r 128 Thumbnail search resolution (64, 128, 256).
--crossfade -x 0 Crossfade frames at the loop seam (0 = hard cut).
--audio - - Include the audio track in the exported loop.
--cli - - Run strictly in CLI mode without opening the GUI.

FFmpeg is recommended (e.g. winget install ffmpeg). Without it, only MP4 (mp4v, no audio) can be exported.


Verification & Testing

Execute the automated test suite against synthetic cyclic media:

python test_autoloop.py

Architecture Overview

autoLoop/
├── core/
│   ├── analyzer.py          # Frame extraction, matrix scoring, SSIM refinement
│   └── video_processor.py   # Demuxer-level trimming, crossfade, and export engine
├── gui/
│   ├── main_window.py       # PyQt6 dark-themed interface
│   └── player_widget.py     # Real-time looping player & difference heatmap
├── autoloop.py              # Application entrypoint (GUI / CLI)
├── test_autoloop.py         # Automated verification tests
├── requirements.txt         # Package dependencies
├── run_autoloop.bat         # Windows one-click launcher
├── LICENSE                  # MIT License
└── README.md                # Project documentation

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

python skript for making loops from videos as clean as possible

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Contributors

Languages