Giter Club home page Giter Club logo

subtitle_merger's Introduction

How to download a YouTube video with Chinese and English subtitles, and merge both Chinese and English subtitles into the video to create a video with embedded bilingual subtitles.

The same applies to other languages.

1.Download youtube videos with subtitle in multi languages.

yt-dlp --write-subs --write-auto-subs --sub-format SRT --sub-langs "en,en-orig,zh-Hans" --write-thumbnail --write-description https://www.youtube.com/xxxxx

# or:
yt-dlp --write-subs --write-auto-subs --sub-format srt --convert-subs "srt" --sub-langs "en,en-orig,zh-Hans" --write-thumbnail --write-description "https://www.youtube.com/watch?v=ZA9K0JMrbWg"

2.To merge two subtitle files into one:

python merge_subtitle.py <srt_file1> <srt_file2> merged_subtitles.srt

The output file content is like this:

    1
    00:00:00,000 --> 00:00:02,430
    自计算机开始以来,编码
    Coding has been the bread and butter for 
    2
    00:00:02,430 --> 00:00:04,290
    一直是开发人员的必需品。
    developers since the dawn of computing. 

3.Then you can merge the subtitle file and origin video file.

Thus you can get a video file with embedded subtitles in two languages.

ffmpeg -i input_video.mp4 -vf "subtitles=merged_subtitles.srt" -c:a copy output_video.mp4

Prerequisites

$ pip install -r requirements.txt

# install ffmpeg on mac:
$ brew install ffmpeg

# for Ubuntu/Debian, install by apt:
$ sudo apt-get install ffmpeg

subtitle_merger's People

Stargazers

 avatar

Watchers

david l euler avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.