Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to edit subtitles in Linux

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "how to edit subtitles in Linux", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to edit subtitles in Linux" this article.

Extracting subtitles from closed-circuit subtitle data

Around 2012 or 2013, I began to learn about a tool called CCEextractor. With the passage of time, it has become one of my indispensable tools, especially when I stumbled upon a media document with subtitles.

CCExtractor is responsible for parsing video files and generating independent subtitle files from closed-circuit subtitle closed captions data.

CCExtractor is a cross-platform, free and open source tool. The tool has matured since the year it was formed and is now part of GSOC and Google code input.

To put it simply, this tool is basically a series of scripts that provide you with extracted subtitles one after another in a sequence.

You can follow the CCExtractor installation guide on this page.

If you want to extract subtitles from the media file after installation, please follow these steps:

Ccextractor

The command will output the following:

$ccextractor $something.mkvCCExtractor 0.87, Carlos Fernandez Sanz Volker Quetschke.Teletext portions taken from Petr Kutalek's telxcc----Input: $something.mkv [Extract: 1] [Stream mode: Autodetect] [Program: Auto] [Hauppage mode: No] [Use MythTV code Auto] [Timing mode: Auto] [Debug: No] [Buffer input: No] [Use pic_order_cnt_lsb for H.264: No] [Print CC decoder traces: No] [Target format: .srt] [Encoding: UTF-8] [Delay: 0] [Trim lines: No] [Add font color data: Yes] [Add font typesetting: Yes] [Convert case: No] [Video-edit join: No] [Extraction start time: not set (from start)] [ Extraction end time: not set (to end)] [Live stream: No] [Clock frequency: 90000] [Teletext page: Autodetect] [Start credits text: None] [Quantisation-mode: CCExtractor's internal function]-Opening file: $something.mkvFile seems To be a Matroska/WebM containerAnalyzing data in Matroska mode Document type: matroskaTimecode scale: 1000000Muxing app: libebml v1.3.1 + libmatroska v1.4.2Writing app: mkvmerge v8.2.0 ('World of Adventure') 64bitTitle: $something Track entry: Track number: 1 UID: 1 Type: video Codec ID: V_MPEG4/ISO/AVC Language: mal Name: $something Track entry: Track number: 2 UID: 2 Type: audio Codec ID: A_MPEG/L3 Language: mal Name : $something Track entry: Track number: 3 UID: somenumber Type: subtitle Codec ID: S_TEXT/UTF8 Name: $something 99% | 144 something Track entry 34100% | 144:34Output file: $something_eng.srtDone Processing time = 6 secondsIssues? Open a ticket here https://github.com/CCExtractor/ccextractor/issues

It will scan the media files in general. In this example, it finds that the media file is Malayalam (mal) and the format is .mkv. It then extracts the subtitle file, names it the source file name and adds the suffix "_ eng".

CCExtractor is an excellent tool for enhancing subtitle functionality and subtitle editing, and I'll cover it in the next section.

Interesting reading: there is an interesting subtitle feed on vicaps that explains and shares why subtitles are so important to us. For those who are interested in such topics, there are also many details of filmmaking.

Edit subtitles with the SubtitleEditor tool

You probably realize that most of the subtitles are in .srt format. The advantage of this format is that you can load it into a text editor and make a few modifications to it.

When you enter a simple text editor, an srt file looks like this:

0000 THE CABINETOF DR 00959-- > 0000 THE CABINETOF DR 00959-- > 0000 TALE of the modern re-appearance of an 11th Century Mythinvolting the strange and mysterious influenceof a mountebank monk over a somnambulist 0000959-- > 0000008A TALE of the modern re-appearance of an 11th Century Mythinvolting the strange and mysterious influenceof a mountebank monk over a somnambulist.

The excerpts I share come from a very old German film, Dr. Calgary's Cabin (1920).

Subtitleeditor is a great subtitle editing software. The subtitle editor can be used to set the subtitle duration, the subtitle frame rate synchronized with multimedia files, the subtitle interval, and so on. Next I'm going to share some basic subtitle editing here.

First, install the subtitleeditor tool in the same way as the ccextractor tool, using your own favorite installation method. In Debian, you can use the command:

Sudo apt install subtitleeditor

When you're done with the installation, let's take a look at some common scenarios when you edit subtitles.

Adjust the frame rate to synchronize its media files

If you find that the subtitle is out of sync with the video, one reason may be that the frame rate of the video file is not the same as that of the subtitle file.

How do you know the frame rate of these files, and then? To get the frame rate of a video file, you can use the mediainfo tool. First of all, you may need a distributed package manager to install it.

Using mediainfo is very simple:

$mediainfo somefile.mkv | grep Frame Format settings: CABAC / 4 Ref Frames Format settings ReFrames: 4 frames Frame rate mode: Constant Frame rate: 25.000 FPS Bits/ (Pixel*Frame): 0.082 Frame rate: 46.875 FPS (1024 SPF)

Now you can see that the frame rate of the video file is 25.000 FPS. The other frame rate we see is the frame rate of the audio file. Although I can share why a specific fps is used in places such as video decoding and audio decoding, it will be a different topic and there is a lot of historical information related to it.

The next problem is to solve the frame rate of the subtitle file, which is a little more complicated.

In general, most subtitles are in compressed format. Unzip the. zip archive file with the subtitle file ending in XXX.srt In addition, there is usually a .info file with the same name, which may contain the frame rate of the subtitle.

If not, it is usually best to go to a site and download subtitles from a site with that frame rate information. For this particular German file, I use Opensubtitle.org to find it.

As you can see in the link, the frame rate of the subtitle is 23.976 FPS. Obviously, it doesn't play well with video files with a frame rate of 25.000 FPS.

In this case, you can use the subtitle editing tool to change the frame rate of the subtitle file.

Press CTRL+A to select everything in the subtitle file. Click "Timings-> Change Framerate", change 23.976 fps to 25.000 fps or any other frame rate you want, and save the changed file.

Synchronize frame rates of subtitles in Linux

Change the starting point of the subtitle file

Sometimes the above methods are enough to solve the problem, but sometimes the above methods are not enough.

When the frame rate is the same, you may find that the beginning of the subtitle file is not the same as the starting point in the movie or media file.

In this case, follow these steps:

Press CTRL+A to select all the contents of the subtitle file. Click "Timings-> Select Move Subtitle".

Move subtitles using Subtitle Editor on Linux

Set a new starting point for the subtitle file and save the changed file.

Move subtitles using Subtitle Editor in Linux

If you want the timing to be more accurate, you can use mpv to view the movie or media file and click the progress bar (which shows the progress of the movie or media file), which will also show microseconds.

Usually I like accurate operation, so I will try to adjust it as carefully as possible. Compared with human reaction time, the reaction time in MPV is very accurate. If I want extremely accurate time, then I can use something like Audacity, but that's another tool where you can do more things. That will also be what I will discuss in my future blog.

Adjust the subtitle interval

Sometimes, it is not enough to use both methods, and you may even need to shorten or increase the interval to synchronize it with media files. This is one of the more tedious tasks because you have to determine the interval of each sentence separately. Especially if the frame rate is variable in media files (it's rare these days, but you still get such files)

In this scenario, you may have to modify the interval manually because you cannot achieve automatic editing. The best way is to modify the video file (which will reduce the video quality) or switch to another higher-quality source and transcode it with your favorite settings.

The above is all the content of the article "how to edit subtitles in Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report