Go Back   The macosxhints Forums > OS X Help Requests > UNIX - Newcomers



Reply
 
Thread Tools Rate Thread Display Modes
Old 03-26-2012, 06:08 AM   #1
ricede
All Star
 
Join Date: Jul 2008
Location: India
Posts: 598
Using Perl

I have a film in Hindi, which i have been asked to show to some children here in India. The problem is they want it with english subtitles. The film came with a .sub file which isn't recognised . I have hunted for a simple way to convert this file to .srt. I have downloaded a few apps which say they can do it but with no success.

I then came across this : Sub2srt.
On the Web site it says -
Installation:
Not necessary - it's just a single perl-script.
But you may want to copy sub2srt to a directory that's in your $PATH - like /usr/local/bin or /usr/bin.



Ive downloaded & installed it, but have no idea where to go from here. If i double click it - it opens this in terminal :


Last login: Mon Mar 26 16:30:35 on ttys000
Rics-MacBook-Pro:~ Ric$ /usr/bin/sub2srt ; exit;

sub2srt [options] inputfile.sub [outputfile.srt]

Convert subrip and microdvd ".sub" subtitle files to subviewer ".srt" format
(the format accepted by ogmmerge for multiplexing into ogm files)


Options:
-h --help Display this message.
-v --version Display Program version.
-l --license Display License information.

-f=n --fps=n Fps to be used if input file is frame-based microdvd-format
Default: 25 fps. Ignored if input format is time-based.

-n --ntsc Sets the framerate to 29.97 fps. Overrides --fps.
-n2 --ntsc24 Sets the framerate to 23.976 fps. Overrides --fps and --ntsc.

--dos Create output file with DOS line end (cr+lf)
Default: unix line end (lf)

--force Overwrite existing files without prompt

-d --debug Print debug information
-q --quiet No output


inputfile.sub
Input file
Both types usally have the ending .sub, the format is autodetected.


[outputfile.srt]
Output file
Default: inputfile.srt

logout

[Process completed]


Can someone please explain ( in the simplest terms - im not very terminal knowledgable ) what i should do with the .sub file in order to change its format to .srt.

Many thanks in advance.
ricede is offline   Reply With Quote
Old 03-26-2012, 06:40 AM   #2
benwiggy
League Commissioner
 
Join Date: Aug 2006
Location: London
Posts: 5,708
What you did was to run the command (with an unnecessary exit command afterwards) without specifying any parameters -- including the filename of the source file.
What that did was to show you the help documentation on how to use the file.

So you need to type:
Code:
sub2srt
then on the same line, any options you want, as in the help
then the filepath of your source file, which you can get by dropping the file onto the Terminal window. Terminal will add the full filepath of that file to the current line.

The output file will be created in the same folder as the source file; or you can specify another folder path and filename.
benwiggy is offline   Reply With Quote
Old 03-26-2012, 06:59 AM   #3
ricede
All Star
 
Join Date: Jul 2008
Location: India
Posts: 598
Thanks for the explanation benwiggy.
Unfortunately when ran it - it gave the message - Could not detect /Users/Ric/Movies/Movies/Dance Of The Wind/Dance Of The Wind.sub format! which might explain why ive been having so much trouble with this. As a .srt subtitle is not available in english on the Internet i shall just have to let go of it. Shame.
ricede is offline   Reply With Quote
Old 03-26-2012, 07:40 AM   #4
acme.mail.order
League Commissioner
 
Join Date: Sep 2003
Location: Tokyo
Posts: 6,299
You have downloaded a unix shell script, which is:

a) completely ignorant of the Mac Desktop
b) very simple to use
c) very picky about how it is used.

Yes, b and c seem to conflict.

Do the following, EXACTLY as described. Any deviations will result in failure.

- close all applications and open windows

- open a new Finder window, containing the .sub file you want to convert

- drag the .sub file to the Desktop, make a note of it's name

- rename it subtitles.sub

- open Applications -> Utilities -> Terminal

- In the Terminal window, copy/paste the following:

cd ~/Desktop ; sub2srt subtitles.sub

then press Return.

- wait, maybe 1-2 seconds. No response other than a new prompt line means it's good.

- Check the desktop for a new .srt file. Rename it with the original name plus the .srt extension, and put it back in the correct folder.
acme.mail.order is offline   Reply With Quote
Old 03-26-2012, 08:03 AM   #5
ricede
All Star
 
Join Date: Jul 2008
Location: India
Posts: 598
Thanks acme.mail.order
Sadly i have had the same result as with benwiggy's post.
Again it says - could not detect .sub format.
It must be a weird format that is unreadable, or otherwise corrupt.
I have spent 4 hours trying to sort this today & must admit defeat as i know not where to go from here.

At least ive learnt something today about terminal, which is great.
Thanks to you all anyway.
ricede is offline   Reply With Quote
Old 03-26-2012, 08:10 AM   #6
acme.mail.order
League Commissioner
 
Join Date: Sep 2003
Location: Tokyo
Posts: 6,299
Copy / paste the entire terminal session here.
acme.mail.order is offline   Reply With Quote
Old 03-26-2012, 08:13 AM   #7
ricede
All Star
 
Join Date: Jul 2008
Location: India
Posts: 598
Last login: Mon Mar 26 18:28:17 on ttys000
Rics-MacBook-Pro:~ Ric$ cd ~/Desktop ; sub2srt ~/Desktop/subtitles.sub
Could not detect /Users/Ric/Desktop/subtitles.sub format!
Rics-MacBook-Proesktop Ric$
ricede is offline   Reply With Quote
Old 03-26-2012, 08:16 AM   #8
acme.mail.order
League Commissioner
 
