A Python script that creates subtitles of a given length from text paragraphs that can be easily imported into any Video Editing software such as FinalCut Pro for further adjustments.

Overview

Text to Subtitles - Python

main2

This python file creates subtitles of a given length from text paragraphs that can be easily imported into any Video Editing software such as FinalCut Pro for further adjustments.

1. Table of Contents

2. Description

2.1 Problem

In a fast-paced TV, Film, and Video production environment Video Editors are often faced with the task to create subtitles quickly and efficiently. They will often have a script that they manually into Video Editing software, one subtitle at a time, then adjust the timing.

In the case of Documentary films or long interviews, the number of subtitles can be overwhelming. In addition, there can be multiple subtitles in different languages.

2.2 Solution

Instead of manually typing the text in Video Editing Software or copy-pasting it from a text file one subtitle at a time this python script automatically converts text paragraphs, located in a text file into a standard .srt subtitle file. It can be then imported into any Video Editing Software.

The script creates subtitles of the same length, such as 3 seconds. Therefore, manual adjustments are still needed after importing the subtitles. Nevertheless, this workflow has proven to be much faster than the full manual process described above.

Input:

Call me Ishmael.

Some years ago,
never mind how long precisely,

having little or no money in my purse,
and nothing particular

Output:

1
00:00:00,000 --> 0:00:03,000
Call me Ishmael.

2
00:00:03,000 --> 0:00:06,000
Some years ago,
never mind how long precisely,

3
00:00:06,000 --> 0:00:09,000
having little or no money in my purse,
and nothing particular

2.3 Motivation behind the project

I first created this workflow when I was Directing and Video Editing TV mini-series. Since deadlines were extremely tight I was looking at every opportunity to speed up the delivery times while maintaining high quality. I later used it for commercial Videography projects. This solution fits my workflow very well and has proven to be very useful.

2.4 Development history

It was originally built simply by using a stack of regular expressions executed in the TextSoap.app along with some operations in Excel and manula copy-pasting. Later most of the steps were combined in a single Python script that is presented here.

3. Technologies Used

  • Python 3.9.4, compatible with Python 2.7 and above
  • datetime integrated module to work with date and time
  • re integrated regular expression operations module
  • os a portable way of using operating system dependent functionality

4. Installation

Download text_to_video_subtitles.py file from this GitHub repository.

5. Usage

5.1 Prepare .txt file

Take existing script or type it from scratch. Then manually split it into paragraphs in the following format:

Call me Ishmael.

Some years ago,
never mind how long precisely,

having little or no money in my purse,
and nothing particular
  • A single line represents a single line in a subtitle.
  • Empty line defines where one subtitle ends and a new one begins.
  • Normally one subtitle has one or two lines, but it can have more.

5.2 Rename and move .txt file

Paste the text into a text editor, then save it as subtitles.txt, and move the file into the same folder with text_to_subtitles.py.

5.3 Launch Python script

Open Terminal.app. Type python, add space, then drag and drop text_to_video_markers.py and press Return.

run python script with terminal

Alternatively, you can install the latest version of Python. Then right-click on text_to_video_markers.py file and choose Open with -> Python Launcher.app.

open python file with python launcher

Either method will run the script and create subtitles.srt file in the same folder.

5.4 Open subtitles.srt with FinalCut Pro

In FinalCut Pro choose File -> Import -> Captions..., then navigate to newly created subtitles.srt and select Import. This will import subtitles into an existing project. They will be visible in Timeline, Index (Captions), and Viewer. You can now easily adjust individual subtitles in Timeline and edit the text in Timeline and Inspector.

That's it! We have just automatically converted text with paragraphs into a universal .srt subtitle file for further adjustments and manipulations in Video editing software such as FinalCut Pro..

finalcut pro markers imported from text

6. Project Status

The project is: complete I am no longer working on it since I am not working for TV any longer. But if you have some ideas or want me to modify something contact me and we should be able to collaborate.

7. Known Limitations

  • An input text file must be named subtitles.txt
  • Text in subtitles.txt** file must be split into paragraphs.
  • Both text_to_subtitles.py and subtitles.txt must be located in the same folder.
  • The default subtitle length is 3 seconds and can only be changed inside text_to_subtitles.py code by changing the number in dursec = 3 statement.

8. Room for Improvement

  • Testing and logging the issues.
  • Making python script an executable file.
  • Developing GUI to be able to specify .txt and .fcpxml input files with any name and location.
  • Building a web app.

9. License

This project is open-source and available under the GNU General Public License v3.0

10. Contact

Created by @DmytroNorth - feel free to contact me at [email protected]!

