Simple C program to modify and verify errors on SubRip subtitles
πThis is the final project of a C language seminar on university. It's a command line program that checks for usual errors on subtitles in SubRip format (usually with a .srt extension).
In the SubRip format, the sequence of subtitles are formatted like this:
Example of a SubRip subtitle:
-
-f "filein" β file is the file name to process
-
-o "fileout" β fileout is the file name where changes will be saved
-
-b index β deletes the subtitle on index
-
-i startmilis endmillis "text" β inserts a new subtitle text, starting on startmilis to endmilis
-
-v β validates the subtitle looking for the following errors:
- index values are not ordered consecutive numbers
- index numbers don't start on 1
- subtitles are overlapped (subtitle i end_time is greater than subtitle i+1 start_time)
- a subtitle lasts less than 1 second
- a subtitle lasts more than 7 seconds
- subtitle line too long (more than 36 characters)
- too many characters per second (more than 25)
- subtitle has more than 2 lines of text
- less than 75 miliseconds between subtitle i end and subtitle i+1 start.
If errors are found, the program must print the index of the respective subtitle and a description of the error, and keep validating the file.
- f parameter is mandatory and cannot repeat
- o parameter is mandatory if the file is modified with other parameters (all except -v) and cannot repeat
- the rest of parameters are opcional, all need to be processed , and processed in order
- parameters are received in any order
- if there are more than one -f or -o parameter a help message is displayed and the exit code is 1
- if a mandatory parameter is not received the previous message is displayed and the exit code is 2
- if a invalid parameter is received the help message is displayed and exit code is 3
- if the file in or file out cannot be opened or saved the exit code is 4.
Clone the repository
git clone https://github.com/fgerst/srt-parser.git
Compile the C source code using Makefile and GCC
cd srt-parser
make
An example of a program invocation would be like this
> ./srt_parser -v -f "pine_barrens.srt" -o "pine_barrens_out.srt" -i 7000 8200 "Did you wrap the package?" -v -b 3 -v