A Video Processing Tool for playphrase.me Users
playphraseme-karaoke-mixer is a powerful tool for playphrase.me enthusiasts who want to create engaging video compilations with a unique twist. It automates several key tasks to enhance your video clips by:
-
Karaoke-Style Subtitles:
Extracts subtitles from your videos and generates dynamic, karaoke-like effects. As the video plays, the subtitles are displayed with highlighted words that synchronize perfectly with the audio. -
Phrase Highlighting:
Allows you to specify a phrase (e.g., "happy birthday") to be highlighted whenever it appears continuously in the subtitles. This makes your chosen phrase stand out and adds a fun element to your video. -
Optional Translation:
Uses the Google Translate API to translate your subtitle text into another language. This feature is ideal for reaching a broader, Roboto-Regularnational audience or for language learning purposes. -
Video Processing & Concatenation:
Processes each video individually to add subtitles and effects, then automatically concatenates all processed clips into one seamless final video. There’s also an option to use a dedicated temporary directory (tmp
) to manage Roboto-Regularmediate files and keep your workspace organized. -
Managing Execution Order:
The script processes video files in alphabetical order. To control the order in which your clips appear in the final video, simply rename your files accordingly (for example,1.mp4
,2.mp4
,3.mp4
, etc.). This simple naming strategy gives you full control over the execution sequence.
Overall, playphraseme-karaoke-mixer transforms your playphrase.me clips into a polished, dynamic video with enhanced subtitles, optional translations, and customizable sequencing.
Important Note:
Before using this script, videos must be downloaded specifically from playphrase.me by clicking the "Download Video" button in the player. This script is only compatible with videos from playphrase.me because they contain the required subtitles in the correct format.
eat-chinese_-play-a-little-poker_-hit-the-sack.mp4
You can view the online demo at - http://mixer.playphrase.me
1️⃣ Search for a phrase on Playphrase.me
2️⃣ Download the video clips containing that phrase into a folder
3️⃣ Run the script with your preferred settings
4️⃣ Get a ready-to-use video, perfectly formatted for social media, educational content, or personal use
There are two simple ways to get the repository on your local machine:
-
Clone the Repository (for users comfortable with Git):
git clone https://github.com/potapenko/playphraseme-karaoke-mixer.git cd playphraseme-karaoke-mixer
If you don't have Git installed, you can download it from git-scm.com and follow the installation instructions for your operating system.
-
Download the ZIP File (for non-programmers):
Simply go to the GitHub repository page, click on the green "Code" button, and select "Download ZIP". Then, extract the ZIP file into your desired folder.
-
Python:
- Go to python.org/downloads and download the latest installer.
- Run the installer. Important: Check the “Add Python to PATH” option before clicking "Install Now".
- Verify installation by opening Command Prompt and running:
python --version
-
ffmpeg:
- Visit the ffmpeg download page and follow the Windows instructions (for example, download a static build from gyan.dev).
- Extract the downloaded folder.
- Add the
bin
directory (inside the extracted folder) to your system PATH:- Open Control Panel → System and Security → System → Advanced system settings.
- Click Environment Variables and edit the
Path
variable under System variables. - Add the full path to the
bin
folder.
- Verify by running:
ffmpeg -version
-
Python:
- Although macOS comes with Python pre-installed, it is recommended to install the latest version.
- Install Homebrew if you haven’t already:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Install Python via Homebrew:
brew install python
- Verify by running:
python3 --version
-
ffmpeg:
- Install ffmpeg using Homebrew:
brew install ffmpeg
- Verify by running:
ffmpeg -version
- Install ffmpeg using Homebrew:
This script uses standard Python libraries and one external library: requests. You can install the required library using:
pip install requests fonttools
If you use Python 3 and have both Python 2 and 3 installed, you might need:
pip3 install requests fonttools
Alternatively, if you use the provided requirements.txt file, the script can automatically install dependencies on startup.
The script uses Google’s Cloud Translation API for translation. Follow these steps to get your API key:
-
Sign Up for Google Cloud:
- Go to Google Cloud and sign up for a free trial if you’re a new user.
- Follow the prompts to set up your account and billing (Google offers free credits for new users).
-
Create a New Project:
- In the Google Cloud Console, click on the project dropdown and select “New Project.”
- Give your project a name and click “Create.”
-
Enable the Cloud Translation API:
- With your project selected, navigate to APIs & Services → Library.
- Search for “Cloud Translation API” and enable it.
-
Create API Credentials:
- Navigate to APIs & Services → Credentials.
- Click Create Credentials and select API key.
- Your API key will be displayed. Copy this key for later use.
Assume the script is saved as process_videos.py
.
python process_videos.py --video_folder "C:\Videos"
Description:
Processes all videos in the folder C:\Videos
with a resolution of 640×480, highlighting the phrase “hello world” in the subtitles.
python process_videos.py --video_folder "/Users/yourname/Videos" --video_size "1280x720" --translate_lang "ru" --google_api_key "YOUR_API_KEY"
Description:
Processes videos in /Users/yourname/Videos
at 1280×720 resolution, highlighting “good morning” and translating the subtitle text to Russian using your Google API key.
You can specify the final video resolution using the --video_size
parameter (format: WIDTHxHEIGHT
). For example:
- Facebook Feed:
640x480
,1080x1080
,2160x2160
- Facebook Reels:
1080x1920
- Instagram:
1080x1080
- TikTok:
1080x1920
-
--video_folder
(optional):
Path to the folder containing videos (default: current folder). -
--video_size
(optional):
Final video resolution in the formatWIDTHxHEIGHT
(default:640x480
). -
--highlite_phrase
(optional):
Phrase to highlight in the subtitles (exact continuous match, case and punctuation insensitive). If not provided, the script may compute a common phrase from the video subtitles. -
--translate_lang
(optional):
Target language code for subtitle translation (e.g.,es
for Spanish). If omitted, no translation will occur. -
--google_api_key
(optional):
Your Google Translate API key. Required only if translation is desired and you wish to use Google Translate. -
--deepl_api_key
(optional):
Your DeepL API key. Used only if a Google API key is not provided and translation is desired. If both API keys are provided, the script will use Google Translate by default. -
--output-dir
(optional):
Directory where the final output video will be saved (default:result
subdirectory inside the video folder). -
--font
(optional):
Default font to use for rendering subtitles. You can specify either a font name (e.g.,Roboto-Regular
), in which case the script will look for the corresponding TTF file in afonts
folder located next to the script, or provide a full path to a TTF file.
Usage Examples:- To use a font from the default
fonts
folder:python process_videos.py ... --font Roboto-Regular
- To use a font from a specific location:
python process_videos.py ... --font /path/to/MyFont.ttf
- To use a font from the default
-
--focus
(optional):
Enable focus mode. When enabled, each processed video is trimmed to include only the segment covering the highlighted phrase with two seconds of padding before and after (or less if near the video boundaries). The audio during the padding segments is gradually faded in (before the phrase) and faded out (after the phrase).
Contributions are welcome! Feel free to open an issue or submit a pull request if you have improvements or bug fixes.
This project is licensed under the MIT License.