[PLUG-TALK] Information on .srt subtitle file format
Clinton
c2plugtalk at gmail.com
Wed Aug 31 05:28:33 UTC 2022
Hi John,
I spend more time than I like to admit, mucking with SRT files.
You've probably already found a solution, but..
This might work to flip the from/to time fields in the file:
gawk '/^[0-9]{2}:/ {printf "%s --> %s\n", $3, $1 ; next} {print}'
subtitles.srt > fixedsubtitles.srt
You might be able to find a correct or even better srt file to match the
movie on subscene.com or addic7ed.com or opensubtitles.org
This could be a helpful reference: https://docs.fileformat.com/video/srt/
Interpretation of the various tags is highly variable between different
video player applications.
It has been my observation that idx/sub is a file format for storing DVD
bitmap VobSub type subtitles.
- Clinton
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Mon, 8 Aug 2022 12:56:47 -0700
> From: John Jason Jordan <johnxj at gmx.com>
> To: plug-talk at lists.pdxlinux.org
> Subject: Re: [PLUG-TALK] Information on .srt subtitle file format
> Message-ID: <20220808125647.3ee1b9f8 at Devil-Thinkpad>
> Content-Type: text/plain; charset=US-ASCII
>
> Wes,
>
> I found one way. Knowing that SRT subtitle files are mostly text I just
> opened it in Mousepad (the Xfce text editor). I got this:
>
> 1
> 00:00:30,280 --> 00:00:02,969
> MOVIE TITLE
>
> 2
> 00:01:21,331 --> 00:00:01,695
> Hold on.
>
> 3
> 00:01:31,408 --> 00:00:01,627
> Okay.
>
> And on it goes. I copied the arrows in the middle and pasted them on
> the end of each line, then selected the first time stamp with its
> following (middle) arrow and dragged it to the end of the line after the
> new arrows. Strangely, this gave me:
>
> 1
> 00:00:02,969 --> 00:00:30,280 -->
> MOVIE TITLE
>
> 2
> 00:00:01,695 --> 00:01:21,331 -->
> Hold on.
>
> 3
> 00:00:01,627 --> 00:01:31,408 -->
> Okay.
>
> And then I did a search and replace to delete the arrows at the end of
> the lines. I was just experimenting, so I did this on only the first 50
> lines or so. The first problem is that doing this with 1250+ lines will
> take a long time. A possibly more serious problem is whether just
> saving the file from Mousepad after finishing the editing will actually
> produce a usable subtitle file. And if that's not enough problems, when
> I look at the time stamps on the above three lines it looks like lines 2
> and 3 will appear at the same time as line 1. I don't know if you can
> do that.
>
> I have the idx/sub files that were the source for the .srt file, and I
> played the movie using them for the subtitles. Line 1 appeared at about
> 30 seconds into the movie and lasted for about three seconds. So now I
> don't know what these time stamps actually represent, i.e.,
> '00:00:30,280' must be the start time for line 1, and '00:00:02,969'
> must be the duration. When I look at the .srt file in any of my several
> subtitle editors the headers above the subtitles are labeled Num,
> Start, End, Duration, Text, and the above time stamps appear in the
> Start and End columns, while the duration is always -0-, because the
> big number is always in the start, with the little number in the end.
>
> I got the idx/sub files out of the MKV file that I created from the DVD
> with Handbrake, then used MKVToolnix-GUI to get an .mks file out of it,
> and then mkvextract to create the idx/sub files out of the .mks file.
> Then I opened the idx/sub files with Subtitle Composer (for the OCR
> work), and then exported as .srt. I suspect that opening the idx/sub
> files in Subtitle Composer is where something wrong happened. Subtitle
> Composer has a Help > Open Handbook button, but clicking on it does
> nothing. I searched all over the net for it, but it came up empty. Once
> again the devs thought they were done when the code was finished. It
> 'installs' via appimage. I used the above procedures to produce an .srt
> file for another movie, and it worked fine, so I don't know what went
> wrong this time.
>
> For another exercise I opened the .idx file in Mousepad, which
> displayed a long list with entries like this one, which must be for for
> line 1, although I see nothing for duration or end. The filepos is
> different for each line.
>
> timestamp: 00:00:30:280, filepos: 000000000
>
> Mousepad refused to open the .sub file, claiming that it was not UTF-8.
> Gedit spent a long time giving it a valiant effort, but at 15 minutes
> it was still displaying trash and I killed it. I'm curious about what's
> in the .sub file.
>
> I think I need to find a full treatise on creating subtitles and how
> they work. It would also be useful to find actual documentation for the
> programs I am using, except that such was usually never created.
>
>
> On Sun, 7 Aug 2022 19:18:19 -0700
> wes <plug at the-wes.com> dijo:
>
> >if you don't figure out a good solution, send me the file and I will
> >use linux command line tool wizardry to do it in a few minutes.
> >
> >-wes
> >
> >On Sun, Aug 7, 2022 at 6:47 PM John Jason Jordan <johnxj at gmx.com>
> >wrote:
> >
> >> I've spent the last couple of hours trying to find out the structure
> >> of a subtitle .srt file and, most importantly tools for reassembling
> >> one. So far, no luck.
> >>
> >> My problem is that I have an .srt file which is perfect in every
> >> respect, except the subtitles do not appear when I play the movie.
> >> Looking at the file with any of my various subtitle editors reveals
> >> the problem: For each line the onset time and the end time are
> >> reversed, e.g., for line one the onset time is 0:00:30.280 and the
> >> end time is 0:00:02:969. When the player starts the subtitle at 2
> >> seconds and ends it at 30 seconds nothing appears on the screen.
> >>
> >> The file contains about 1250 lines of subtitles. I could manually
> >> copy and rewrite the entries, but that would take a lot of time, not
> >> to mention errors. My thinking is that the data in this file has to
> >> be some kind of database where 'start' is one field and 'end' is
> >> another. Surely there is a way to rename the fields.
> >>
> >> Any suggestions?
> >> _______________________________________________
> >> PLUG: https://pdxlinux.org
> >> PLUG-talk mailing list
> >> PLUG-talk at lists.pdxlinux.org
> >> https://pdxlinux.org/mailman/listinfo/plug-talk
> >>
> >_______________________________________________
> >PLUG: https://pdxlinux.org
> >PLUG-talk mailing list
> >PLUG-talk at lists.pdxlinux.org
> >https://pdxlinux.org/mailman/listinfo/plug-talk
>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> PLUG: https://pdxlinux.org
> PLUG-talk mailing list
> PLUG-talk at lists.pdxlinux.org
> https://pdxlinux.org/mailman/listinfo/plug-talk
>
>
> ------------------------------
>
> End of PLUG-talk Digest, Vol 214, Issue 5
> *****************************************
>
More information about the PLUG-talk
mailing list