Join Date: Sep 2003
Location: Tokyo
Posts: 6,299
do this (in the terminal) and paste the results here:

cd ~/Desktop ; file *
acme.mail.order is offline   Reply With Quote
Old 03-26-2012, 08:18 AM   #9
ricede
All Star
 
Join Date: Jul 2008
Location: India
Posts: 598
Last login: Mon Mar 26 18:42:02 on ttys000
Rics-MacBook-Pro:~ Ric$ cd ~/Desktop ; file *
: empty
subtitles.sub: MPEG sequence, v2, program multiplex
Rics-MacBook-Proesktop Ric$
ricede is offline   Reply With Quote
Old 03-26-2012, 08:19 AM   #10
acme.mail.order
League Commissioner
 
Join Date: Sep 2003
Location: Tokyo
Posts: 6,299
Looks odd. Lets see this:

ls -lO ~/Desktop/
acme.mail.order is offline   Reply With Quote
Old 03-26-2012, 08:22 AM   #11
ricede
All Star
 
Join Date: Jul 2008
Location: India
Posts: 598
Last login: Mon Mar 26 18:47:51 on ttys000
Rics-MacBook-Pro:~ Ric$ ls -lO ~/Desktop/
total 4768
-rw-r--r--@ 1 Ric staff hidden 0 14 Mar 16:50 Icon?
-rw-r--r-- 1 Ric staff - 2437120 26 Mar 16:11 subtitles.sub
Rics-MacBook-Pro:~ Ric$
ricede is offline   Reply With Quote
Old 03-26-2012, 08:26 AM   #12
acme.mail.order
League Commissioner
 
Join Date: Sep 2003
Location: Tokyo
Posts: 6,299
That's a rather large subtitle file - you might not have the correct file, or it's in a different .sub format (the "MPEG sequence" is the odd part, most subtitle formats come up as text).

On the plus side, you are doing everything right. It's the file that is not cooperating.
acme.mail.order is offline   Reply With Quote
Old 03-26-2012, 08:31 AM   #13
ricede
All Star
 
Join Date: Jul 2008
Location: India
Posts: 598
Yeah - its 2.4 mb - i thought that was strange. A friend gave me the movie to show to these kids. Its a folder with both the avi file & the .sub.

Ive trawled all the sites on google looking for a .srt file but to no avail. Its only available in Romanian !!!!!
ricede is offline   Reply With Quote
Old 03-26-2012, 09:04 AM   #14
benwiggy
League Commissioner
 
Join Date: Aug 2006
Location: London
Posts: 5,708
If the .sub file is expected to be in text, it might be worth opening it in TextWrangler or some other texteditor, and see what it is made of.
It may be that the relevant text is a portion of this larger file, and you can cut and paste it out.
benwiggy is offline   Reply With Quote
Old 03-26-2012, 09:11 AM   #15
ricede
All Star
 
Join Date: Jul 2008
Location: India
Posts: 598
The contents are Gobbledy Gook to me. Heres the first few lines :

∫DF%q√Ω!S=`:!

<H3ArAqG41rArsAxqrAtp8Ω∞@[ 9k$[Ω b≥€,≥ €Ω≤ ik$∂=∏ΩM∞8Ω≥iik<Ω#≠k∂€VqK€m6Ω70Ω#a[€Ω≤Kig$v€K”|[Ω/“p8Ω≥igig<ΩmGigigΩigΩ∏Ωm∏Ω∞\ΩmΩ€(Ω€€8ΩigΩ€8Ω≥fl€8Ω≤ ikfl€Ωv∏Ω∏Ωo“€$v€Ω≤mK|Ω/Ωv∏Ω€8Ω≥K€K€4Ω≤K€€K€Ω˝Ω∂q9≥ €$Ω€Ω≤ikik9Ω˝Ω€8Ω≥ iik0Ω≤K€KiavΩ—=Ob 9≥

From past experience all subtitle files are just the line time in hrs/mins/secs and then the text.
There doesn't seem to be any english text in here at all !!!!!!!
ricede is offline   Reply With Quote
Old 03-26-2012, 11:51 AM   #16
fracai
MVP
 
Join Date: May 2004
Posts: 2,084
Some subs are distributed as pre-rendered images that are overlayed on the movie when played back.

See the Types section on the wiki article. The following section on formats should also be helpful.

It sounds like what you have is a "VobSub".

You may want to try posting at lesat the sub files you have. Someone else may have more luck converting them to another format.

Where did the movie originally come from? That's probably a better bet for tracking down a useable subtitle in english.
fracai is offline   Reply With Quote
Old 03-26-2012, 12:40 PM   #17
ricede
All Star
 
Join Date: Jul 2008
Location: India
Posts: 598
VobSub sounds about right - fracai. The avi movie was packaged with a .sub & .idx file.

Ive just been trying different words in google & came upon a suggestion to use mplayer.
IT WORKS . Somehow it reads both the sub & the idx files. Brilliant .
The kids will be happy.

Thanks all for your imput. Its always such a pleasure to use this forum.
ricede is offline   Reply With Quote
Old 03-26-2012, 12:59 PM   #18
fracai
MVP
 
Join Date: May 2004
Posts: 2,084
If you need to, you should be able to use mplayer / mencode to "burn" the subtitles into the movie. You'd be able to pick the encoding format and play it on your desired device. Handbrake may also be an option if you need it on an iOS device (including Apple TV).
fracai is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 06:28 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.