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]!

Owner
Dmytro North
Dmytro North
Objective of the repository is to learn and build machine learning models using Pytorch. 30DaysofML Using Pytorch

30 Days Of Machine Learning Using Pytorch Objective of the repository is to learn and build machine learning models using Pytorch. List of Algorithms

Mayur 119 Nov 24, 2022
PyTorch implementation of deep GRAph Contrastive rEpresentation learning (GRACE).

GRACE The official PyTorch implementation of deep GRAph Contrastive rEpresentation learning (GRACE). For a thorough resource collection of self-superv

Big Data and Multi-modal Computing Group, CRIPAC 186 Dec 27, 2022
Meta-meta-learning with evolution and plasticity

Evolve plastic networks to be able to automatically acquire novel cognitive (meta-learning) tasks

5 Jun 28, 2022
Testbed of AI Systems Quality Management

qunomon Description A testbed for testing and managing AI system qualities. Demo Sorry. Not deployment public server at alpha version. Requirement Ins

AIST AIRC 15 Nov 27, 2021
Replication package for the manuscript "Using Personality Detection Tools for Software Engineering Research: How Far Can We Go?" submitted to TOSEM

tosem2021-personality-rep-package Replication package for the manuscript "Using Personality Detection Tools for Software Engineering Research: How Far

Collaborative Development Group 1 Dec 13, 2021
Code for AutoNL on ImageNet (CVPR2020)

Neural Architecture Search for Lightweight Non-Local Networks This repository contains the code for CVPR 2020 paper Neural Architecture Search for Lig

Yingwei Li 104 Aug 31, 2022
TransNet V2: Shot Boundary Detection Neural Network

TransNet V2: Shot Boundary Detection Neural Network This repository contains code for TransNet V2: An effective deep network architecture for fast sho

Tomáš Souček 212 Dec 27, 2022
Official implementation for "Symbolic Learning to Optimize: Towards Interpretability and Scalability"

Symbolic Learning to Optimize This is the official implementation for ICLR-2022 paper "Symbolic Learning to Optimize: Towards Interpretability and Sca

VITA 8 Dec 19, 2022
Algorithms for outlier, adversarial and drift detection

Alibi Detect is an open source Python library focused on outlier, adversarial and drift detection. The package aims to cover both online and offline d

Seldon 1.6k Dec 31, 2022
Parasite: a tool allowing you to compress and decompress files, to reduce their size

🦠 Parasite 🦠 Parasite is a tool written in Python3 allowing you to "compress" any file, reducing its size. ⭐ Features ⭐ + Fast + Good optimization,

Billy 30 Nov 25, 2022
用强化学习DQN算法,训练AI模型来玩合成大西瓜游戏,提供Keras版本和PARL(paddle)版本

用强化学习玩合成大西瓜 代码地址:https://github.com/Sharpiless/play-daxigua-using-Reinforcement-Learning 用强化学习DQN算法,训练AI模型来玩合成大西瓜游戏,提供Keras版本、PARL(paddle)版本和pytorch版本

72 Dec 17, 2022
ONNX-GLPDepth - Python scripts for performing monocular depth estimation using the GLPDepth model in ONNX

ONNX-GLPDepth - Python scripts for performing monocular depth estimation using the GLPDepth model in ONNX

Ibai Gorordo 18 Nov 06, 2022
Histology images query (unsupervised)

110-1-NTU-DBME5028-Histology-images-query Final Project: Histology images query (unsupervised) Kaggle: https://www.kaggle.com/c/histology-images-query

1 Jan 05, 2022
Milano is a tool for automating hyper-parameters search for your models on a backend of your choice.

Milano (This is a research project, not an official NVIDIA product.) Documentation https://nvidia.github.io/Milano Milano (Machine learning autotuner

NVIDIA Corporation 147 Dec 17, 2022
Codes for the AAAI'22 paper "TransZero: Attribute-guided Transformer for Zero-Shot Learning"

TransZero [arXiv] This repository contains the testing code for the paper "TransZero: Attribute-guided Transformer for Zero-Shot Learning" accepted to

Shiming Chen 52 Jan 01, 2023
Converts geometry node attributes to built-in attributes

Attribute Converter Simplifies converting attributes created by geometry nodes to built-in attributes like UVs or vertex colors, as a single click ope

Ivan Notaros 12 Dec 22, 2022
A project to make Amazon Echo respond to sign language using your webcam

Making Alexa respond to Sign Language using Tensorflow.js Try the live demo Read the Blog Post on Tensorflow's Blog Coming Soon Watch the video This p

Abhishek Singh 444 Jan 03, 2023
A library for low-memory inferencing in PyTorch.

Pylomin Pylomin (PYtorch LOw-Memory INference) is a library for low-memory inferencing in PyTorch. Installation ... Usage For example, the following c

3 Oct 26, 2022
机器学习、深度学习、自然语言处理等人工智能基础知识总结。

说明 机器学习、深度学习、自然语言处理基础知识总结。 目前主要参考李航老师的《统计学习方法》一书,也有一些内容例如XGBoost、聚类、深度学习相关内容、NLP相关内容等是书中未提及的。

Peter 445 Dec 12, 2022
Quantized models with python

quantized-network download .pth files to qmodels/: googlenet : https://download.

adreamxcj 2 Dec 28, 2021