banner
Nix

Nix

正在作为一个废物|开心的生活|学习产生快乐的事物
twitter
bilibili

My bilingual subtitle workflow

Introduction#

The native subtitles in Final Cut Pro are not user-friendly and can result in a heavy workload when creating batch subtitles. For example, when I have a transcript, I have to constantly use ⌘ + C and ⌘ + V between Pages and FCP, which causes me great pain, including having to dance my fingers on the trackpad to select objects.

However, a turning point always happens at the worst moment. This is where the following workflow comes into play.

Transcript#

Yes. The applicable scenario for this workflow is that you first have a transcript. Usually, it includes the following scenarios:

  • Client-provided proofread copy
  • Lyric subtitles
  • Dialogue in films and TV dramas
  • ...

The transcript for creating subtitles can be saved as plain text in a TXT file.

This is 1st subtitle.
这是第 1 条字幕
This is 2nd subtitle.
这是第 2 条字幕

There should be no empty lines because I'm too lazy to handle them... (but you can add them yourself if you want)

Subtitle Timeline#

Generally, there are two ways to create a timeline: manual and automatic (AI).

Manual Timeline Creation#

It mainly relies on listening and audio waveforms, such as manual timeline creation (dragging or using the JK keys) in subtitle creation software like ArcTime. Of course, ArcTime is very friendly to bilingual subtitles. You can refer to the official tutorial: Workflow for Creating Bilingual Subtitles.

Workflow for Creating Bilingual Subtitles in ArcTime

Automatic Timeline Creation#

CapCut, a video editing software owned by ByteDance, is considered the best "subtitle creation" tool by many video creators. It has a free voice-to-text feature (intelligent subtitles) that is quite accurate. As a result, I have abandoned the previously commonly used Youdao Sight...

CapCut's software interface, with subtitle recognition and script matching, as well as importing local subtitles

Currently, the experience of automatic timeline creation is good in terms of determining the start and end points of sentences, but there are still some shortcomings in sentence segmentation. These shortcomings mainly apply to transcripts. It does not match well with the line breaks in the transcript. This is also my entire fantasy about "script matching". Maybe in a few more versions, CapCut will be able to achieve true script matching!

However, for now, an additional step of manual alignment is still needed. Merge/split the incorrectly segmented lines according to the transcript. But this part of the work is much easier compared to manual timeline creation. This is also the decisive step in the entire process! I hope there will be better optimization solutions.

The timeline can be exported as an SRT file.

1
00:02:14,000 --> 00:03:14,000
This is 1st subtitle.

2
00:05:21,000 --> 00:13:14,000
This is 2nd subtitle.

Subtitle Text Replacement#

After alignment, the SRT subtitle file can be exported. Here, you may make modifications based on the subtitle text generated by CapCut. For bilingual subtitles, you will duplicate the subtitle track and perform individual replacements using ⌘ + C and ⌘ + V.

But think about it, since they are both structured text, they can naturally be processed in batches through programming.

For example, the following Python code (ChatGPT can help you annotate each function clearly~)

# txt_to_srt.py

import pysrt

# Define the input file paths
srt_file_path = 'path/to/your/srt/file.srt'
txt_file_path = 'path/to/your/txt/file.txt'

# Define the output file paths
new_srt_file_EN_path = 'path/to/your/srt/file_EN.srt'
new_srt_file_ZH_path = 'path/to/your/srt/file_ZH.srt'

# Read the text from the txt file
with open(txt_file_path, 'r', encoding='utf-8') as txt_file:
    replacement_content = txt_file.read()

# Split the txt file into a list of sentences
replacement_text = replacement_content.split('\n')

# Initialize English and Chinese sentence lists
english_sentences = []
chinese_sentences = []

# Extract English and Chinese sentences respectively
for i in range(len(replacement_text)):
    if i % 2 == 0:  # Even lines are English sentences (Note: Counting starts from 0)
        english_sentences.append(replacement_text[i])  # Add to the English list
    else:  # Odd lines are Chinese sentences
        chinese_sentences.append(replacement_text[i])  # Add to the Chinese list

# Use the pysrt library to load the SRT file
subs_EN = pysrt.open(srt_file_path)
subs_ZH = pysrt.open(srt_file_path)

