This project is a Python script that processes video files by converting them from MP4 to MKV format, normalizing subtitles, translating subtitles from German to English using Azure Translator, and muxing the translated subtitles back into the video file.
- Convert MP4 files to MKV format using FFmpeg.
- Normalize subtitles by removing HTML content.
- Translate subtitles from German to English using Azure Translator.
- Mux the translated subtitles back into the video file.
- Python 3.6+
- FFmpeg
- Azure Translator API credentials
-
Clone the repository:
git clone https://github.com/yourusername/ai-subtitle-translator.git cd ai-subtitle-translator
-
Install the required Python packages:
pip install -r requirements.txt
-
Ensure FFmpeg is installed and available in your system's PATH.
-
Prepare your video files and subtitles in the working directory.
-
Run the script with the required arguments:
python main.py --working-directory /path/to/working/directory --video-format mp4 --azure-translator-endpoint https://your-translator-endpoint.cognitiveservices.azure.com --azure-api-key your-azure-api-key
--working-directory
: Directory containing the video files and subtitles.--video-format
: Format of the video files (e.g., mp4, mkv).--azure-translator-endpoint
: Endpoint for the Azure Translator API.--azure-api-key
: Key for the Azure Translator API.--debug
: Set the log level to debug.
python [main.py](http://_vscodecontentref_/0) --working-directory ./videos --video-format mp4 --azure-translator-endpoint https://api.cognitive.microsofttranslator.com --azure-api-key YOUR_API_KEY