Skip to content

Repository files navigation

ffmpeg-batcher

A lightweight, queue-based automation framework for batch-converting videos and images using FFmpeg.

It is designed to handle heavy media conversion tasks sequentially, preventing system overload while maintaining a clean, tracked workflow.


Features

  • Queue-Based Workflow: Process heavy video/image conversions one by one without overloading your system.
  • Ready-to-Use Presets: Includes handy presets for AV1 (libaom, libsvtav1), WebP, Opus, and custom video trimming.
  • Robust Processing (run.sh): * Automatically adjusts process priority (renice) to keep your OS responsive during intense CPU encodes.
    • Saves temporary outputs to a work-in-progress (wip) directory, moving them to fin only upon successful completion.
    • Safely removes completed queue items in real-time.
    • Logs the entire process to log.txt with timestamps.

Project Structure

.
├── original/               # Place your raw, unconverted files here
├── queue/                  # Symlinks to original files, representing the active queue
├── wip/                    # Temporary directory for files currently being processed
├── fin/                    # Final directory where successfully converted files are stored
├── select.sh               # Selects the active FFmpeg preset script
├── gen_queue.sh            # Generates symlinks from original/ to queue/
├── run.sh                  # The main batch-processing engine
├── print_info.sh           # Helper script to output video frame counts
├── video_*.sh / image_*.sh # Pre-configured FFmpeg scripts
└── log.txt                 # Main execution logs


Prerequisites

Ensure you have ffmpeg, ffprobe, and bash installed on your system.

  • Arch Linux: sudo pacman -S ffmpeg bash
  • Debian/Ubuntu: sudo apt install ffmpeg bash
  • macOS (via Homebrew): brew install ffmpeg

Quick Start

Here is a quick guide on how to batch-convert multiple images to the modern .webp format:

1. Set Up Your Files

Create the original directory if it doesn't exist, and drop your input files inside:

mkdir -p original
# Put your source files (e.g., .png, .jpg) inside original/

2. Select a Preset

Run select.sh with your desired preset script. This creates a symlink named function pointing to the active preset:

./select.sh image_libwebp.sh

3. Generate the Queue

Generate symlinks from your original/ folder to the queue/ folder to build the pipeline:

./gen_queue.sh

4. Run the Batch Process

Start the conversion engine:

./run.sh

Note: The script may prompt you for your sudo password to lower its CPU priority (renice). This ensures your computer remains perfectly usable while FFmpeg runs in the background.


How It Works Under the Hood

The conversion pipeline operates in a safe, step-by-step cycle:

[original/] ---> (gen_queue.sh) ---> [queue/] ---> (run.sh + preset) ---> [wip/] ---> [fin/]

  1. Queue Generation (gen_queue.sh): Instead of copying heavy media files and wasting disk space, it creates symbolic links inside queue/ pointing back to your original/ files.
  2. Preset Selection (select.sh): It symlinks your chosen conversion script to a file named function. This allows run.sh to trigger the active script dynamically using ./function without hardcoding the format.
  3. Process Optimization (run.sh): When you start run.sh, it uses sudo renice to assign a lower priority value to the current process. This is incredibly helpful for long, resource-heavy encodes (like AV1), keeping your UI snappy.
  4. Safe Processing Cycle: For every file in the queue:
  • run.sh logs the metadata using ./print_info.sh.
  • The preset is executed, and the intermediate file is written to wip/.
  • Upon successful completion (exit status 0), the original queue link is safely deleted, and the finalized file is moved to fin/.
  • If a crash or interruption occurs, your files remain safely in wip/ or queue/ so you never lose progress.

License

This project is licensed under the GPL-3.0 License. See the LICENSE file for details.

About

A queue-based automation script for batch converting videos and images using FFmpeg.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages