I was wondering if I could get your assessment of the feasibility of the below Python application idea I had? If feasible, are there any significant areas you can see that I might need to clarify, elaborate on, or potentially rethink altogether? The idea is to get an MVP version of the application created that can then be enhanced later.
Video Converter Overview
Purpose:
A Python application for personal use that allows a user to to select either a single video file or a folder of video files and transcode them with configurable settings.
User Workflow
The user launches the application. The initial state is a blank canvas, and the application should detect whether an NVIDIA GPU is present for acceleration
To add a video file to transcode, the user can add a single video file using the “Add Video” option. To add a folder of video files the user would use the “Add Folder” option. When adding a folder, the application will scan for all valid video files in the folder the user selects ignoring subfolders. When scanning, the application will read metadata for each video file (based on file extension - .ts, .wmv, .mp4, .m4v) using ffprobe and create a widget for each file added - in the case of a folder being selected, files should be scanned and added in alphabetical order. Bulk adding videos should present a popup window to the user as files are being scanned & added and block other UI actions to avoid the risk of a potential conflict.
For each video added, a collapsible widget will be added to the queue with new videos being added at the bottom.
When expanded, the widget should have the following options:
The order of the clip in the project
A "Delete" Button to delete the widget
An Up and Down arrow to use when reordering
A dropdown for the desired output format (H.264 or H.265)
A checkbox to indicate whether GPU acceleration should be used (enabled by default if an NVIDIA GPU is detected on startup and hidden if no NVIDIA GPU is detected. GPU acceleration would use either h264_nvenc or hevc_nvenc)
A dropdown with the option to resize the video (with Unchanged, 1920x1080, 1280x720, 960x540 as options, and Unchanged as the default)
The desired CRF/CQ factor to use when transcoding (20-30 slider with a default value of 23)
A dropdown option to select the preferred audio bitrate (with Unchanged, 128Kbps, 192Kbps, 320Kbps options and Unchanged as the default)
Basic metadata about the source file (file name, source dimensions, duration)
When collapsed, the widget should have the following options:
The order of the clip in the project
The first 100 characters of the source file name (without the folder path)
The source video duration
An Up and Down arrow to use when reordering
The user can edit video transcoding settings within the widget, which will automatically save with a 300ms debounce timer to prevent unnecessary updates while a user is typing in a value or adjusting a slider
When the user is finished adding and reordering video clips, they would click an "Export" button. This would generate a pop up dialog that prompts the user to select the output folder. It would also display:
The number of videos being transcoded
If one or more files with the same name is already present in the destination folder, a warning that proceeding will overwrite them (exported files will use the same file name as the source video with a MP4 file type)
The export dialog should have a "Proceed" and "Cancel" button to allow the user to abort if needed.
After the user has selected their export options, a background process is run to process transcoding of the source video files in the order the user selected in the application
The Export workflow should work like this:
For each item, generate an FFMPEG command to handle transcoding based on the user selected options for each video (which may be different between video files)
the FFMPEG command should attempt to align audio and video start times and regenerate the timeline to address potential source video file errors using a method like -fflags +genpts
If the user selected GPU acceleration but GPU acceleration is not available, the application should silently fall back to CPU transcoding using libx264 or libx265
If the user resizes a video to dimensions that would result in a different aspect ratio, the export process should add letterboxing or pillar boxing as needed to prevent distorted output.
While exporting, the application should update the progress bar using a videos processed / total videos format
To simplify state management, UI elements should be locked/unselectable during an export process
If an export operation fails, the error should be logged but should not stop attempts to transcode other files in the queue. Retrying a failed export is currently out of scope.
When the export process is complete, the user should receive a pop up window that summarizes the export results (total number of videos processed, file names for any failed exports, and a link to the output folder)
System Specifications:
OS: Windows 11 Pro
CPU: Intel i9-13900K
RAM: 64GB (~42GB available under normal circumstances)
GPU: NVIDIA RTX 4080 with 16GB of VRAM (~13GB available under normal circumstances)
Storage: ~2TB available.
Additional requirements/preferences:
From a coding standpoint, smaller Python files implementing a single class object are preferred to keep memory and context length more manageable.
Coding approaches should favor simpler approaches that accomplish the goal over more complex approaches that may offer little benefit for the amount of complexity they add.
Preferred development approach is a "walking skeleton" approach where the UI is created first, then components are developed and integrated in the order they would be used based on the workflow.
PyQt6 is the preferred approach to use for the user interface.
Code should be clearly commented for maintainability or future enhancements.
After implementing a component, it should be tested before resuming developing further components of the application.
If the application encounters an error, it should be displayed to the user in the UI as well as captured to a log file in a logging subfolder. The application should check the folder on start and clear all but the last 5 logs to keep the folder size manageable.
Long-running processes should be isolated to background worker threads to keep the UI responsive
Proposed user interface: A single pane application with the main window containing a column of clip widgets. A QMenuBar object would have an "Exit" option, and a QToolBar would have the “Add Video”, “Add Folder”, and “Export” options. At the bottom of the application window should be a progress bar to be used when a selected video source is being processed as well as for the export process.
For video transcoding, FFMPEG is installed and added to the Windows PATH
Video widgets should read from and write to a central data class that stores the information about the scenes (file path, clip order, transcoding selections, other metadata needed) without the clip widgets separately storing any information, ideally using an MVC approach to handle widget/data class interactions.
Input Video Specifications:
Resolution - typically 960x540, 1280x720, 1920x1080
Frame Rate - Typically 25 frames/second, 29.97 frames/second, 59.94 frames/second
File types - .ts, .wmv, .mp4, .m4v
Duration - 15-30 minutes for most videos, the longest approach 60 minute durations
Queue size - 100 videos is likely to be the largest processed at once, but should not be a hard limit.
Assistant
Feasibility Assessment:
The proposed Python application for video transcoding is feasible. The requirements and specifications provided are well-documented, and the use of PyQt6 for the UI and FFMPEG for video transcoding are suitable choices.
Significant Areas to Clarify or Rethink:
Error Handling: While the application will log errors and display them to the user, it's essential to consider how to handle specific error scenarios, such as:
FFMPEG command failures
GPU acceleration fallback failures
File system errors (e.g., permission issues, disk space limitations)
Performance and Resource Management: With a large queue size (up to 100 videos) and long video durations (up to 60 minutes), the application may consume significant system resources. Consider implementing:
Resource monitoring and limiting (e.g., CPU, memory, disk space)
Priority queuing or batch processing to manage resource utilization
UI Responsiveness and Feedback: To maintain a responsive UI, ensure that:
Background worker threads are properly implemented and managed
Progress updates are frequent and accurate
User feedback is provided for long-running operations (e.g., export process)
Data Storage and Management: The central data class will store information about the scenes. Consider:
Data persistence (e.g., saving and loading project data)
Data validation and sanitization to prevent errors or inconsistencies
Security and Permissions: When working with file systems and executing external commands (FFMPEG), ensure that:
Proper permissions and access controls are in place
User input is validated and sanitized to prevent security vulnerabilities
Testing and Debugging: Develop a comprehensive testing strategy to cover various scenarios, including:
Unit testing for individual components
Integration testing for the entire application
User acceptance testing (UAT) to validate the application's functionality and usability
Additional Recommendations:
Modularize the Code: Break down the application into smaller, independent modules to improve maintainability and scalability.
Use Design Patterns: Apply design patterns (e.g., MVC, Singleton) to organize the code and improve its structure.
Implement Logging and Monitoring: Use logging and monitoring tools to track application performance, errors, and user activity.
Consider Using a Database: If the application grows in complexity or requires more advanced data management, consider using a database to store project data.
By addressing these areas and following best practices for coding, testing, and debugging, you can create a robust and efficient video transcoding application that meets your requirements.