# Development Roadmap This document outlines the planned development steps for the VidEnc application. ## Phase 1: Code Refactoring The first priority is to refactor the existing codebase to improve its structure, maintainability, and readability. This will provide a solid foundation for future feature development. ### Detailed Plan for Phase 1 This phase will be broken down into the following steps: 1. **Centralize Encoding Settings:** * **Create `EncodingSettings` Model:** In a new file, `src/models/settings.py`, create a new Pydantic model named `EncodingSettings`. * **Define Fields:** This model will have the following fields, corresponding to the Typer options in `app.py`: * `preset: int` * `crf: int` * `original_media_type: OriginalMediaType` * `film_grain: int` * **Integrate into `app.py`:** * In the `main` function, create an instance of `EncodingSettings` by passing the values from the Typer options. * The `apply_stream_settings` function will be updated to accept this `EncodingSettings` object instead of individual parameters, simplifying its signature. 2. **Refactor IMDb Search:** * Create a Pydantic model, `IMDbSearchResult`, to represent a single search result (e.g., with `title`, `year`, `imdb_id`). * Modify the `search_imdb` function in `src/lib/movie_details.py` to no longer print to the console. Instead, it will return a list of `IMDbSearchResult` objects. * The interactive selection logic will be handled separately in `app.py` after calling the refactored `search_imdb`. 3. **[x] Implement Template-Based Command Generation:** The `ffmpeg` command is now generated using a Jinja2 template, separating the command logic from the Python code. ## Phase 2: Logging Implement comprehensive logging using the `loguru` library. This will help with debugging and tracking the application's behavior during encoding jobs. ## Phase 3: Configuration File Introduce a configuration file managed by the `pydantic-settings` package. This will allow loading settings from a file (e.g., `.env` or `config.toml`) and environment variables, making the application more flexible and easier to configure for different users. ## Phase 4: Enhanced Error Handling Improve error handling throughout the application, especially for external interactions. This will make the application more robust and provide clearer feedback to the user when things go wrong. Key areas include: - API interactions (e.g., invalid API keys, network errors, movies not found). - `ffprobe` and `ffmpeg` command execution failures. - File system operations (e.g., permission errors). ## Phase 5: Encoding Profiles Introduce encoding profiles (e.g., `dvd`, `bluray`, `tvrip`) to simplify the user experience. These profiles will map to pre-defined sets of encoding parameters (`preset`, `crf`, `film_grain`, etc.), allowing users to choose a quality target without needing to know the underlying `ffmpeg` settings. ## Phase 6: Batch Processing Implement a stateful batch processing system. This will involve creating a set of commands to manage an internal encoding queue: - A command to process a video and add its generated `ffmpeg` command to the queue. - A command to write all queued commands into a single, consolidated shell script. - Commands to view and clear the queue. This provides a more flexible and robust workflow for batch encoding. ## Future Goals ### Advanced Subtitle Handling Implement a sophisticated subtitle processing pipeline to automatically convert bitmap-based subtitles (DVD VobSub, Blu-ray PGS) into the text-based SubRip (.srt) format. This is a significant research and development task that will be tackled after the initial roadmap is complete. It involves: - Automating the OCR process for `dvd_sub` streams using tools like `mkvextract` and `vobsub2srt`. - Researching and implementing a solution for the more complex `pgs` subtitle format, potentially using an OCR engine like Tesseract via a command-line tool. ### Direct Execution Add an option to execute the generated `ffmpeg` command directly from the application. This will require research into the best way to run and monitor long-running subprocesses in Python, providing real-time feedback and progress to the user. ### GUI Development Develop a graphical user interface (GUI) to make the application more accessible and user-friendly for a broader audience. This will be a significant undertaking and will be considered after the core CLI functionality is mature and stable. Research into the best GUI framework (e.g., Dear PyGui, CustomTkinter, PySide6) will be the first step. ### Deinterlacing A `bwdif` deinterlacing filter is currently hardcoded in the video processing pipeline as a temporary solution. **To-Do:** - Implement detection for interlaced video streams (e.g., by checking the `field_order` property from `ffprobe` output). - Apply the deinterlacing filter conditionally, only when interlaced content is detected, to avoid unnecessary processing on progressive sources. --- *This roadmap will be updated as development progresses.*