# Iterate through each subtitle entry and replace the text with the text from the txt file
for id, sub in enumerate(subs_EN):
    sub.text = english_sentences[id]

for id, sub in enumerate(subs_ZH):
    sub.text = chinese_sentences[id]

# Save the modified subtitles to new SRT files
subs_EN.save(new_srt_file_EN_path, encoding='utf-8')
subs_ZH.save(new_srt_file_ZH_path, encoding='utf-8') 

print("Subtitle replacement completed!")

"""
Make sure you have installed the pysrt library. You can use the pip command to install it: pip install pysrt.
Also, please replace srt_file_path, txt_file_path, new_srt_file_EN_path, and new_srt_file_ZH_path with your actual file paths.
This code will replace all subtitle texts in the SRT file with the text from the txt file and save the modified subtitles to new SRT files.
"""

Input

txt file
---
This is 1st subtitle.
这是第 1 条字幕
This is 2nd subtitle.
这是第 2 条字幕
srt file
---
1
00:02:14,000 --> 00:03:14,000
left blank intentionally.

2
00:05:21,000 --> 00:13:14,000
left blank intentionally.

Run

python txt_to_srt.py

Output

srt file EN
---
1
00:02:14,000 --> 00:03:14,000
This is 1st subtitle.

2
00:05:21,000 --> 00:13:14,000
This is 2nd subtitle.
srt file ZH
---
1
00:02:14,000 --> 00:03:14,000
这是第 1 条字幕

2
00:05:21,000 --> 00:13:14,000
这是第 2 条字幕

Importing into Editing Software#

CapCut: Supports importing SRT subtitles. After importing, edit the style, export the video, and deliver it.

Final Cut Pro: Since I mainly use Final Cut Pro, I need to import subtitles through XML. This is why there is a need to convert the SRT file to FCPXML file.

FCPXML Template File Template.fcpxml
---

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE fcpxml>

<fcpxml version="1.10">
    <resources>
        <format id="r1" name="FFVideoFormat1080p2997" frameDuration="1001/30000s" width="1920" height="1080" colorSpace="1-1-1 (Rec. 709)"/>
        <effect id="r2" name="Basic Title" uid=".../Titles.localized/Bumper:Opener.localized/Basic Title.localized/Basic Title.moti"/>
    </resources>
    <library>
        <event name="{EVENT_NAME}">
            <project name="{PROJECT_NAME}">
                <sequence format="r1" tcStart="0s" tcFormat="NDF">
                    <spine>
                        <title ref="r2" name="{TITLE_NO}" offset="{OFFSET}" duration="{DURATION}" start="{START}">
                            <param name="Flatten" key="9999/999166631/999166633/2/351" value="1"/>
                            <param name="Alignment" key="9999/999166631/999166633/2/354/999169573/401" value="1 (Center)"/>
                            <text>
                                <text-style ref="ts1">{TEXT}</text-style>
                            </text>
                            <text-style-def id="ts1">
                                <text-style font="Noto Sans SC" fontSize="42" fontFace="Regular" fontColor="1 1 1 1" shadowColor="0 0 0 0.75" shadowOffset="5 315" shadowBlurRadius="4"/>
                            </text-style-def>
                            <adjust-transform position="0 -40.7407"/>
                        </title>
                    </spine>
                </sequence>
            </project>
        </event>
    </library>
</fcpxml>

Online Conversion#

crossub Subtitle Conversion Tool

Local Conversion#

I found this project on GitHub hysmichael/srt_fcpxml_converter. The author has implemented bidirectional conversion between SRT and FCPXML.

Input

srt file EN
---
1
00:02:14,000 --> 00:03:14,000
This is 1st subtitle.

2
00:05:21,000 --> 00:13:14,000
This is 2nd subtitle.

Combined with the FCPXML template file Template.fcpxml. You can also adjust the style in Final Cut Pro and export it as an FCPXML file as a template.

Run

python srt_converter.py -i INPUT_FILE.srt -o OUTPUT_FILE.fcpxml

Output and Import into Final Cut Pro
Convert from SRT to FCPXML and import into Final Cut Pro

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.