Skip to content

πŸ“ VTT Caption Merger is a Python script that automatically merges multiple .vtt subtitle files into a single file. Whether you're handling captions for long-form videos 🎬 or shorts πŸ“±, this tool efficiently combines subtitles from different sources, making it easy to manage and use.

Notifications You must be signed in to change notification settings

andrepradika/merge-webvtt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 

Repository files navigation

VTT Merging Script

This Python script merges .vtt subtitle files from two folders (watch and shorts) and combines them into merged .vtt files. It outputs three merged subtitle files:

  • One for captions from the watch folder.
  • One for captions from the shorts folder.
  • One combining all captions from both folders.

Requirements

  • Python 3.x
  • webvtt-py library for reading .vtt files. You can install it using pip:
pip install webvtt-py

File Structure

Ensure the following folder structure:

your_project_folder/
β”œβ”€β”€ watch/                # Folder containing VTT files for "watch"
β”œβ”€β”€ shorts/               # Folder containing VTT files for "shorts"
β”œβ”€β”€ merge/                # Folder where merged VTT files will be saved
β”œβ”€β”€ merge_vtt.py          # Python script (this script)
  • watch/: Place .vtt files related to "watch" content here.
  • shorts/: Place .vtt files related to "shorts" content here.
  • merge/: The merged .vtt files will be saved in this folder.

Usage

  1. Place your .vtt subtitle files into the watch/ and shorts/ folders.
  2. Run the script:
python merge_vtt.py
  1. The script will generate the following merged files in the merge/ folder:
    • watch_merge.vtt: Merged captions from the watch folder.
    • shorts_merge.vtt: Merged captions from the shorts folder.
    • all_merge.vtt: Merged captions from both the watch and shorts folders.

How It Works

  • The script reads all .vtt files in the watch/ and shorts/ folders.
  • It merges the captions from these files and stores the result in a new file.
  • Three merged .vtt files are generated:
    • watch_merge.vtt: Contains merged captions from the watch folder.
    • shorts_merge.vtt: Contains merged captions from the shorts folder.
    • all_merge.vtt: Contains merged captions from both watch and shorts folders.

Folder and File Paths

The following paths are used in the script:

  • watch_folder: Path to the folder containing the watch .vtt files (../watch).
  • shorts_folder: Path to the folder containing the shorts .vtt files (../shorts).
  • merge_results_folder: Path to the folder where the merged .vtt files will be saved (merge/).

Example

Folder Structure:

your_project/
β”œβ”€β”€ watch/
β”‚   β”œβ”€β”€ video1.vtt
β”‚   β”œβ”€β”€ video2.vtt
β”œβ”€β”€ shorts/
β”‚   β”œβ”€β”€ short1.vtt
β”‚   β”œβ”€β”€ short2.vtt
β”œβ”€β”€ merge/
β”‚   β”œβ”€β”€ watch_merge.vtt
β”‚   β”œβ”€β”€ shorts_merge.vtt
β”‚   β”œβ”€β”€ all_merge.vtt

Output Example:

After running the script, the merge/ folder will contain:

merge/
β”œβ”€β”€ watch_merge.vtt
β”œβ”€β”€ shorts_merge.vtt
β”œβ”€β”€ all_merge.vtt

License

MIT License (or your preferred license)

Author

andrepradika

sh``` yt-dlp --write-auto-subs --skip-download --sleep-requests 1.25 --min-sleep-interval 60 --max-sleep-interval 90 -o "%(uploader)s/%(title)s.%(ext)s" "https://www.youtube.com/@MyFirstMillionPod"

About

πŸ“ VTT Caption Merger is a Python script that automatically merges multiple .vtt subtitle files into a single file. Whether you're handling captions for long-form videos 🎬 or shorts πŸ“±, this tool efficiently combines subtitles from different sources, making it easy to manage and use.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages