In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to edit video subtitles in Linux. The quality of the article is high, so Xiaobian shares it with you as a reference. I hope you have a certain understanding of relevant knowledge after reading this article.
I have been a fan of world and regional films for decades. During this period subtitles are an essential tool that allows me to enjoy excellent movies from different countries and languages. If you like watching movies with subtitles, you may notice that sometimes the subtitles are not synchronized or correct. Did you know that you could write your own subtitles and make them perfect? Let's show you some basic subtitle editing in Linux.
Caption extraction from closed caption data
Around 2012 or 2013 I started learning about a tool called CCEextractor. Over time, it has become one of my indispensable tools, especially when I stumble upon a media file that contains subtitles.
CCExtractor is responsible for parsing video files and generating separate caption files from closed captions data.
CCExtractor is a cross-platform, free and open source tool. The tool has matured considerably since its inception and is now part of GSOC and Google's coding input.
Simply put, the tool is basically a series of scripts that give you extracted subtitles one after another in a sequential fashion.
You can follow the CCExtractor installation guide on this page.
If you want to extract subtitles from media files after installation, follow these steps:
ccextractor
This 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:34100% | 144:34Output file: $something_eng.srtDone, processing time = 6 secondsIssues? Open a ticket herehttps://github.com/CCExtractor/ccextractor/issues
It browses through media files. In this example, it finds that the media file is in the Malayalam language (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, which I'll describe in the next section.
Fun reading: there's an interesting subtitle feed at vicaps that explains and shares why subtitles are so important to us. For those interested in such topics, there are also many details of filmmaking.
Editing subtitles with SubtitleEditor tool
You probably realize that most subtitles are.srt. The advantage of this format is that you can load it into a text editor and modify it slightly.
When entered into a simple text editor, an srt file would look something like this:
100:00:00,959 --> 00:00:13,744"THE CABINETOF DR. CALIGARI" 200:00:40,084 --> 00:01:02,088A TALE of the modern re-appearance of an 11th Century Mythinvolting the strange and mysterious influenceof a mountebank monk over a somnambulist.
The subtitle excerpt I share is from a very old German film, Dr. Caligari's Cabin (1920).
Subtitleeditor is a great subtitle editor. The subtitle editor can be used to set subtitle duration, subtitle frame rate synchronized with multimedia files, subtitle interval time, etc. I'm going to share some basic subtitle editing here.
First, install the subtitle editor tool in the same way you installed the ccextractor tool, using your favorite installation method. In Debian, you can use the command:
sudo apt install subtitleeditor
When you're done, let's take a look at some common scenarios when editing subtitles.
Adjust frame rate to synchronize their media files
If you find that subtitles and video are out of sync, one reason may be that the frame rate of the video file does not match the frame rate of the subtitle file.
How do you know the frame rate of these files, and then what? To get the frame rate of a video file, you can use the mediainfo tool. First you may need the distribution's 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. Another frame rate we see is the frame rate of audio files. While I can share why certain fps are used in video decoding and audio decoding, etc., this will be a different topic, and there is a lot of historical information about it.
The next problem is to solve the frame rate of subtitle files, which is a little more complicated.
Usually, most subtitles are in compressed format. Unzip the.zip archive along with the subtitle file (ending with XXX.srt). In addition to this, there is usually an.info file with the same name, which may contain the frame rate of subtitles.
If not, it is usually best to go to a site and download subtitles from the site that has the frame rate information. For this particular German file, I used Opensubtitle.org to find it.
As you can see in the link, the frame rate for subtitles 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 the entire contents of the subtitle file. Click "Timings -> Change Framerate" to 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 method is enough to solve the problem, but sometimes the above method is not enough to solve the problem.
At the same frame rate, you may find that the beginning of the subtitle file is not the same as the beginning of the movie or media file.
In this case, follow these steps:
Press CTRL+A to select the entire contents of the subtitle file. Click "Timings -> Select Move Subtitle".
Move subtitles using Subtitle Editor on Linux
Set a new start for the subtitle file and save the changed file.
Move subtitles using Subtitle Editor in Linux
If you want to be more precise, you can use mpv to view a movie or media file and click on the progress bar (which shows the progress of the movie or media file), which also shows microseconds.
Usually I like precision, so I try to adjust as carefully as possible. MPV reaction times are accurate compared to human reaction times. If I want extremely precise time, then I can use something like Audacity, but that's another tool and you can do more on it. That will be something I will explore in my future blog.
Adjust caption interval time
Sometimes, both methods are not enough, and you may even need to shorten or increase the interval time to synchronize it with the media file. This is one of the more tedious tasks, because you have to determine the interval time for each sentence individually. Especially if the frame rate in the media file is variable (it's rare now, but you'll still get such files)
In this scenario, you may have to manually modify the interval because automatic editing is not possible. The best way to do this is to modify the video file (which degrades the video quality) or switch to a higher quality source and transcode it with your preferred settings. This is another big task, which I will explain in some of my blog posts later.
summary
What I share above is more or less an improvement on existing subtitle files. If you start from scratch, you will need to spend a lot of time. I didn't share this at all, because a movie or any video material in an hour can easily take 4-6 hours or more depending on the subtitler's skill, patience, context, jargon, accent, native English speaker, translation, etc., all of which have an impact on the quality of the subtitles.
I hope you find it interesting and make your subtitles better from now on.
About how to edit video subtitles in Linux to share here, I hope the above content can be of some help to everyone, you can learn more knowledge. If you think the article is good, you can share it so that more people can see it.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.