A simple tool to add subtitles to your video in the CoD MW I-III style.
from cosb import add_subtitles_to_video
style_file = "style.json"
video_file = "vid.mp4"
subtitle_file = "subs.json"
output_file = "output.mp4"
add_subtitles_to_video(video_file, subtitle_file, output_file, style_file)
git clone https://github.com/denver-code/cosb
cd cosb
poetry install
- change the
_style.json
tostyle.json
and modify it to your liking - change the
_subtitles_.json
tosubtitles.json
and modify it to your liking. This is the place where you can add your subtitles. - Provide
vid.mp4
in the root directory or rename_vid.mp4
tovid.mp4
to use the provided example video.
then run main.py
, you able to modify it to your liking or create your own script.
poetry run python main.py
The style file is a json file that contains the following fields:
{
"nameColors": {
"enemy": "#CD716D",
"friednly": "#86B9E1",
"neutral": "#C5E3BA"
},
"textColors": {
"general": "#F7F7F9"
},
"styles":{
"stroke": 0,
"strokeColor": "transparent",
"fontSize": 24
},
"duration": 3,
"padding": 100
}
[
{
"name": "Captain Price",
"text": "From now.... She's yours.",
"type": "friednly",
"startTime": "00:00:01"
},
{
"name": "Graves",
"text": "Alright, let's go.",
"type": "enemy",
"startTime": "00:00:02"
}
]
- Add basic support for multiple characters
- Render the suptitles from the file
- Color of the name will be based on the type and will be different from text color
- Add support for more video formats
- Change location of the subtitles when multiple characters are speaking
- Breaking the subtitles into multiple lines when the text is too long
- GUI
- Add Custom Fonts