You might also like...
🍀 Pytorch implementation of various Attention Mechanisms, MLP, Re-parameter, Convolution, which is helpful to further understand papers.⭐⭐⭐
🍀 Pytorch implementation of various Attention Mechanisms, MLP, Re-parameter, Convolution, which is helpful to further understand papers.⭐⭐⭐

🍀 Pytorch implementation of various Attention Mechanisms, MLP, Re-parameter, Convolution, which is helpful to further understand papers.⭐⭐⭐

The official implementation of Variable-Length Piano Infilling (VLI).
The official implementation of Variable-Length Piano Infilling (VLI).

Variable-Length-Piano-Infilling The official implementation of Variable-Length Piano Infilling (VLI). (paper: Variable-Length Music Score Infilling vi

Transformer-XL: Attentive Language Models Beyond a Fixed-Length Context Code in both PyTorch and TensorFlow

Transformer-XL: Attentive Language Models Beyond a Fixed-Length Context This repository contains the code in both PyTorch and TensorFlow for our paper

PyTorch implementation of Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation.
PyTorch implementation of Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation.

ALiBi PyTorch implementation of Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation. Quickstart Clone this reposit

Llvlir - Low Level Variable Length Intermediate Representation

Low Level Variable Length Intermediate Representation Low Level Variable Length

A project which aims to protect your privacy using inexpensive hardware and easily modifiable software
A project which aims to protect your privacy using inexpensive hardware and easily modifiable software

Protecting your privacy using an ESP32, an IR sensor and a python script This project, which I personally call the "never-gonna-catch-me-in-the-act-ev

OpenMMLab Image and Video Editing Toolbox
OpenMMLab Image and Video Editing Toolbox

Introduction MMEditing is an open source image and video editing toolbox based on PyTorch. It is a part of the OpenMMLab project. The master branch wo

 Layered Neural Atlases for Consistent Video Editing
Layered Neural Atlases for Consistent Video Editing

Layered Neural Atlases for Consistent Video Editing Project Page | Paper This repository contains an implementation for the SIGGRAPH Asia 2021 paper L

A fast poisson image editing implementation that can utilize multi-core CPU or GPU to handle a high-resolution image input.
A fast poisson image editing implementation that can utilize multi-core CPU or GPU to handle a high-resolution image input.

Poisson Image Editing - A Parallel Implementation Jiayi Weng (jiayiwen), Zixu Chen (zixuc) Poisson Image Editing is a technique that can fuse two imag

Owner
Dmytro North
Dmytro North
This repository is based on Ultralytics/yolov5, with adjustments to enable polygon prediction boxes.

Polygon-Yolov5 This repository is based on Ultralytics/yolov5, with adjustments to enable polygon prediction boxes. Section I. Description The codes a

xinzelee 226 Jan 5, 2023
This repository is based on Ultralytics/yolov5, with adjustments to enable rotate prediction boxes.

Rotate-Yolov5 This repository is based on Ultralytics/yolov5, with adjustments to enable rotate prediction boxes. Section I. Description The codes are

xinzelee 90 Dec 13, 2022
source code for 'Finding Valid Adjustments under Non-ignorability with Minimal DAG Knowledge' by A. Shah, K. Shanmugam, K. Ahuja

Source code for "Finding Valid Adjustments under Non-ignorability with Minimal DAG Knowledge" Reference: Abhin Shah, Karthikeyan Shanmugam, Kartik Ahu

Abhin Shah 1 Jun 3, 2022
DexterRedTool - Dexter's Red Team Tool that creates cronjob/task scheduler to consistently creates users

DexterRedTool Author: Dexter Delandro CSEC 473 - Spring 2022 This tool persisten

null 2 Feb 16, 2022
This solves the autonomous driving issue which is supported by deep learning technology. Given a video, it splits into images and predicts the angle of turning for each frame.

Self Driving Car An autonomous car (also known as a driverless car, self-driving car, and robotic car) is a vehicle that is capable of sensing its env

Sagor Saha 4 Sep 4, 2021
Automatically erase objects in the video, such as logo, text, etc.

Video-Auto-Wipe Read English Introduction:Here   本人不定期的基于生成技术制作一些好玩有趣的算法模型,这次带来的作品是“视频擦除”方向的应用模型,它实现的功能是自动感知到视频中我们不想看见的部分(譬如广告、水印、字幕、图标等等)然后进行擦除。由于图标擦

seeprettyface.com 141 Dec 26, 2022
Apply a perspective transformation to a raster image inside Inkscape (no need to use an external software such as GIMP or Krita).

Raster Perspective Apply a perspective transformation to bitmap image using the selected path as envelope, without the need to use an external softwar

s.ouchene 19 Dec 22, 2022