# Batch extract srt from multiple Mkv's?

1. Here we go again

Code:
dyld: Library not loaded: /opt/local/lib/libintl.8.dylib
Referenced from: /Applications/MkvExtractor.app/Contents/MacOS/mkvextract
Trace/BPT trap: 5
2. attached libintl.8.dylib
3. Hi,

Here is the next one:

Code:
dyld: Library not loaded: /opt/local/lib/libboost_regex-mt.dylib
Referenced from: /Applications/MkvExtractor.app/Contents/MacOS/mkvextract
Trace/BPT trap: 5
Thnx
4. have to look for that one
5. No problem.
6. So you have XCode installed?

Do you only need it when you plan to make apps? or do you also need it for running apps that other people created?

I ask this cause when I run: "sudo port install mkvtoolnix" I get the following message:
Code:
Warning: xcodebuild exists but failed to execute
Warning: Xcode does not appear to be installed; most ports will likely fail to build.
So it seems you need XCode to be able install mkvtoolnix.
When I google XCode, I read it's a huge file (several GB's) and I need an Apple ID to be able install it. (but with credit card information)
I'm not sure if I can download it for free or if they will charge 99 dollars after all. I hate to give my credit card information when it supposedly free.

How did you do it?
7. yep, I got xcode installed, it's the easiest way to get a gcc environment on mac osx.
for leopard is was free, for snow leopard it cost 5$, for lion it's free again attached libboost,.. 8. So even if I enter my credit card information they won't bill me now (or in the future) for downloading XCode? I'm on Lion so it should be free like you said right? I'm just afraid I will get a bill in the future. I suppose you had to fill it in as well? 9. Thanks for the dylib. Next it asks is the following: Code: dyld: Library not loaded: /opt/local/lib/libboost_filesystem-mt.dylib Thanks 10. yup, I hope so, at least they never billed my for anything that I did not explicitly buy. -> https://developer.apple.com/xcode/ 11. I deleted the previous text here. I thought it was the same file but it isn't It's a different file Code: dyld: Library not loaded: /opt/local/lib/libboost_system-mt.dylib Referenced from: /Applications/MkvExtractor.app/Contents/MacOS/mkvextract Reason: image not found Trace/BPT trap: 5 it's libboost_system-mt.dylib and I thought it was like the previous one which was filesystem 12. attached 13. Code: dyld: Library not loaded: /opt/local/lib/libicuuc.48.dylib Thnx 14. libicuuc.48.dylib attached 15. Code: dyld: Library not loaded: /opt/local/lib/libicui18n.48.dylib Referenced from: /opt/local/lib/libboost_regex-mt.dylib Reason: image not found Trace/BPT trap: 5 Thnx again 16. attached,... 17. Code: dyld: Library not loaded: /opt/local/lib/libicudata.48.dylib Arigato 18. No problemo attached the file 19. Yeah!!! It worked: Code: Extracting track 1 with the CodecID 'V_MPEG4/ISO/AVC' to the file '/Users/SG/Movies/new/test_1.264'. Container format: raw data Extracting track 2 with the CodecID 'A_AAC' to the file '/Users/SG/Movies/new/test_2.aac'. Container format: raw AAC file with ADTS headers Extracting track 3 with the CodecID 'S_TEXT/ASS' to the file '/Users/SG/Movies/new/test_3.ass'. Container format: SSA/ASS text subtitles Progress: 100% I'm using the following code you gave me: Code: "/Applications/MkvExtractor.app/Contents/MacOS/mkvextract" tracks "/Users/SG/Movies/test.mkv" --ui-language en_US --raw 1:"/Users/SG/Movies/new/test_1.264" 2:"/Users/SG/Movies/new/test_2.aac" 3:"/Users/SG/Movies/new/test_3.ass" 1) Can I shorten it to just extract subtitles and without the video and audio. 2) Since I'm going to use my Samsung TV I would use srt. Is it possible to save them straight away as srt instead of ass? I'm so happy Thanks thnx!!! 20. not at the moment, I can probably write some basic ass to .srt conversion code, but you will loose some of the styling since .ass allows far more than .srt in regards of styling&co,... will look at it tomorrow if it's worth the effort for you,... btw. could you lost a list with all the libs? 21. With the terminal I can do it with: Code: "/Applications/MkvExtractor.app/Contents/MacOS/mkvextract" tracks "/Users/SG/Movies/test.mkv" --ui-language en_US 3:"/Users/SG/Movies/new/test_3b.srt" I just removed "--raw". Maybe for in your app you could have a radio button to choose between SRT and ASS. Here is the list of dylib's: Code: libboost_filesystem-mt.dylib libicuuc.48.dylib libboost_regex-mt.dylib libintl.8.dylib libboost_system-mt.dylib liblzo2.2.dylib libiconv.2.dylib libmagic.1.dylib libicudata.48.dylib libogg.0.dylib libicui18n.48.dylib libvorbis.0.dylib It would be nice to have it as your app but if you know how to do it in with the command line, it's ok too. As long as I can do extract it multiple files at once, it's all good I googled and found this, but I'm sure you know better how to do it. Code:  for mkv_files in *.mkv; do mkvextract tracks "${mkv_files}" 2:"${mkv_files}.ac3"; done I haven't written a script before, just so you know I will look up if Samsung TV Media player recognizes ass filles. I didn't know that ass subs are better than srt. Thanks a lot. 22. Ooh maybe this is what you mean about loosing some styles. But I remember know when I use iMkvExtract which only allowed me to extract one file at a time that the file generated didn't work on my TV. I had to remove the lines that started with COMMENTS I don't know why. Here is an example: [Script Info] ; Script generated by Aegisub 2.1.8 ; http://www.aegisub.org/ Title: Default Aegisub file ScriptType: v4.00+ WrapStyle: 3 PlayResX: 1280 PlayResY: 720 ScaledBorderAndShadow: yes Last Style Storage: Default Video Aspect Ratio: 0 Video Zoom: 6 Video Position: 0 Collisions: Normal Video Zoom Percent: 0.500000 [V4+ Styles] Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding Style: Default,Cambria,45,&H00FFFFFF,&H000000FF,&H0000000 0,&H00000000,0,0,0,0,100,100,0,0,1,2.2,0,2,100,100 ,50,1 Style: Sign,Arno Pro,120,&H00FFFFFF,&H000000FF,&H00000000,&H0000000 0,0,0,0,0,100,100,0,0,1,0,2,2,20,20,15,1 Style: Sign2,Apple Garamond,100,&H00FFFFFF,&H000000FF,&H00000000,&H00 000000,-1,0,0,0,100,100,0,0,1,0,2,2,20,20,15,1 Style: Title,Salernomi J,80,&H00FDE2E2,&H000000FF,&H00000000,&H00000000,-1,0,0,0,100,100,0,0,1,0,0,8,10,10,10,1 Style: ED,Salernomi J,40,&H00FEF4F4,&H000000FF,&H00962719,&H00000000,0 ,0,0,0,100,100,0,0,1,2,0,8,10,10,10,1 Style: EDrom,Salernomi J,40,&H00FEF4F4,&H000000FF,&H00761809,&H00000000,-1,0,0,0,100,100,0,0,1,2,0,2,10,10,3,1 Style: OPromaji,Salernomi J,45,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,-1,0,0,0,100,100,0,0,1,2.5,0,2,20,20,3,1 Style: OP,Salernomi J,45,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0 ,0,0,0,100,100,0,0,1,2.5,0,8,20,20,15,1 Style: moeshiba,SF Wonder Comic,54,&H00FFFFFF,&HFFFFFFFF,&HFFFFFFFF,&H960000 00,0,0,0,0,100,100,0,0,1,4.5,0,2,20,20,30,1 Style: Mameshiba,Coaster,78,&H00000000,&H000000FF,&H00FFF FFF,&H00000000,0,0,0,0,100,100,0,0,1,1.5,0,2,20,20 ,15,1 Style: Mameshiba small,Coaster,48,&H00242B2F,&H000000FF,&H00000000, &H00000000,0,0,0,0,100,100,0,0,1,0,0,2,20,20,15 ,1 Style: Love,Komika Boo,54,&H009CB2DC,&H000000FF,&H00000000,&H00000000 ,0,0,0,0,100,100,0,0,1,0,0,2,20,20,15,1 Style: moeshiba1,Coaster,63,&H00FFFFFF,&H000000FF,&H00E8B 574,&H96000000,0,0,0,0,100,100,0,0,1,3,1.5,8,20,20 ,30,1 Style: Sign3,Corporate Rounded,30,&H00B8B7AD,&H000000FF,&H00000000,&H0000 0000,0,0,0,0,100,100,0,0,1,0,0,2,20,20,15,1 Style: Sign4,EraserDust,60,&H00D9DBD0,&H000000FF,&H000000 00,&H00000000,0,0,0,0,100,100,0,0,1,0,0,2,20,20,15 ,1 [Events] Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text Comment: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,-OP- Comment: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,-ED- Dialogue: 0,0:00:05.36,0:00:06.15,Default,,0000,0000,0000,,F irst line of subtitle So the top part is working and it seems that the COMMENT part is a problem. I just tested it again and as soon as I remove the 2 following lines it works: Code: Comment: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,-OP- Comment: 0,0:00:00.00,0:00:00.00,Default,,0000,0000,0000,,-ED- But I'm not sure if mkvextract can erase all lines that start with COMMENT: I can always do it afterwards with something like this: Code: sed '/^\Comment:/d' test_3.srt > temp.srt mv temp.srt test_3.srt I just found this by googling. I'm no expert in linux commands If I would do it afterwards I need to figure out how to do it for all the files of course Edit: I found the following code which might work. But I'll have to try it with the srt's and I first need to learn how to make a small script(file). Code: foreach file (*dat) sed '/^\#/d'$file > tt
mv tt $file end Greets 23. small script,.. much luck Problem is to know what sort of styling the player supports, simple srt has no styling in any way So you would have to remove all the styling, effects, font references, etc. so something like: Code: [Script Info] ; Script generated by Aegisub 2.1.8 ; http://www.aegisub.org/ Title: Default Aegisub file ScriptType: v4.00+ WrapStyle: 0 PlayResX: 1920 PlayResY: 1080 ScaledBorderAndShadow: yes Video Aspect Ratio: 0 Video Zoom: 3 Video Position: 4184 Last Style Storage: VCS Audio File: ?video Video File: vcs 00 wraw.avi [V4+ Styles] Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding Style: Credits,Freestyle Script,70,&H00B0D8F4,&H000000FF,&H004FB9FD,&H00000000,0,0,0,0,100,100,0,0,1,1.25,0,2,30,30,23,1 Style: Default,Aardvark Cafe,65,&H00D8E2F0,&H000C90DC,&H0010283B,&H00D8E2F0,-1,0,0,0,100,100,0,0,1,3.375,1.35,2,30,30,56,1 [Events] Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text Comment: 0,0:02:46.54,0:02:49.54,Copy of Signs,,0000,0000,0000,,{\an8}20XX Nationwide Roadshow\NEdy Nelson Homer Peron {repeats their names again a bunch} Evans Records Evans {cant make out this one} Evans Studios\NYui Kano & Umeka Susie "Twin Tails {star} I Love You!?" (Evans Records)\NGallia Maneko {can't make out rest}\NEvans {?} Dialogue: 0,0:00:42.65,0:00:43.64,Default,,0000,0000,0000,,VERSTANDEN? Dialogue: 0,0:00:43.64,0:00:44.12,Default,,0000,0000,0000,,Yeah... Dialogue: 0,0:02:41.78,0:02:46.52,Credits,,0000,0000,0000,,{\an1\fad(0,0)}Übersetzer: Loxagon\NQC: Yuuzie\NEncode: Springlove Dialogue: 0,0:02:42.78,0:02:46.52,Credits,,0000,0000,0000,,{\alpha&H00&\an7}Wer hat's gemacht?\N{\alpha&Hff&\t(2360,2360,\alpha&H00&)}Loxagon-sub for the simplest approach one neeeds to: 1. drop all lines that do not start with 'Dialogue' 2. drop all the styling 3. joining all the stuff that overlaps time wise (otherwise some stuff standalone players will probably a ignore one of the subtitles or switch from one to the next really fast 4. change the general composition and way the subtitles are written 5. make sure the output is ANSI or UTF-8 compatible, most hardware players will ignore anything else so a simple representation of the one above would be Code: 00:00:42,650 --> 00:00:43,6400 VERSTANDEN? 00:00:43,640 --> 00:00:44,120 Yeah... 00:02:41,780 --> 00:02:46,520 Übersetzer: Loxagon QC: Yuuzie Encode: Springlove Wer hat's gemacht? Loxagon-sub depending on the player you can convert • 'i1' to '<i>' and 'i0' to '</i>' • 'b1' to '<b>' and 'b0' to '</b>' • 'u1' to '<u>' and 'u0' to '</u>' • 's1' to '<s>' and 's0' to'</s>' instead of dropping all styling,.. so I don't think a small script will really work,... -> http://doom10.org/index.php?topic=916.0 There's an online ass to srt converted which does: 1. drop all lines that do not start with 'Dialogue' 2. dropp all the styling it doesn't look at the overlapping&co Cu Selur 24. Very interesting what you wrote. I will have to read it again. (I just woke up so my brains are still half asleep) I'm lucky that my Samsung TV plays the SRT, although the styling is not shown but that is ok for me. As long as I can see the subtitles The only thin I need to remove is the COMMENT line and I can do it with a script. So for me your script through command line in terminal works which is fantastic but this is for one file. 1 A) Can you help me changing the script in terminal so that it works for all files in a certain directory? OR 1 B) add in your app a radio button so I can choose SRT or ASS? So when SRT is choosen don't forget to remove "--raw". Then I can choose SRT Then I only need to make a script to remove the "COMMENT:" and I can start watching So I think I will be able to do that myself with the code in the previous post. Unless you can integrate the code in the app so that all lines will automatically be deleted that starts with COMMENT: But like I said I'm happy that it almost works. I will look at some tutorials right now to learn how to do 1A with a bash script myself too. That way I learn a bit bash scripting. EDIT: I forgot to thank for all the help up until now. I really appreciate it!!!!!!! 25. something like: Code: for file in *; do ... done might work,.. 26. Hi, This is the complete script I use and it works!!!!!! Code: for mkv_files in *.mkv; do "/Applications/MkvExtractor.app/Contents/MacOS/mkvextract" tracks "${mkv_files}" 3:"${mkv_files%.*}.srt"; done for srt_files in *.srt; do sed '/^\Comment:/d' "${srt_files}" > temp.srt;
mv temp.srt "\${srt_files}";
done
echo -e "\nSrt's extracted and Comment lines removed!";
I'm just not sure if those ";" are necesarry?

