[go: up one dir, main page]

CN117544826B - Subtitle file editing method and subtitle editor for loading application - Google Patents

Subtitle file editing method and subtitle editor for loading application Download PDF

Info

Publication number
CN117544826B
CN117544826B CN202410026320.8A CN202410026320A CN117544826B CN 117544826 B CN117544826 B CN 117544826B CN 202410026320 A CN202410026320 A CN 202410026320A CN 117544826 B CN117544826 B CN 117544826B
Authority
CN
China
Prior art keywords
subtitle
structure object
subtitle file
data
format
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202410026320.8A
Other languages
Chinese (zh)
Other versions
CN117544826A (en
Inventor
庞猛
谭美红
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Feizhu Technology Co ltd
Original Assignee
Hangzhou Feizhu Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Feizhu Technology Co ltd filed Critical Hangzhou Feizhu Technology Co ltd
Priority to CN202410026320.8A priority Critical patent/CN117544826B/en
Publication of CN117544826A publication Critical patent/CN117544826A/en
Application granted granted Critical
Publication of CN117544826B publication Critical patent/CN117544826B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/47End-user applications
    • H04N21/488Data services, e.g. news ticker
    • H04N21/4884Data services, e.g. news ticker for displaying subtitles
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/451Execution arrangements for user interfaces
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/431Generation of visual interfaces for content selection or interaction; Content or additional data rendering
    • H04N21/4312Generation of visual interfaces for content selection or interaction; Content or additional data rendering involving specific graphical features, e.g. screen layout, special fonts or colors, blinking icons, highlights or animations
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/435Processing of additional data, e.g. decrypting of additional data, reconstructing software from modules extracted from the transport stream

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • General Health & Medical Sciences (AREA)
  • Computational Linguistics (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Human Computer Interaction (AREA)
  • Artificial Intelligence (AREA)
  • Studio Circuits (AREA)

Abstract

The invention provides a subtitle file editing method and a subtitle editor for loading application, which are used for acquiring a subtitle file, defining a Go structure object data structure, calling os.open to open a srt format subtitle file, calling bufio.Newscanner and scanner.Scan to circularly traverse the contents of the subtitle file line by line, wherein the sequence numbers, time stamps and characters identified in the contents are added into a block slice in the process of circularly traversing the contents of the subtitle file, each time empty contents appear, the block slice is added into a two-dimensional slice, the circularly traversing two-dimensional slice is stored in the Go structure object data structure according to the sequence numbers, the time stamps and the texts to obtain the Go structure object, wherein the Go structure object comprises a plurality of structure monomers arranged according to the sequence numbers, the Go structure object at the rear end is called based on the editing requirement acquired by the front page to carry out editing operation, and the Go structure object after the editing operation is still displayed on the front page in a json the basis of the json data, so that the quality and the efficiency of subtitle editing are improved.

Description

Subtitle file editing method and subtitle editor for loading application
Technical Field
The present invention relates to the field of subtitle editing, and in particular, to a subtitle file editing method and a subtitle editor for loading applications.
Background
Subtitles refer to non-visual content such as conversations in television, movies and stage works, and the correct and proper subtitles in visual videos can enable visual content to be displayed in a high-quality mode, and especially, the importance of the subtitles is self-evident for English teaching videos facing young children.
There are also some subtitle editors on the market, such as video subtitle editors like VideoSrtPro, which can support editing and modification of subtitles in SRT, ASS, VTT format, but cannot support editing of subtitles in JSON data format. However, compared with the SRT, ASS, VTT format, the JSON format has greater flexibility and expansibility, and can be better adapted to data processing of various application platforms, such as the online translation platform is mostly directly connected with the JSON format data. Because the existing caption editor does not support data editing in JSON format, the existing caption editor needs to introduce additional caption editors (such as Notepad++, subtitle Text, aegisub and the like) to translate the caption in SRT, ASS, VTT format, or needs to export and convert the caption in SRT, ASS, VTT format and then translate the caption by using an online translation tool, so that the problems of low translation efficiency and low accuracy exist.
Disclosure of Invention
The embodiment of the application provides a subtitle file editing method and a subtitle editor for loading application, which are used for automatically converting uploaded subtitles into a Go structure object data structure, converting the Go structure object data structure into data in a JSON format for online editing and improving the quality and efficiency of subtitle editing.
In a first aspect, an embodiment of the present application provides a method for editing a subtitle file, where the method includes: acquiring an uploaded subtitle file in a srt format or a vtt format, and converting the subtitle file in the vtt format into a srt format; defining a Go structure object data structure; invoking os.open to open srt format caption file, invoking bufio.newscanner and scanner.scan to cycle through the content of caption file line by line, wherein serial number, time stamp and text identified in the content are added into block slice in the process of cycling through the content of caption file, and each time empty content appears, block slice is added into two-dimensional slice; circularly traversing the two-dimensional slice, and storing the two-dimensional slice in a Go structure object data structure according to the sequence number, the timestamp and the text in a corresponding format to obtain a Go structure object, wherein the Go structure object comprises a plurality of structure monomers arranged according to the sequence number, and each structure monomer comprises the sequence number, the timestamp and the text; and converting the Go structure object into json data, displaying the json data on a front-end page, calling the Go structure object at the rear end to carry out editing operation based on the editing requirement acquired by the front-end page, and displaying the Go structure object after the editing operation on the front-end page still in the json data.
In a second aspect, an embodiment of the present application provides a subtitle file editor, including a front-end page and a back-end page, where the front-end page is used to input and display a subtitle file, and the back-end load runs any of the mentioned subtitle file editing methods.
In a third aspect, an embodiment of the present application provides an electronic device, including a memory, and a processor, where the memory stores a computer program, and the processor is configured to run the computer program to perform any one of the subtitle file editing methods.
In a fourth aspect, embodiments of the present application provide a readable storage medium having stored therein a computer program including program code for controlling a process to execute a process including the subtitle file editing method of any one of the above.
The main contributions and innovation points of the invention are as follows:
the subtitle file editing method provided by the embodiment of the application converts the srt and vtt format subtitle files into json data structures through a self-grinding method for editing, and has the advantages of convenient subtitle file editing, capability of butting other platform APIs, high correction efficiency, low using threshold and the like.
The details of one or more embodiments of the application are set forth in the accompanying drawings and the description below to provide a more thorough understanding of the other features, objects, and advantages of the application.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiments of the application and together with the description serve to explain the application and do not constitute an undue limitation to the application. In the drawings:
FIG. 1 is a file upload interface of a subtitle file editor that loads a method of operating a subtitle file editing according to one embodiment of the present application;
FIG. 2 is an interface schematic diagram of a front-end presentation JSON format subtitle of a subtitle file editor that loads a method of running a subtitle file editing according to one embodiment of the present application;
FIG. 3 is an interface diagram of the front end display function requirements of a subtitle file editor that loads a method for running subtitle file editing according to one embodiment of the present application;
FIG. 4 is a schematic diagram of an interface for front-end downloading of a subtitle file editor for loading a method for running a subtitle file editing according to one embodiment of the present application;
fig. 5 is a flowchart illustrating a subtitle file editing method according to an embodiment of the present application.
Fig. 6 is a schematic diagram of a hardware structure of an electronic device according to an embodiment of the present application.
Detailed Description
Reference will now be made in detail to exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, the same numbers in different drawings refer to the same or similar elements, unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with one or more embodiments of the present specification. Rather, they are merely examples of apparatus and methods consistent with aspects of one or more embodiments of the present description as detailed in the accompanying claims.
It should be noted that: in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this specification. In some other embodiments, the method may include more or fewer steps than described in this specification. Furthermore, individual steps described in this specification, in other embodiments, may be described as being split into multiple steps; while various steps described in this specification may be combined into a single step in other embodiments.
Example 1
The present invention provides a subtitle file editing method, which is different from the traditional editing method that can only edit subtitles in srt and vtt formats, and the subtitle file editing method provided in the present invention can convert uploaded text into Go structure object data structure for processing, in this way, efficiency and quality of various subtitle editing functions are improved, specifically, as shown in fig. 5, the subtitle file editing method provided in the present invention includes the following steps:
acquiring an uploaded subtitle file in a srt format or a vtt format, and converting the subtitle file in the vtt format into a srt format;
defining a Go structure object data structure;
invoking os.open to open srt format caption file, invoking bufio.newscanner and scanner.scan to cycle through the content of caption file line by line, wherein serial number, time stamp and text identified in the content are added into block slice in the process of cycling through the content of caption file, and each time empty content appears, block slice is added into two-dimensional slice;
circularly traversing the two-dimensional slice, and storing the two-dimensional slice in a Go structure object data structure according to the sequence number, the timestamp and the text in a corresponding format to obtain a Go structure object, wherein the Go structure object comprises a plurality of structure monomers arranged according to the sequence number, and each structure monomer comprises the sequence number, the timestamp and the text;
and converting the Go structure object into json data, displaying the json data on a front-end page, calling the Go structure object at the rear end to carry out editing operation based on the editing requirement acquired by the front-end page, and displaying the Go structure object after the editing operation on the front-end page still in the json data.
The method comprises the steps of firstly defining a Go structure object data structure, specifically, in the step of defining the Go structure object data structure, the Go structure object data structure consists of an id field, a start field, an end field and a line [ ] field, wherein the variables are defined as character strings after the start field, the end field and the line [ ] field, the variables are defined as integers after the id field, the id field is filled with sequence numbers, the start field and the end field are filled with time stamps, and the line [ ] field is filled with texts.
Illustratively, the Go structure object data structure provided by the present solution is as follows:
type SubtitleSlice struct {
SubtitileReponse struct {
Content []Subtitle
}
}
type Subtitle struct {
Idint
Start string
Endstring
Line[]string
}
in addition, the Go structure object data format of the present solution is applicable to subtitle text data in srt format, so in the step of "obtaining uploaded subtitle files in srt format or vtt format, converting the subtitle files in vtt format into srt format:
and acquiring a subtitle file, judging the subtitle type of the subtitle file, and if the subtitle type is in a webvtt format, calling ffmpeg-i xxx.
Specifically, as shown in fig. 1, a user imports a subtitle file on a front-end page of a subtitle editor provided in the scheme, and after receiving the subtitle file, the rear end stores the subtitle file on a server and reads the subtitle file to determine the subtitle type of the subtitle file.
Note that, in this scheme, go structure object data needs to be instantiated before the subtitle file in srt format is converted into Go structure object data, so that it can be prepared to store data. The following will focus on the details of converting a srt-format subtitle file into Go structure object data:
specifically, in the step of calling os.open to open a srt-format subtitle file and calling bufio.newscanner and scanner to circularly traverse the contents of the subtitle file line by line, the os.open method built in the Go is called to open a srt-format subtitle file, and the bufio.newscanner method built in the Go is called to read the contents of the subtitle file line by line, and the scanner is called to circularly traverse the contents of each line of subtitle file. In the process of calling the built-in bufio.newscanner method of Go to read the contents in the subtitle file according to the row, if the row contents of the subtitle file contain special characters or messy codes, the messy codes and the special characters are replaced by blank bytes, and the method is exemplified as follows; line=strings. Display (line, "\ufoff", -1)
line = strings.Replace(line, "\xef\xbb\xbf", "", -1)。
In order to realize the storage of the subtitle file, the scheme additionally defines a block slice and a two-dimensional slice, when the serial number, the timestamp and the text which are identified in the content of the subtitle file read by the bufio.NewScanner method according to the rows are added into the block slice, the block slice is added into the two-dimensional slice every time the hole content appears.
In the step of circularly traversing the two-dimensional slice and storing the sequence number, the timestamp and the text in the Go structure object data structure according to the corresponding format to obtain the Go structure object, the subscripts of the sequence number, the timestamp and the text definition are stored in the block slice, and in the process of traversing the two-dimensional slice, if the data in the block slice is identified to be the sequence number, strconv. Atoi is used for converting the sequence number into int; if the data subscript in the block slice identifies a time stamp, a string is separated by using strings; if the data of the block slice is identified as text, the text is stored in a Subtitle structure of the Go structure object, and the Subtitle structure of the Go structure object is added to the Subtitle structure content each time the two-dimensional slice is traversed to obtain the Go structure object.
The Go structure object of the present solution is composed of a plurality of structural monomers, and in some embodiments, the Go structure object obtained by the present solution is exemplified as follows: [ {1 00:00:03,160 00:00:04,620 [ I'm Peppa Pic I. I are piggy-pecies ] } {2 00:00:05,200 00:00:07,500 [ This is my little brother George, which is my brother George ] } {3 00:00:07,840 00:00:09,700 [ this is Mummy Pig, which is pig mom ] } {4 00:00:10,080 00:00:11,980 [ and this is Daddy Pig, which is pig dad ] } ]
In the "convert Go Structure object to json data display in front page" step, json. Marshal is invoked to convert Go Structure object to json data according to the Go Structure object data structure. If the Go structure object has no structure, the front page regards the Go structure object as a whole string, and the subsequent editing process cannot be performed. In this embodiment, the Go structure object data structure is defined, so that the json data converted by this embodiment also has a certain format, and in some embodiments, json data displayed on the front page of this embodiment is shown in fig. 2.
In the step of "calling Go structure objects of the back end based on editing requirements obtained by the front end page to perform editing operation and displaying the Go structure objects after editing operation on the front end page still as json data", the editing requirements include, but are not limited to, one or more combinations of a single english caption function, a single chinese caption function, a chinese double caption function, a punctuation removal function, a global search function, a single line data deletion function, and a data modification function. In some embodiments, the editing requirements displayed on the front page of the present solution are as shown in fig. 3.
Specifically, when the editing requirement is a single English subtitle function, judging whether text in a line field in the Go structure object is Chinese, if so, calling a copy function built in Go to reorganize variables of the Go structure object to delete the line field of a structural monomer where Chinese is located to form a new Go structure object and converting the new Go structure object.
Because text is stored in the Line field of the Go structure object, it is determined whether the value in the Line field is [_4e00\u9fa5 ], if yes, the current Line field is deleted if the value in the Line field is chinese, and the specific code is as follows:
index=n (according to judgment, row 0 or 1)
s := make([]string, len(srt.Subtitle.Content)-1)
copy(s[:index], srt.Subtitle.Line[:index])
copy(s[index:],srt.Subtitle.Line[index+1:])
srt.Subtitle.Line = s
Specifically, when the editing requirement is a single Chinese subtitle function, judging whether text in a line field in the Go structure object is English, if so, calling a copy function built in Go to reorganize variables of the Go structure object to delete the line field of a structural monomer where English is located to form a new Go structure object and converting the new Go structure object.
Because English is stored in the Line field of the Go structure object, judging whether the value in the Line field is [ A-Za-z ], if so, deleting the current Line field.
Specifically, when the editing requirement is a Chinese-English double-caption function, detecting the language of the text of the lineZ field in the Go structure object, if the language is Chinese, calling the channel api interface to translate into English and fill the current line field, if the language is English, calling the channel api interface to translate into Chinese and fill the current line field to form a new Go structure object and converting.
Specifically, when the editing requirement is to remove the English punctuation mark function, detecting whether the line field in the Go structure object is English, if so, replacing the punctuation mark with blank to form a new Go structure object and converting.
Examples are as follows:
t2 := strings.Replace(t1, ",", " ", -1)
t3 := strings.Replace(t2, "。", " ", -1)
t5 := strings.Replace(t3, "!", " ", -1)
t6 := strings.Replace(t5, "?", " ", -1)
t7 := strings.Replace(t6, "?", " ", -1)
t8 := strings.Replace(t7, ",", " ", -1)
t9 := strings.Replace(t8, "!", " ", -1)
t0 := strings.Replace(t9, ".", " ", -1)
specifically, when the editing requirement is global search function, the rear end acquires the keywords transmitted from the front end page, and loops the Go structure object to compare whether each structure monomer contains keywords or not by strings.
Specifically, when the editing requirement is to delete a single-row data function, acquiring a row to be deleted and locating a structural monomer where the row to be deleted is located, deleting the structural monomer to form a new Go structural object, and converting the new Go structural object.
Specifically, when the editing requirement is to modify the data function, the content to be modified of the subtitle file to be modified is obtained, and the structure monomers in the corresponding Go structure body object are positioned according to the content to be modified, so that the structure monomers are modified to form a new Go structure body object and converted. In other words, the user can modify the start time, the end time and the Chinese and English content of a line by double-clicking the line on the front-end page, and the back-end overwrites the modified content to form a new Go structure object and converts the new Go structure object.
In some embodiments, the subtitle file editing method provided by the present invention further provides a subtitle downloading function. Specifically, when a request for downloading the subtitles is obtained, the front-end page sends the requested subtitle text to the back-end in json format, the back-end writes the user data in json format into the subtitle text in srt format, and the srt format subtitle text is returned to the front-end page again for local downloading. As shown in fig. 4, fig. 4 is a schematic diagram of the present embodiment for providing a subtitle downloading function.
Example two
Based on the same conception, the application also provides a subtitle file editor comprising a front-end page and a back-end, wherein the front-end page is used for inputting and displaying subtitle files, and the back-end loads and runs the subtitle file editing method mentioned in the first embodiment. The same contents as those in the first embodiment are not described here in detail.
Example III
The present embodiment also provides an electronic device, referring to fig. 6, comprising a memory 304 and a processor 302, the memory 304 having stored therein a computer program, the processor 302 being arranged to run the computer program to perform the steps of any of the subtitle file editing method embodiments described above.
In particular, the processor 302 may include a Central Processing Unit (CPU), or an Application Specific Integrated Circuit (ASIC), or may be configured to implement one or more integrated circuits of embodiments of the present application.
Memory 304 may include, among other things, mass storage 304 for data or instructions. By way of example, and not limitation, memory 304 may comprise a Hard Disk Drive (HDD), floppy disk drive, solid State Drive (SSD), flash memory, optical disk, magneto-optical disk, tape, or Universal Serial Bus (USB) drive, or a combination of two or more of these. Memory 304 may include removable or non-removable (or fixed) media, where appropriate. Memory 304 may be internal or external to the data processing apparatus, where appropriate. In a particular embodiment, the memory 304 is a Non-Volatile (Non-Volatile) memory. In particular embodiments, memory 304 includes Read-only memory (ROM) and Random Access Memory (RAM). Where appropriate, the ROM may be a mask-programmed ROM, a Programmable ROM (PROM), an Erasable PROM (EPROM), an Electrically Erasable PROM (EEPROM), an electrically rewritable ROM (EAROM) or FLASH memory (FLASH) or a combination of two or more of these. The RAM may be Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM) where appropriate, and the DRAM may be fast page mode dynamic random access memory 304 (FPMDRAM), extended Data Output Dynamic Random Access Memory (EDODRAM), synchronous Dynamic Random Access Memory (SDRAM), or the like.
Memory 304 may be used to store or cache various data files that need to be processed and/or communicated, as well as possible computer program instructions for execution by processor 302.
The processor 302 implements any one of the subtitle file editing methods of the above embodiments by reading and executing computer program instructions stored in the memory 304.
Optionally, the electronic apparatus may further include a transmission device 306 and an input/output device 308, where the transmission device 306 is connected to the processor 302, and the input/output device 308 is connected to the processor 302.
The transmission device 306 may be used to receive or transmit data via a network. Specific examples of the network described above may include a wired or wireless network provided by a communication provider of the electronic device. In one example, the transmission device includes a network adapter (Network Interface Controller, simply referred to as NIC) that can connect to other network devices through the base station to communicate with the internet. In one example, the transmission device 306 may be a Radio Frequency (RF) module, which is used to communicate with the internet wirelessly.
The input-output device 308 is used to input or output information. In this embodiment, the input information may be a subtitle file or the like in srt format, and the output information may be subtitle data or the like in editable json format.
Alternatively, in the present embodiment, the above-mentioned processor 302 may be configured to execute the following steps by a computer program:
it should be noted that, specific examples in this embodiment may refer to examples described in the foregoing embodiments and alternative implementations, and this embodiment is not repeated herein.
In general, the various embodiments may be implemented in hardware or special purpose circuits, software, logic or any combination thereof. Some aspects of the invention may be implemented in hardware, while other aspects may be implemented in firmware or software which may be executed by a controller, microprocessor or other computing device, although the invention is not limited thereto. While various aspects of the invention may be illustrated and described as block diagrams, flow charts, or using some other pictorial representation, it is well understood that these blocks, apparatus, systems, techniques or methods described herein may be implemented in, as non-limiting examples, hardware, software, firmware, special purpose circuits or logic, general purpose hardware or controller or other computing devices, or some combination thereof.
Embodiments of the invention may be implemented by computer software executable by a data processor of a mobile device, such as in a processor entity, or by hardware, or by a combination of software and hardware. Computer software or programs (also referred to as program products) including software routines, applets, and/or macros can be stored in any apparatus-readable data storage medium and they include program instructions for performing particular tasks. The computer program product may include one or more computer-executable components configured to perform embodiments when the program is run. The one or more computer-executable components may be at least one software code or a portion thereof. In addition, in this regard, it should be noted that any blocks of the logic flows as illustrated may represent program steps, or interconnected logic circuits, blocks and functions, or a combination of program steps and logic circuits, blocks and functions. The software may be stored on a physical medium such as a memory chip or memory block implemented within a processor, a magnetic medium such as a hard disk or floppy disk, and an optical medium such as, for example, a DVD and its data variants, a CD, etc. The physical medium is a non-transitory medium.
It should be understood by those skilled in the art that the technical features of the above embodiments may be combined in any manner, and for brevity, all of the possible combinations of the technical features of the above embodiments are not described, however, they should be considered as being within the scope of the description provided herein, as long as there is no contradiction between the combinations of the technical features.
The foregoing examples merely represent several embodiments of the present application, the description of which is more specific and detailed and which should not be construed as limiting the scope of the present application in any way. It should be noted that it would be apparent to those skilled in the art that various modifications and improvements could be made without departing from the spirit of the present application, which would be within the scope of the present application. Accordingly, the scope of protection of the present application shall be subject to the appended claims.

Claims (8)

1. A subtitle file editing method, comprising: acquiring an uploaded subtitle file in a srt format or a vtt format, and converting the subtitle file in the vtt format into a srt format; defining a Go structure object data structure; invoking os.open to open srt format caption file, invoking bufio.newscanner and scanner.scan to cycle through the content of caption file line by line, wherein serial number, time stamp and text identified in the content are added into block slice in the process of cycling through the content of caption file, and each time empty content appears, block slice is added into two-dimensional slice; circularly traversing the two-dimensional slice, and storing the two-dimensional slice in a Go structure object data structure according to a sequence number, a time stamp and a text in a corresponding format to obtain a Go structure object, wherein the Go structure object comprises a plurality of structure monomers arranged according to the sequence number, each structure monomer comprises the sequence number, the time stamp and the text, in the process of calling a built-in bufio.Newscanner method in Go to read the content in a subtitle file in a row, if the row content of the subtitle file contains special characters or mess codes, the mess codes and the special characters are replaced by empty bytes, the sequence number, the time stamp and the text define respective subscripts to be stored in a block slice, and in the process of traversing the two-dimensional slice, if the data in the block slice is identified to the sequence number, using strconv.Atoi to convert the sequence number into int; if the data subscript in the block slice identifies a time stamp, a string is separated by using strings; if the data of the block slice is identified as text, storing the text in a Subtitle structure of the Go structure object, and adding the Subtitle structure of the Go structure object to the Subtitle structure content to obtain the Go structure object when traversing the two-dimensional slice each time; and converting the Go structure object into json data, displaying the json data on a front-end page, calling the Go structure object at the rear end to carry out editing operation based on the editing requirement acquired by the front-end page, and displaying the Go structure object after the editing operation on the front-end page still in the json data.
2. The subtitle file editing method according to claim 1, comprising: in the step of defining the Go structure object data structure, the Go structure object data structure defines a Subtitle structure and a Subtitle structure, wherein the Subtitle structure in the Go structure object data structure is composed of an id field, a start field, an end field and a line [ ] field, wherein the start field, the end field and the line [ ] field define variables as character strings after the variable is defined as integers after the id field, the id field is filled with sequence numbers, the start field and the end field are filled with time stamps, and the line [ ] field is filled with text.
3. The subtitle file editing method of claim 1, wherein the editing requirements include, but are not limited to, one or more of a single english subtitle function, a single chinese subtitle function, a chinese double subtitle function, a punctuation removal function, a global search function, a single line data deletion function, and a data modification function.
4. The subtitle file editing method according to claim 3, wherein when the editing requirement is a single english subtitle function, it is determined whether text in a line field in the Go structure object is chinese, and if so, a copy function built in Go is called to reorganize variables of the Go structure object to delete the line field of a structure monomer where chinese is located to form a new Go structure object and convert the new Go structure object; when the editing requirement is a single Chinese subtitle function, judging whether a text in a line field in the Go structure object is English, if so, calling a copy function built in Go to reorganize variables of the Go structure object to delete the line field of a structural monomer where English is located to form a new Go structure object and converting the new Go structure object; when the editing requirement is a Chinese-English double-caption function, detecting languages of texts of line fields in the Go structure object, calling a channel api interface to translate into English if the languages are Chinese and filling the current line fields, and calling the channel api interface to translate into Chinese if the languages are English and filling the current line fields to form a new Go structure object and converting.
5. The subtitle file editing method of claim 1, wherein when a request for downloading a subtitle is acquired, after the front-end page transmits the requested subtitle text in json format to the back-end, the back-end writes the json-format user data into srt-format subtitle text, and srt-format subtitle text is returned to the front-end page again for local download.
6. A subtitle file editor comprising a front page and a back page, wherein the front page is used for inputting and displaying a subtitle file, and the back load runs the subtitle file editing method of any one of claims 1 to 5.
7. An electronic device comprising a memory and a processor, wherein the memory has stored therein a computer program, the processor being arranged to run the computer program to perform the subtitle file editing method of any one of claims 1 to 5.
8. A readable storage medium, characterized in that the readable storage medium has stored therein a computer program comprising program code for controlling a process to execute a process comprising the subtitle file editing method according to any one of claims 1 to 5.
CN202410026320.8A 2024-01-09 2024-01-09 Subtitle file editing method and subtitle editor for loading application Active CN117544826B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410026320.8A CN117544826B (en) 2024-01-09 2024-01-09 Subtitle file editing method and subtitle editor for loading application

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410026320.8A CN117544826B (en) 2024-01-09 2024-01-09 Subtitle file editing method and subtitle editor for loading application

Publications (2)

Publication Number Publication Date
CN117544826A CN117544826A (en) 2024-02-09
CN117544826B true CN117544826B (en) 2024-03-29

Family

ID=89792229

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410026320.8A Active CN117544826B (en) 2024-01-09 2024-01-09 Subtitle file editing method and subtitle editor for loading application

Country Status (1)

Country Link
CN (1) CN117544826B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117931248B (en) * 2024-03-25 2024-06-07 杭州菲助科技有限公司 Method and device for improving deployment efficiency of boulder application

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8918311B1 (en) * 2012-03-21 2014-12-23 3Play Media, Inc. Intelligent caption systems and methods
US9456170B1 (en) * 2013-10-08 2016-09-27 3Play Media, Inc. Automated caption positioning systems and methods
US10423660B1 (en) * 2017-12-07 2019-09-24 Amazon Technologies, Inc. System for detecting non-synchronization between audio and subtitle
CN110781649A (en) * 2019-10-30 2020-02-11 中央电视台 Subtitle editing method and device, computer storage medium and electronic equipment
KR102459775B1 (en) * 2022-06-24 2022-10-27 주식회사 에이치앤케이스튜디오 Automatic editing method, apparatus and system for artificial intelligence-based vidieo content production
CN116685995A (en) * 2020-12-30 2023-09-01 斯纳普公司 Adding time-based subtitles to captured video

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11856315B2 (en) * 2017-09-29 2023-12-26 Apple Inc. Media editing application with anchored timeline for captions and subtitles
US11775756B2 (en) * 2020-11-10 2023-10-03 Adobe Inc. Automated caption generation from a dataset

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8918311B1 (en) * 2012-03-21 2014-12-23 3Play Media, Inc. Intelligent caption systems and methods
US9456170B1 (en) * 2013-10-08 2016-09-27 3Play Media, Inc. Automated caption positioning systems and methods
US10423660B1 (en) * 2017-12-07 2019-09-24 Amazon Technologies, Inc. System for detecting non-synchronization between audio and subtitle
CN110781649A (en) * 2019-10-30 2020-02-11 中央电视台 Subtitle editing method and device, computer storage medium and electronic equipment
CN116685995A (en) * 2020-12-30 2023-09-01 斯纳普公司 Adding time-based subtitles to captured video
KR102459775B1 (en) * 2022-06-24 2022-10-27 주식회사 에이치앤케이스튜디오 Automatic editing method, apparatus and system for artificial intelligence-based vidieo content production

Also Published As

Publication number Publication date
CN117544826A (en) 2024-02-09

Similar Documents

Publication Publication Date Title
CN117544826B (en) Subtitle file editing method and subtitle editor for loading application
CN112650529B (en) System and method for configurable generation of mobile terminal APP codes
CN108717437B (en) Search result display method and device and storage medium
CN104572668A (en) Method and equipment for generating combined style file based on multiple style files
CN111729313A (en) Language configuration method and device, storage medium and electronic device
EP1830282A1 (en) Storage device and recording medium
CN116028047A (en) Page rapid generation method based on custom annotation
CN102568021B (en) A kind of picture playing method based on flash and system
CN113573125B (en) Subtitle rendering method and system based on SVG word stock
CN112540958B (en) File processing method, device, equipment and computer storage medium
CN115221437A (en) Font file loading method and device, electronic equipment and storage medium
CN113391817A (en) ANTLR 4-based header file replacement method and device
CN112383888A (en) Short message system, method and equipment
CN101369953A (en) Method and system for network distribution of fonts
CN113546409B (en) Method for playing GIF format resource by Laya engine and storage medium
CN101986303A (en) Digital television HSML analysis method and system applying DOM analysis engine
CN117336393A (en) Method and system for realizing automatic analysis of message data based on configuration model
EP3404560A1 (en) Search program, search device, and search method
CN115712601A (en) Method for reading fixed-length files in batch based on springbatch
CN116302181A (en) Web font file compression method and device based on Vite and application thereof
CN115758002A (en) Method, device, equipment and program product for displaying electronic map POI
CN111723316B (en) Character string rendering method and device, terminal equipment and computer storage medium
CN114610920B (en) Image storage format generation method, image storage format and processing system
CN112529643B (en) Electronic invoice processing method and device, storage medium and electronic equipment
CN116400967B (en) Method for smoothly playing startup animation based on UEFI BIOS

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant