Root--main.py(Frontend Component)
-
Function Overview: The
main
component is designed to organize the primary graphical user interface's (GUI's) window class (MainWindow). -
Function Details
-
Application Initialization: Establishes window dimensions, navigational bar width, and window title.
-
Module Inclusion: Incorporates essential PySide6 library components and other custom modules, including log configuration and interfaces for various functions (e.g., video transcoding, automatic editing, settings interface).
-
Log Configuration: Routes log information to both log file and console via distinct handlers.
-
Window Class (MainWindow): Inherits from
FluentWindow
, overseeing the initialization of window status, UI components, navigation items, and application settings, while invoking individual sub-interface modules for integration. -
Interface Structure: Organizes the left-side navigation menu through the
init_navigation
method, dividing the interface into primary functional areas and footer tools. -
Application Configuration Initialization: Prior to instantiation,
init_ffpath
andinit_autopath
are invoked to customize or initialize FFmpeg paths and other application configurations. -
Application Launch: Upon execution, creates a QApplication instance, constructs an instance of
MainWindow
, displays the main window, and enters the event loop.
-
-
Key Technology Stack
-
PySide6 (GUI Library)
-
qFluentWidgets (Styling Component Library)
-
Modules--Ui_xxInterface.py (Frontend Component)
-
Function Overview: The
Ui_xxInterface
module configures a widget-based graphical user interface (GUI) window, specifically designed for managing various settings in video processing. It includes components such as buttons, text inputs, lists, checkboxes, supporting actions like adding/removing files, selecting output folders, and adjusting video encoding parameters. -
Function Description:
- Title Bar: Displays the interface title.
- Display Area: Provides information about filter processing.
- Buttons: Includes controls for initiating video processing, stopping, unlocking, or closing the interface.
- File Operation Section: Facilitates adding files, clearing lists, choosing output directories, and displaying selected files in a list.
- Encoding Settings: Features text boxes for custom encoding configurations, examples of preconfigured video encoding command-line parameters, and input fields for custom filters.
- UI Layout: Utilizes vertical (
QVBoxLayout
) and horizontal (QHBoxLayout
) layout managers to arrange elements, with aScrollArea
wrapping the main content to accommodate window resizing, especially for smaller screens.
Modules--xxInterface.py (Frontend-Backend Binding Component)
-
Function Overview:
xxInterface.py
binds the PySide6 frontend with Python backend logic, enabling user interactions to configure parameters and execute video editing tasks using backend APIs. -
Function Description:
-
Worker Class (inherits from QObject): Defines a unit for executing background tasks (video processing). Utilizes signals and slots to communicate task status changes (start, completion, interruption) to the UI thread. Coordinates with instances created by backend API libraries and can pause or terminate video processing upon receiving an interrupt signal.
-
WorkerThread Class (inherits from QThread): Manages the execution environment for Worker objects, preventing program freeze due to thread blocking. Ensures safe thread exit when the Worker is interrupted.
-
xxInterface Class (inherits from QWidget and Ui_xxInterface): Implements UI logic, including:
-
- Initializing the interface and connecting event handlers.
- Defining and handling changes to video processing parameters (codec selection, video clip timing adjustments, etc.).
- Implementing file operation interfaces (opening files, clearing lists).
- Providing controls to start, terminate video processing tasks with corresponding response logic.
- Managing UI control states in response to task progress (locking/unlocking interface elements).
-
-
Key Functions:
- Enables users to customize detailed video processing parameters via the GUI, such as video codec, bitrate, audio settings, and video cropping/speed adjustments. Dynamically constructs edit commands based on user selections and executes them through command-line utilities, allowing users to start or terminate background video processing tasks.
Modules--logger_config.py(Backend Component)
-
Function Description: This module is dedicated to configuring the logging system. It employs the
logging
module from Python's standard library to establish logging behavior, encompassing log levels, output destinations, and formatting styles. -
Core Logic:
-
Logger Initialization: Acquires a logger, setting its default log level to DEBUG, thereby capturing all log information ranging from DEBUG to CRITICAL.
-
Directory Check & Creation: Verifies if the 'log' directory exists; if not, it creates this directory using
os.mkdir('log')
to house log files. -
File Handler Configuration:
- Installs a
RotatingFileHandler
instance, directing logs to 'log/log.txt'. - Configures the handler to rotate files once they reach 5MB (
maxBytes=1024 * 1024 * 5
), maintaining up to 5 backup files (backupCount=5
). - Adopts a log format that includes timestamp, module name, log level, and message content.
- Installs a
-
Console Handler Configuration:
- Incorporates a
StreamHandler()
for logging output to the console. - Sets the console log level to INFO, with a simplified format showing only the log level and message.
- Incorporates a
-
Attaching Handlers: Adds both the file and console handlers to the logger, ensuring log entries are recorded in both file and console.
-
Log Output Test: Executes a DEBUG-level log entry containing only a newline character to verify the configuration's effectiveness.
-
Modules--config.py(Backend Component)
-
Function Description: The
config.py
module oversees functionalities related to configurations, particularly dealing with paths for FFmpeg tools (ffmpeg.exe
,ffprobe.exe
) and the Auto-Editor application. -
Function Details:
-
Library Imports:
- Imports
os
,configparser
for file operations and parsing configuration files, along with a custom logging modulelogger
.
- Imports
-
Initialization Functions:
-
init_ffpath
: If FFmpeg paths are not set in the configuration file, it assigns default paths and writes them back to the configuration. -
init_autopath
: Similarly, initializes Auto-Editor path settings.
-
-
Class Definitions:
-
ffpath
Class: Offers methods for manipulating FFmpeg paths, including reading paths during initialization and manual resetting. -
autopath
Class: Mirrorsffpath
, tailored for managing Auto-Editor paths.
-
-
Configuration Modification Functions:
-
set_config
: Enables users to customize FFmpeg settings, includingffmpeg_path
andffprobe_path
. -
set_auto_path
: Allows users to specify the executable path for Auto-Editor (auto_path
).
-
-
Modules--ffmpegApi.py(Backend Component)
-
Function Description: The
ffmpegApi.py
module is a Python component designed to interface with the FFmpeg command-line tool, facilitating a variety of video processing tasks, including video trimming, concatenation, transcoding, audio extraction, and more. -
Functionality Overview:
-
Class
FFmpeg
: Offers an object-oriented interface to invoke various functionalities of FFmpeg.-
Initializer Method
__init__
: Configures the paths for FFmpeg and FFprobe, establishes mechanisms for interrupt control, and defines callback functions. -
Method
run
: Executes FFmpeg commands using thesubprocess
library, monitoring real-time command output while enabling interruption with callback handling logic. -
Methods
update_interrupt_flag
,check_interrupt_flag
,interrupt_run
: Formulate an interruption management system, empowering external entities to halt ongoing FFmpeg processes at any time. -
Exception Handling: Utilizes try-except blocks to ensure graceful feedback in exceptional scenarios, such as logging errors and handling specific exceptions like missing files or permission issues.
-
Thread Management: Employs daemon threads to monitor the interrupt flag, enhancing program responsiveness and user control.
-
-
Audiovisual Encoding Parameters: Facilitates customization of video encoding parameters (e.g., bitrate, resolution) and provides fundamental audio manipulation options.
-
Video Trimming & Concatenation: Enables video clipping based on timestamps for single videos or multiple videos within a folder, and supports concatenation of multiple video segments, with adaptive adjustments to resolution, frame rate, etc.
-
Video Duration Retrieval: Leverages
ffprobe
to extract the duration of input video files, catering to dynamic parameter requirements in video processing tasks that depend on video length. -
Rotation & Filtering: Defines several schemes for video rotation and image overlays, such as landscape-to-portrait conversion or applying a blurred background overlay, catering to diverse video editing needs, and automatically adjusts video aspect ratios and sizes accordingly.
-