View Full Version : Chapter coverter - simple textfile to Chapterformat?
HMarke
30th March 2022, 22:33
Hi,
i am searching for a program that converts simple textfiles (as people for example post under youtube videos) into a chapterformat which i can use to chapterize MKVs or split up Audiofiles into single files...
Most of the time people there use simple formats like this when they post under youtube:
00:00 Title 1
02:40 Title 2
09:27 Title 3
15:12 Title 4
...
1:05:23 Title x
1:13:26 Title xx
...
convert that for example to:
CHAPTER01=00:00:00.000
CHAPTER01NAME=Title 1
CHAPTER02=00:02:40.000
CHAPTER02NAME=Title 2
CHAPTER03=00:09:27.000
CHAPTER03NAME=Title 3
CHAPTER04=00:15:12 .000
CHAPTER04NAME=Title 4
...
CHAPTER12=01:05:23.000
CHAPTER12NAME=Title x
CHAPTER13=01:13:26.000
CHAPTER13NAME=Title xx
Any ideas?
Thanks!
hubblec4
31st March 2022, 11:19
Maybe
https://forum.doom9.org/showthread.php?t=169984
HMarke
31st March 2022, 12:38
I could not find a way to even open a normal textfile with a chapter description i mentioned above... when i try to open my chapterfile as a txt format it says "unsupported chapter format"...
Are you shure your program can import and automaticaly convert a simple list of chapters into a well-known chapter-file?
Maybe
https://forum.doom9.org/showthread.php?t=169984
StainlessS
31st March 2022, 13:03
Can you use Avisynth+ ?
Sounds daft to use Avisynth but I might want something similar myself.
I was thinking [EDIT: of] putting up file selector (I can do this with RT_Stats plugin), you pick your input text file,
put up file selector and you pick your output text file, then
Parse input and write output.
EDIT: I've started on script for myself anyways.
HMarke
31st March 2022, 14:17
When i find the time i will write a VBS Script to use inside of excel or word...
StainlessS
31st March 2022, 15:29
Post removed, see post #15:- https://forum.doom9.org/showthread.php?p=1966757#post1966757
StainlessS
31st March 2022, 20:01
Post removed, see post #15:- https://forum.doom9.org/showthread.php?p=1966757#post1966757
hubblec4
31st March 2022, 20:10
I could not find a way to even open a normal textfile with a chapter description i mentioned above... when i try to open my chapterfile as a txt format it says "unsupported chapter format"...
Are you shure your program can import and automaticaly convert a simple list of chapters into a well-known chapter-file?
chapterEditor can read a lot of chapter formats.
And it seems your chapter format is not supported, but I can add support for this format.
Can you share a file with me? Which program creates such files?
StainlessS
31st March 2022, 20:12
Which program creates such files?
He posts,
(as people for example post under youtube videos)
so is likely just a very loose user description written by hand and with little specific formatting.
(eg optional millisecs, optional hours, = "12:31" = 12 mins and 31 secs, no hours and no millisecs)
EDIT: I know nothing of MKV chapters specifics, my script just what I thought was required as outined in his 1st post.
StainlessS
31st March 2022, 20:39
Post removed, see post #15:- https://forum.doom9.org/showthread.php?p=1966757#post1966757
hubblec4
31st March 2022, 22:28
REMOVED: duplicated post
HMarke
1st April 2022, 00:36
Thanks for all the support - actually a better description what i am talking about....
*I often download videos (and audiofiles) from Youtube releases of Live-Concerts (i love live music!)
*I like the downloaded videofile more in MKV format with chapters to the different tracks - and if the music is really cool i also split up the audiofile into tracks for easier access...
Since a few years fans describe the Concerts more and more in chapters in their commentaries under the video - and nowadays the uploader even give their chapterinfos in the description direct under the videos... and they do it in the most simple and human way like...
"timestamp""space""trackname"
So i copy and pasted them as text into an editor and made my chapterfiles by myself - but i think this is ridiculous in theses times...;)
**Example of chapters in commentaries....
*https://www.youtube.com/watch?v=I5AOg8rTGHU
00:00:00 Intro (Zu Asche, zu Staub Remix)
00:04:29 Hit Me Like A Drum
00:08:17 Clap Your Hands
00:12:18 Josephine
00:16:08 Cuba Libre
00:20:51 Catgroove
00:24:57 Berlin Shuffle / Django's Revenge
00:32:07 Speed Demon
00:41:17 Mama Talking
00:44:28 The Burning Spider
00:49:14 Invisible Girl
00:54:12 Grandpa's Groove
00:59:01 Mojo Radio Gang
01:05:18 All Night
01:12:12 Nosferatu
01:16:20 Booty Swing
01:21:20 Step Two
or this example where the person choosed a little bit different version (without the empty hours/minutes):
*https://www.youtube.com/watch?v=2loN0JFZa0Y
0:10 Gula (Deadmau5)
7:15 Rej (Âme)
13:55 Customer Is King (Solomun)
18:12 Think Twice (Henrik Schwarz/The Detroit Experiment)
24:34 Versatile (Syap)
30:42 Araya (Fatima Yamaha)
36:25 Hey Hey (Dennis Ferrer)
44:00 Wixn (Siriusmo)
46:50 You & Me (Flume/Disclosure)
52:00 Every Wall Is A Door (N'to)
59:10 The Man with the Red Face (Laurent Garnier)
1:07:56 The Drums Pt. 1 (MEUTE)
1:13:22 Kerberos (Stephan Bodzin & Marc Romboy)
1:19:40 Acamar (Frankey & Sandrino)
1:27:00 Mental Help (Gonçalo)
1:32:45 Miss You (Trentemøller)
And here is an example where even the uploader publish the tracklist in the description of the upload..
*https://www.youtube.com/watch?v=Ts2qNTA8i5Q
00:00 Intro
00:35 Green Sun (Theresa Zaremba)
11:00 Mosaïque Bleu (Comp.: Leonhard Kuhn / Lyrics: Patricia Römer)
18:40 AI 101 (Leonhard Kuhn)
26:00 Make Craft Perform (Leonhard Kuhn)
33:44 Der Literat (Comp.: Leonhard Kuhn / Lyrics: Hugo Ball)
43:43 Suche nach Jugend (Comp.: Leonhard Kuhn / Lyrics: Johann Wolfgang von Goethe)
53:15 Who’s Your Daddy (Leonhard Kuhn)
1:05:26 String Quartet No. 14 - Part II, Adagio (Comp.: Ludwig v. Beethoven / Arr.: Leonhard Kuhn)
1:13:10 Transformation (Comp.: Transform / Arr.: Leonhard Kuhn)
1:19:16 Back Home (Leonhard Kuhn)
1:24:52 What It Is (Leonhard Kuhn)
1:31:08 Shuffling Steps (Leonhard Kuhn)
1:41:07 Green Sun Return (Theresa Zaremba)
1:52:49 J’arrive (Stefanie Raschke / Leonhard Kuhn)
2:01:28 I Want To Be A Banana (Leonhard Kuhn)
2:13:29 Punkt und Linie zur Fläche (Leonhard Kuhn)
2:20:15 Moebius Strip (Leonhard Kuhn)
Hope it gets clearer now...:)
hubblec4
1st April 2022, 12:52
@StainlessS
The name "ConvTxtToMkvChap" for your script is not correct/ is wrong. The output are chapters in OGG/OGM format not Matroska :-)
@HMarke
Ok, now I understand. It makes sense to add such chapter formats, and loading via the clipboard so you don't have to create a file first.
StainlessS
1st April 2022, 13:12
OK, thanks very much Hub, I'll change it.
StainlessS
1st April 2022, 13:20
REQUIRES RT_STATS v2.0 Beta #13 for a required bugfix [bug in non beta v1.43]:-
https://www.mediafire.com/file/xa3t1wx234gyzfq/RT_Stats_25%252626_x86_x64_dll_v2.00Beta13_20201229.zip/file
EDIT: See post #21 for update script.
Mod to name, ConvTxtToOggChap.avsi.
# ConvTxtToOggChap.avsi # (c) StainlessS @ https://forum.doom9.org/showthread.php?p=1966757#post1966757
# Converts very loosely user specified times and chapter name in file, to Ogg/Ogm Chapter style in file.
# Requires AVS+, and RT_Stats v2.0 Beta13+
Function ChrIsNul(String S) {return RT_Ord(S)== 0} # End of String
Function ChrIsHash(String S) {return RT_Ord(S)==35} # #
Function ChrIsWhite(String S) {C=RT_Ord(S) return C==32||C>=8&&C<=13} # SPC, BackSPC, TAB, LF, VT, FF, CR
Function ChrIsDigit(String S) {C=RT_Ord(S) return C>=48&&C<=57}
Function ChrEatWhite(String S) {i=1 C=RT_Ord(S,i) While(C==32||C>=8&&C<=13) {i=i+1 C=RT_Ord(S,i)} return i>1?MidStr(S,i):S}
# Return extent of string S [ie length from the beginning] that matches any character in Chars set of characters [Default case insignificant]. # StrMatchChrLen("1234.567abcd","0123456789.") = 8
Function StrMatchChrLen(String s,String Chars,Bool "Sig") {
Function __StrMatchChrLen_LOW(String s,String Chars,int n) { c=s.MidStr(n+1,1) Return(c==""||Chars.FindStr(c)==0) ? n : s.__StrMatchChrLen_LOW(Chars,n+1) }
Sig=Default(Sig,False) # Default Case Insignificant
s=(Sig)?s:s.UCASE Chars=(Sig)?Chars:Chars.UCASE
__StrMatchChrLen_LOW(s,Chars,0)
}
Function ConvTxtToOggChap(String txtfile,String "chapfile",Int "ChapIxLen",String "CommentChars") {
myName = "ConvTxtToOggChap: "
Chap = Default(chapfile,"")
ChapIxLen = Default(ChapIxLen,3) # At Least ChapIxLen digits appended to CHAPTER Times and NAME. [NO CHECK if exceeded]
CommentChars=Default(CommentChars,"#*") # String of chars, any one of which will be interpreted as comment introducer.
Assert(txtfile!="",RT_String("%stxtfile path required",myName))
txtfile = txtfile.RT_GetFullPathName
Assert(Txtfile.Exist,RT_String("%stxtfile Does not Exist",myName))
Chapfile = ((chapfile=="") ? ".\OggChap.txt" : chapfile).RT_GetFullPathName # Chapfile defaults "OggChap.txt" in current directory.
Chapfile.RT_FileDelete
SIN=RT_ReadTxtFromFile(txtfile)
LINES = SIN.RT_TxtQueryLines
TimeAlp="0123456789.:"
ChapIX = 0
for(i=0,LINES-1){
S = SIN.RT_TxtGetLine(Line=i).ChrEatWhite.RevStr.ChrEatWhite.RevStr # Get Line of text, remove EOL and Eat leading & trailing White Space.
IsComment = CommentChars.RT_FindStr(S.LeftStr(1),sig=True)!=0
if(!S.ChrIsNul && !IsComment) { # Ignore blank lines and those beginning with Any character in CommentChars string.
Assert(S.ChrIsDigit,RT_string("%sLINE %d, Expecting Digit @'%s'",myName,i+1,S))
Timelen=S.StrMatchChrLen(TimeAlp,sig=True)
Assert(Timelen>0,RT_String("%sLine %d Time NOT FOUND @'%s'",myName,i+1,S))
MilliSecs=0 Secs=0 Mins=0 Hrs=0
RTS = S.LeftStr(TimeLen).RevStr
TITLE = S.MidStr(Timelen+1).ChrEatWhite
ix = RTS.RT_FindStr(".")
if(ix>0) { # Optional millisecs ?
TS = LeftStr(RTS.LeftStr(ix-1).RevStr + "000",3)
MilliSecs = TS.RT_NumberValue # As integer, 0 -> 999
RTS = RTS.MidStr(ix+1)
}
ix = RTS.RT_FindStr(":")
Secs = ((ix>0) ? RTS.LeftStr(ix-1) : RTS).RevStr.RT_NumberValue
Assert(Secs < 60,RT_String("%sLine %d Invalid Seconds @'%s'",myName,i+1,S))
RTS = (ix>0) ? RTS.MidStr(ix+1) : ""
ix = RTS.RT_FindStr(":")
Mins = ((ix>0) ? RTS.LeftStr(ix-1) : RTS).RevStr.RT_NumberValue
Assert(Mins < 60,RT_String("%sLine %d Invalid Minutes @'%s'",myName,i+1,S))
RTS = (ix>0) ? RTS.MidStr(ix+1) : ""
Hrs = RTS.RevStr.RT_NumberValue
Assert(Hrs < 24,RT_String("%sLine %d Invalid Hours @'%s'",myName,i+1,S))
ChapIX = ChapIx + 1 # New Chapter
TimeS = RT_string("%02d:%02d:%02d.%03d",Hrs,Mins,Secs,MilliSecs) # Time as eg "23:59:59.987"
CHAPTER_LINE = RT_String("CHAPTER%0*d=%s",ChapIxLen,ChapIx,TimeS)
TITLE = (TITLE=="") ? RT_String("Title %0*d",ChapIxLen,ChapIx) : TITLE # Improvise TITLE if is ""
CHAPTERNAME_LINE = RT_String("CHAPTER%0*dNAME=%s",ChapIxLen,ChapIx,TITLE)
RT_DebugF("%d:%d] %s : '%s' : '%s'",i+1,ChapIx,S.RT_StrPad(48),CHAPTER_LINE,CHAPTERNAME_LINE,name=myName) # UnComment, output to DebugView
RT_WriteFile(chapfile,"%s\n%s",CHAPTER_LINE,CHAPTERNAME_LINE,Append=True)
}
}
return ChapIX # Number of Chapters written
}
Simple test client
# Import(".\ConvTxtToOggChap.avsi")
textFile = ".\SimpleTimes.txt" chapfile = ".\chapfile.txt"
textFile2 = ".\SimpleTimes_2.txt" chapfile2 = ".\chapfile_2.txt"
textFile3 = ".\SimpleTimes_3.txt" chapfile3 = ".\chapfile_3.txt"
textFile4 = ".\SimpleTimes_4.txt" chapfile4 = ".\chapfile_4.txt"
Nchaps = ConvTxtToOggChap(textfile,chapfile)
Nchaps = ConvTxtToOggChap(textfile2,chapfile2)
Nchaps = ConvTxtToOggChap(textfile3,chapfile3)
Nchaps = ConvTxtToOggChap(textfile4,chapfile4)
MessageClip("DONE")
Return last
FileSelector Client
# Import(".\ConvTxtToOggChap.avsi")
textFile = "" # Dummy
chapfile = "" # Dummy
textFile = ".\SimpleTimes.txt" # If "" then prompt for simple times text filename. ## COMMENT out to use File selector
chapfile = ".\chapfile.txt" # If "" then prompt for output chapters filename. ## COMMENT out to use File selector
TextFile = (TextFile=="") ? RT_FSelOpen("Open simple chapters",dir="",Filt="TXT Files (*.txt)|*.txt") : TextFile
chapFile = (chapFile=="") ? RT_FSelSaveAs(title="Write Ogg chapter file",Filt="TXT Files (*.txt)|*.txt",fn="chapfile.txt") : chapFile
Nchaps = ConvTxtToOggChap(textfile,chapfile)
MessageClip(String(NChaps,"Chapters written = %0.f"))
Return last
Input and results.
SimpleTimes.txt [input file]
00:00 Title 1
02:40 Title 2
09:27 Title 3
15:12 Title 4
#...
1:05:23 Title x
1:13:26 Title xx
#...
00:00. Title 7
02:40.12 Title 8
09:27.99 Title 9
15:12.71 Title 10
23:59:59.987 Title 11
# Next line HAS NO TITLE TEXT
11:10:09.876
# Next line No Hours, and no millisecs, NO TITLE TEXT
12:31
Chapfile.txt [output file]
CHAPTER01=00:00:00.000
CHAPTER01NAME=Title 1
CHAPTER02=00:02:40.000
CHAPTER02NAME=Title 2
CHAPTER03=00:09:27.000
CHAPTER03NAME=Title 3
CHAPTER04=00:15:12.000
CHAPTER04NAME=Title 4
CHAPTER05=01:05:23.000
CHAPTER05NAME=Title x
CHAPTER06=01:13:26.000
CHAPTER06NAME=Title xx
CHAPTER07=00:00:00.000
CHAPTER07NAME=Title 7
CHAPTER08=00:02:40.120
CHAPTER08NAME=Title 8
CHAPTER09=00:09:27.990
CHAPTER09NAME=Title 9
CHAPTER10=00:15:12.710
CHAPTER10NAME=Title 10
CHAPTER11=23:59:59.987
CHAPTER11NAME=Title 11
CHAPTER12=11:10:09.876
CHAPTER12NAME=Title 12
CHAPTER13=00:12:31.000
CHAPTER13NAME=Title 13
SimpleTimes_2.txt [input file]
**Example of chapters in commentaries....
*https://www.youtube.com/watch?v=I5AOg8rTGHU
00:00:00 Intro (Zu Asche, zu Staub Remix)
00:04:29 Hit Me Like A Drum
00:08:17 Clap Your Hands
00:12:18 Josephine
00:16:08 Cuba Libre
00:20:51 Catgroove
00:24:57 Berlin Shuffle / Django's Revenge
00:32:07 Speed Demon
00:41:17 Mama Talking
00:44:28 The Burning Spider
00:49:14 Invisible Girl
00:54:12 Grandpa's Groove
00:59:01 Mojo Radio Gang
01:05:18 All Night
01:12:12 Nosferatu
01:16:20 Booty Swing
01:21:20 Step Two
Chapfile_2.txt [output file]
CHAPTER01=00:00:00.000
CHAPTER01NAME=Intro (Zu Asche, zu Staub Remix)
CHAPTER02=00:04:29.000
CHAPTER02NAME=Hit Me Like A Drum
CHAPTER03=00:08:17.000
CHAPTER03NAME=Clap Your Hands
CHAPTER04=00:12:18.000
CHAPTER04NAME=Josephine
CHAPTER05=00:16:08.000
CHAPTER05NAME=Cuba Libre
CHAPTER06=00:20:51.000
CHAPTER06NAME=Catgroove
CHAPTER07=00:24:57.000
CHAPTER07NAME=Berlin Shuffle / Django's Revenge
CHAPTER08=00:32:07.000
CHAPTER08NAME=Speed Demon
CHAPTER09=00:41:17.000
CHAPTER09NAME=Mama Talking
CHAPTER10=00:44:28.000
CHAPTER10NAME=The Burning Spider
CHAPTER11=00:49:14.000
CHAPTER11NAME=Invisible Girl
CHAPTER12=00:54:12.000
CHAPTER12NAME=Grandpa's Groove
CHAPTER13=00:59:01.000
CHAPTER13NAME=Mojo Radio Gang
CHAPTER14=01:05:18.000
CHAPTER14NAME=All Night
CHAPTER15=01:12:12.000
CHAPTER15NAME=Nosferatu
CHAPTER16=01:16:20.000
CHAPTER16NAME=Booty Swing
CHAPTER17=01:21:20.000
CHAPTER17NAME=Step Two
SimpleTimes_3.txt [input file]
*https://www.youtube.com/watch?v=2loN0JFZa0Y
0:10 Gula (Deadmau5)
7:15 Rej (Âme)
13:55 Customer Is King (Solomun)
18:12 Think Twice (Henrik Schwarz/The Detroit Experiment)
24:34 Versatile (Syap)
30:42 Araya (Fatima Yamaha)
36:25 Hey Hey (Dennis Ferrer)
44:00 Wixn (Siriusmo)
46:50 You & Me (Flume/Disclosure)
52:00 Every Wall Is A Door (N'to)
59:10 The Man with the Red Face (Laurent Garnier)
1:07:56 The Drums Pt. 1 (MEUTE)
1:13:22 Kerberos (Stephan Bodzin & Marc Romboy)
1:19:40 Acamar (Frankey & Sandrino)
1:27:00 Mental Help (Gonçalo)
1:32:45 Miss You (Trentemøller)
Chapfile_3.txt [output file]
CHAPTER01=00:00:10.000
CHAPTER01NAME=Gula (Deadmau5)
CHAPTER02=00:07:15.000
CHAPTER02NAME=Rej (Âme)
CHAPTER03=00:13:55.000
CHAPTER03NAME=Customer Is King (Solomun)
CHAPTER04=00:18:12.000
CHAPTER04NAME=Think Twice (Henrik Schwarz/The Detroit Experiment)
CHAPTER05=00:24:34.000
CHAPTER05NAME=Versatile (Syap)
CHAPTER06=00:30:42.000
CHAPTER06NAME=Araya (Fatima Yamaha)
CHAPTER07=00:36:25.000
CHAPTER07NAME=Hey Hey (Dennis Ferrer)
CHAPTER08=00:44:00.000
CHAPTER08NAME=Wixn (Siriusmo)
CHAPTER09=00:46:50.000
CHAPTER09NAME=You & Me (Flume/Disclosure)
CHAPTER10=00:52:00.000
CHAPTER10NAME=Every Wall Is A Door (N'to)
CHAPTER11=00:59:10.000
CHAPTER11NAME=The Man with the Red Face (Laurent Garnier)
CHAPTER12=01:07:56.000
CHAPTER12NAME=The Drums Pt. 1 (MEUTE)
CHAPTER13=01:13:22.000
CHAPTER13NAME=Kerberos (Stephan Bodzin & Marc Romboy)
CHAPTER14=01:19:40.000
CHAPTER14NAME=Acamar (Frankey & Sandrino)
CHAPTER15=01:27:00.000
CHAPTER15NAME=Mental Help (Gonçalo)
CHAPTER16=01:32:45.000
CHAPTER16NAME=Miss You (Trentemøller)
SimpleTimes_4.txt [input file]
*https://www.youtube.com/watch?v=Ts2qNTA8i5Q
00:00 Intro
00:35 Green Sun (Theresa Zaremba)
11:00 Mosaïque Bleu (Comp.: Leonhard Kuhn / Lyrics: Patricia Römer)
18:40 AI 101 (Leonhard Kuhn)
26:00 Make Craft Perform (Leonhard Kuhn)
33:44 Der Literat (Comp.: Leonhard Kuhn / Lyrics: Hugo Ball)
43:43 Suche nach Jugend (Comp.: Leonhard Kuhn / Lyrics: Johann Wolfgang von Goethe)
53:15 Who’s Your Daddy (Leonhard Kuhn)
1:05:26 String Quartet No. 14 - Part II, Adagio (Comp.: Ludwig v. Beethoven / Arr.: Leonhard Kuhn)
1:13:10 Transformation (Comp.: Transform / Arr.: Leonhard Kuhn)
1:19:16 Back Home (Leonhard Kuhn)
1:24:52 What It Is (Leonhard Kuhn)
1:31:08 Shuffling Steps (Leonhard Kuhn)
1:41:07 Green Sun Return (Theresa Zaremba)
1:52:49 J’arrive (Stefanie Raschke / Leonhard Kuhn)
2:01:28 I Want To Be A Banana (Leonhard Kuhn)
2:13:29 Punkt und Linie zur Fläche (Leonhard Kuhn)
2:20:15 Moebius Strip (Leonhard Kuhn)
Chapfile_4.txt [output file]
CHAPTER01=00:00:00.000
CHAPTER01NAME=Intro
CHAPTER02=00:00:35.000
CHAPTER02NAME=Green Sun (Theresa Zaremba)
CHAPTER03=00:11:00.000
CHAPTER03NAME=Mosaïque Bleu (Comp.: Leonhard Kuhn / Lyrics: Patricia Römer)
CHAPTER04=00:18:40.000
CHAPTER04NAME=AI 101 (Leonhard Kuhn)
CHAPTER05=00:26:00.000
CHAPTER05NAME=Make Craft Perform (Leonhard Kuhn)
CHAPTER06=00:33:44.000
CHAPTER06NAME=Der Literat (Comp.: Leonhard Kuhn / Lyrics: Hugo Ball)
CHAPTER07=00:43:43.000
CHAPTER07NAME=Suche nach Jugend (Comp.: Leonhard Kuhn / Lyrics: Johann Wolfgang von Goethe)
CHAPTER08=00:53:15.000
CHAPTER08NAME=Who’s Your Daddy (Leonhard Kuhn)
CHAPTER09=01:05:26.000
CHAPTER09NAME=String Quartet No. 14 - Part II, Adagio (Comp.: Ludwig v. Beethoven / Arr.: Leonhard Kuhn)
CHAPTER10=01:13:10.000
CHAPTER10NAME=Transformation (Comp.: Transform / Arr.: Leonhard Kuhn)
CHAPTER11=01:19:16.000
CHAPTER11NAME=Back Home (Leonhard Kuhn)
CHAPTER12=01:24:52.000
CHAPTER12NAME=What It Is (Leonhard Kuhn)
CHAPTER13=01:31:08.000
CHAPTER13NAME=Shuffling Steps (Leonhard Kuhn)
CHAPTER14=01:41:07.000
CHAPTER14NAME=Green Sun Return (Theresa Zaremba)
CHAPTER15=01:52:49.000
CHAPTER15NAME=J’arrive (Stefanie Raschke / Leonhard Kuhn)
CHAPTER16=02:01:28.000
CHAPTER16NAME=I Want To Be A Banana (Leonhard Kuhn)
CHAPTER17=02:13:29.000
CHAPTER17NAME=Punkt und Linie zur Fläche (Leonhard Kuhn)
CHAPTER18=02:20:15.000
CHAPTER18NAME=Moebius Strip (Leonhard Kuhn)
StainlessS
1st April 2022, 14:13
hubblec4,
Can you tell me please, does Ogg/Ogm, allow a comment line preamble char ?
Maybe I'de like to allow comments pass through, eg pass through OP's original youtube URL.
Thanks in advance :)
hubblec4
1st April 2022, 17:01
Here are the specs (https://wiki.xiph.org/Chapter_Extension).
No comments are allowed if I'm right.
StainlessS
1st April 2022, 18:26
OK thanks Hubble, I'll just forget about output comments.
I've changed default ChapIxLen to 3 (was 2) ie 3 digits in chapter ID's,
ChapIxLen = Default(ChapIxLen,3) # At Least ChapIxLen digits appended to CHAPTER Times and NAME. [NO CHECK if exceeded]
Chapfile_4.txt [output file] with mod
CHAPTER001=00:00:00.000
CHAPTER001NAME=Intro
CHAPTER002=00:00:35.000
CHAPTER002NAME=Green Sun (Theresa Zaremba)
CHAPTER003=00:11:00.000
CHAPTER003NAME=Mosaïque Bleu (Comp.: Leonhard Kuhn / Lyrics: Patricia Römer)
CHAPTER004=00:18:40.000
CHAPTER004NAME=AI 101 (Leonhard Kuhn)
CHAPTER005=00:26:00.000
CHAPTER005NAME=Make Craft Perform (Leonhard Kuhn)
CHAPTER006=00:33:44.000
CHAPTER006NAME=Der Literat (Comp.: Leonhard Kuhn / Lyrics: Hugo Ball)
CHAPTER007=00:43:43.000
CHAPTER007NAME=Suche nach Jugend (Comp.: Leonhard Kuhn / Lyrics: Johann Wolfgang von Goethe)
CHAPTER008=00:53:15.000
CHAPTER008NAME=Who’s Your Daddy (Leonhard Kuhn)
CHAPTER009=01:05:26.000
CHAPTER009NAME=String Quartet No. 14 - Part II, Adagio (Comp.: Ludwig v. Beethoven / Arr.: Leonhard Kuhn)
CHAPTER010=01:13:10.000
CHAPTER010NAME=Transformation (Comp.: Transform / Arr.: Leonhard Kuhn)
CHAPTER011=01:19:16.000
CHAPTER011NAME=Back Home (Leonhard Kuhn)
CHAPTER012=01:24:52.000
CHAPTER012NAME=What It Is (Leonhard Kuhn)
CHAPTER013=01:31:08.000
CHAPTER013NAME=Shuffling Steps (Leonhard Kuhn)
CHAPTER014=01:41:07.000
CHAPTER014NAME=Green Sun Return (Theresa Zaremba)
CHAPTER015=01:52:49.000
CHAPTER015NAME=J’arrive (Stefanie Raschke / Leonhard Kuhn)
CHAPTER016=02:01:28.000
CHAPTER016NAME=I Want To Be A Banana (Leonhard Kuhn)
CHAPTER017=02:13:29.000
CHAPTER017NAME=Punkt und Linie zur Fläche (Leonhard Kuhn)
CHAPTER018=02:20:15.000
CHAPTER018NAME=Moebius Strip (Leonhard Kuhn)
According to the specs, titles should be in UTF8, my script function only handles ASCII/EXT ASCII.
hubblec4
2nd April 2022, 02:29
@HMarke
Here is a test version of cE (https://forum.videohelp.com/attachments/64101-1648862204/cE.7z) with the support for YouTube chapters from comments.
You can copy the text from a comment and insert via CTRL+V to a TreeView in the tab.(CTRL+SHIFT+V opens a new tab)
Or you can create a file and save there the text and then load the file.
HMarke
2nd April 2022, 17:22
@hubblec4 @StainlessS
Thanks for the fast and adequate help!!! both solutions work like charm for me!!!
These solutions make my life as a fan of live-music easier! :)
StainlessS
11th June 2022, 19:21
Update for ConvTxtToOggChap.avsi, supports COMMA (,) fractional time separator as well as PERIOD (.) separator.
ConvTxtToOggChap.avsi
# ConvTxtToOggChap.avsi # (c) StainlessS @ https://forum.doom9.org/showthread.php?p=1966757#post1966757
# Converts very loosely user specified times and chapter name in file, to Ogg/Ogm Chapter style in file.
# Requires AVS+, and RT_Stats v2.0 Beta13+
Function ChrIsNul(String S) {return RT_Ord(S)== 0} # End of String
Function ChrIsHash(String S) {return RT_Ord(S)==35} # #
Function ChrIsWhite(String S) {C=RT_Ord(S) return C==32||C>=8&&C<=13} # SPC, BackSPC, TAB, LF, VT, FF, CR
Function ChrIsDigit(String S) {C=RT_Ord(S) return C>=48&&C<=57}
Function ChrEatWhite(String S) {i=1 C=RT_Ord(S,i) While(C==32||C>=8&&C<=13) {i=i+1 C=RT_Ord(S,i)} return i>1?MidStr(S,i):S}
# Return extent of string S [ie length from the beginning] that matches any character in Chars set of characters [Default case insignificant]. # StrMatchChrLen("1234.567abcd","0123456789.") = 8
Function StrMatchChrLen(String s,String Chars,Bool "Sig") {
Function __StrMatchChrLen_LOW(String s,String Chars,int n) { c=s.MidStr(n+1,1) Return(c==""||Chars.FindStr(c)==0) ? n : s.__StrMatchChrLen_LOW(Chars,n+1) }
Sig=Default(Sig,False) # Default Case Insignificant
s=(Sig)?s:s.UCASE Chars=(Sig)?Chars:Chars.UCASE
__StrMatchChrLen_LOW(s,Chars,0)
}
Function ConvTxtToOggChap(String txtfile,String "chapfile",Int "ChapIxLen",String "CommentChars") {
myName = "ConvTxtToOggChap: "
Chap = Default(chapfile,"")
ChapIxLen = Default(ChapIxLen,3) # At Least ChapIxLen digits appended to CHAPTER Times and NAME. [NO CHECK if exceeded]
CommentChars=Default(CommentChars,"#*") # String of chars, any one of which will be interpreted as comment introducer.
Assert(txtfile!="",RT_String("%stxtfile path required",myName))
txtfile = txtfile.RT_GetFullPathName
Assert(Txtfile.Exist,RT_String("%stxtfile Does not Exist",myName))
Chapfile = ((chapfile=="") ? ".\OggChap.txt" : chapfile).RT_GetFullPathName # Chapfile defaults "OggChap.txt" in current directory.
Chapfile.RT_FileDelete
SIN=RT_ReadTxtFromFile(txtfile)
LINES = SIN.RT_TxtQueryLines
DIGITS = "0123456789"
TIMEALP_A = DIGITS + ":"
TIMEALP = TIMEALP_A + ".,"
ChapIX = 0
for(i=0,LINES-1){
S = SIN.RT_TxtGetLine(Line=i).ChrEatWhite.RevStr.ChrEatWhite.RevStr # Get Line of text, remove EOL and Eat leading & trailing White Space.
IsComment = CommentChars.RT_FindStr(S.LeftStr(1),sig=True)!=0
if(!S.ChrIsNul && !IsComment) { # Ignore blank lines and those beginning with Any character in CommentChars string.
MilliSecs=0 Secs=0 Mins=0 Hrs=0
Timelen=S.StrMatchChrLen(TIMEALP,sig=True) # Entire Time length
Assert(TimeLen>0,RT_String("%sLine %d Time NOT FOUND @'%s'",myName,i+1,S))
TITLE = S.MidStr(Timelen+1).ChrEatWhite # Chapter title
ST = S.Leftstr(TimeLen) # Time Only, no title
Timelen_A=ST.StrMatchChrLen(TIMEALP_A,sig=True) # Whole Part Only
SA = ST.LeftStr(Timelen_A) # Whole part string
SB = ST.MidStr(TimeLen_A+1) # Fraction Part String
Chr = SB.MidStr(1,1)
if(Chr=="." || Chr==",") { SB = SB.MidStr(2) } # Strip leading '.' or ',' ::: Remaining SB MUST be digits only or "", else error
Assert(SB.StrMatchChrLen(DIGITS,sig=True)==SB.StrLen,RT_String("%sLine %d Bad Fractional time @'%s'",myName,i+1,S))
MilliSecs = LeftStr(SB+"000",3).Eval # Optional Millsecs, As integer, 0 -> 999 [Left Aligned, ie '.5' is 0.500 seconds]
RTS = SA.RevStr
ix = RTS.RT_FindStr(":")
Secs = ((ix>0) ? RTS.LeftStr(ix-1) : RTS).RevStr.RT_NumberValue
Assert(Secs < 60,RT_String("%sLine %d Invalid Seconds @'%s'",myName,i+1,S))
RTS = (ix>0) ? RTS.MidStr(ix+1) : ""
ix = RTS.RT_FindStr(":")
Mins = ((ix>0) ? RTS.LeftStr(ix-1) : RTS).RevStr.RT_NumberValue
Assert(Mins < 60,RT_String("%sLine %d Invalid Minutes @'%s'",myName,i+1,S))
RTS = (ix>0) ? RTS.MidStr(ix+1) : ""
Hrs = RTS.RevStr.RT_NumberValue
Assert(Hrs < 24,RT_String("%sLine %d Invalid Hours @'%s'",myName,i+1,S))
ChapIX = ChapIx + 1 # New Chapter
TimeS = RT_string("%02d:%02d:%02d.%03d",Hrs,Mins,Secs,MilliSecs) # Time as eg "23:59:59.987"
CHAPTER_LINE = RT_String("CHAPTER%0*d=%s",ChapIxLen,ChapIx,TimeS)
TITLE = (TITLE=="") ? RT_String("Title %0*d",ChapIxLen,ChapIx) : TITLE # Improvise TITLE if is ""
CHAPTERNAME_LINE = RT_String("CHAPTER%0*dNAME=%s",ChapIxLen,ChapIx,TITLE)
RT_DebugF("%d:%d] %s : '%s' : '%s'",i+1,ChapIx,S.RT_StrPad(48),CHAPTER_LINE,CHAPTERNAME_LINE,name=myName) # UnComment, output to DebugView
RT_WriteFile(chapfile,"%s\n%s",CHAPTER_LINE,CHAPTERNAME_LINE,Append=True)
}
}
return ChapIX # Number of Chapters written
}
Same Client,
ConvTxtToOggChap_Client.avs
# Import(".\ConvTxtToOggChap.avsi")
textFile = ".\SimpleTimes.txt" chapfile = ".\chapfile.txt"
textFile2 = ".\SimpleTimes_2.txt" chapfile2 = ".\chapfile_2.txt"
textFile3 = ".\SimpleTimes_3.txt" chapfile3 = ".\chapfile_3.txt"
textFile4 = ".\SimpleTimes_4.txt" chapfile4 = ".\chapfile_4.txt"
Nchaps = ConvTxtToOggChap(textfile,chapfile)
#Nchaps = ConvTxtToOggChap(textfile2,chapfile2)
#Nchaps = ConvTxtToOggChap(textfile3,chapfile3)
#Nchaps = ConvTxtToOggChap(textfile4,chapfile4)
MessageClip("DONE")
Return last
Mod to one of the test input files, SimpleTimes.txt [Added comma separator] {the other test files unchanged}
SimpleTimes.txt
00:00 Title 1
02:40 Title 2
09:27 Title 3
15:12 Title 4
#...
1:05:23 Title x
1:13:26 Title xx
#...
00:00. Title 7
02:40.12 Title 8
09:27.99 Title 9
15:12.71 Title 10
# Next line has fractional seconds period separator
23:59:59.987 Title 11
# Next line HAS NO TITLE TEXT - NOTE has fractional seconds comma separator
11:10:09,876
# Next line fractional seconds comma separator, and 500 millisecs time (.500)
11:10:09,5
# Next line No Hours, and no millisecs, NO TITLE TEXT
12:31
And result ChapFile.txt
CHAPTER001=00:00:00.000
CHAPTER001NAME=Title 1
CHAPTER002=00:02:40.000
CHAPTER002NAME=Title 2
CHAPTER003=00:09:27.000
CHAPTER003NAME=Title 3
CHAPTER004=00:15:12.000
CHAPTER004NAME=Title 4
CHAPTER005=01:05:23.000
CHAPTER005NAME=Title x
CHAPTER006=01:13:26.000
CHAPTER006NAME=Title xx
CHAPTER007=00:00:00.000
CHAPTER007NAME=Title 7
CHAPTER008=00:02:40.120
CHAPTER008NAME=Title 8
CHAPTER009=00:09:27.990
CHAPTER009NAME=Title 9
CHAPTER010=00:15:12.710
CHAPTER010NAME=Title 10
CHAPTER011=23:59:59.987
CHAPTER011NAME=Title 11
CHAPTER012=11:10:09.876
CHAPTER012NAME=Title 012
CHAPTER013=11:10:09.500
CHAPTER013NAME=Title 013
CHAPTER014=00:12:31.000
CHAPTER014NAME=Title 014
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.