THANK YOU SO MUCH FOR ALL THE HELP!!!!
It would never have worked without you.

A small question.
SRT do not need anything before DIALOGUE?
So I can delete everything under SCRIPT INFO, V4+ STYLES and EVENTS?
27. SRT do not need anything before DIALOGUE?
So I can delete everything under SCRIPT INFO, V4+ STYLES and EVENTS?
yup, srt are really simple:
https://en.wikipedia.org/wiki/SubRip#SubRip_.srt_file_example
28. Ok.
What I find strange is that they say that srt looks like this:

Code:
1 00:00:20,000 --> 00:00:24,400 Altocumulus clouds occur between six thousand
2 00:00:24,600 --> 00:00:27,800 and twenty thousand feet above ground level.

But the file I have looks like this and it works as well:

Code:
Dialogue: 0,0:00:05.36,0:00:06.15,Default,,0000,0000,0000,,Altocumulus clouds occur between six thousand
Dialogue: 0,0:00:07.13,0:00:10.65,Default,,0000,0000,0000,,and twenty thousand feet above ground level.
I guess I shouldn't complain
29. nope, you shouldn't,..
Maybe the TV even supports .ass in a restricted way and if you write to the Samsung TV Support they can shed some light on it.
What I find strange is that they say that srt looks like this..
That is wrong! For .srt there needs to be a line feed between the times and the text, so it needs to look like:
Code:
00:00:20,000 --> 00:00:24,400
Altocumulus clouds occur between six thousand
Cu Selur
30. Attached an overworked MkvExtractor, that:
a. does not require the dynamic libraries (bundles the complete Mkvtoolnix 5.5.0)
b. can extract audio and/or video and/or subtitles
c. can do a basic ass to srt convertion; it does not check the overlapping of the start/end times, but it does remove all the styling and add a proper srt compliant formating of the lines.

Cu Selur

Statistics