subtitle_converter 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 685a9eaefbcb8091dba91d86aa9909b9f38fa2bc
4
+ data.tar.gz: f8ee8b7c0be0be9dd4d0d19bed3f4e2983428ccf
5
+ SHA512:
6
+ metadata.gz: c329fee4d3006fe70bab24dc85725b3fc41cf55647deb6f9970d539a7ebb07dfd6a417ecf1037f3693997ea402aee2fc885478a7c681e9d6f902b42c1fe2236c
7
+ data.tar.gz: 1d8719e7c9e2ad734d13acb21cd44400f5df6dac1449df818bce61eeccd68d26a9f2f32247c650535b5504f108a1906cac318281543307390ae343b490064a9d
data/README.md ADDED
@@ -0,0 +1,17 @@
1
+ subtitle_converter
2
+ ==================
3
+
4
+ If you have a movie, then sometimes it comes with a subtitle file. However, there are several formats of subtitle files. We subtitle movies we use in training and usually we use Final Cut for that and they produce a movie file like the one attached, which is in STL format.
5
+
6
+ However, if you attach subtitle to a mkv file, then the format that is required is SRT. They are quite different, but the type of information is same (similar)
7
+
8
+ STL file format:
9
+ http://documentation.apple.com/en/dvdstudiopro/usermanual/index.html#chapter=19%26section=13%26tasks=true
10
+
11
+ SRT file format:
12
+ http://wiki.videolan.org/SubRip
13
+
14
+
15
+ *** Installation
16
+
17
+ gem install subtitle_convertor
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env rake
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,126 @@
1
+ 1
2
+ 2
3
+ 3
4
+ 4
5
+ 5
6
+ 6
7
+ 7
8
+ 8
9
+ 9
10
+ 10
11
+ 11
12
+ 12
13
+ 13
14
+ 14
15
+ 15
16
+ 16
17
+ 17
18
+ 18
19
+ 19
20
+ 20
21
+ 21
22
+ 22
23
+ 23
24
+ 24
25
+ 25
26
+ 26
27
+ 27
28
+ 28
29
+ 29
30
+ 30
31
+ 31
32
+ 32
33
+ 33
34
+ 34
35
+ 35
36
+ 36
37
+ 37
38
+ 38
39
+ 39
40
+ 40
41
+ 41
42
+ 42
43
+ 43
44
+ 44
45
+ 45
46
+ 46
47
+ 47
48
+ 48
49
+ 49
50
+ 50
51
+ 51
52
+ 52
53
+ 53
54
+ 54
55
+ 55
56
+ 56
57
+ 57
58
+ 58
59
+ 59
60
+ 60
61
+ 61
62
+ 62
63
+ 63
64
+ 64
65
+ 65
66
+ 66
67
+ 67
68
+ 68
69
+ 69
70
+ 70
71
+ 71
72
+ 72
73
+ 73
74
+ 74
75
+ 75
76
+ 76
77
+ 77
78
+ 78
79
+ 79
80
+ 80
81
+ 81
82
+ 82
83
+ 83
84
+ 84
85
+ 85
86
+ 86
87
+ 87
88
+ 88
89
+ 89
90
+ 90
91
+ 91
92
+ 92
93
+ 93
94
+ 94
95
+ 95
96
+ 96
97
+ 97
98
+ 98
99
+ 99
100
+ 100
101
+ 101
102
+ 102
103
+ 103
104
+ 104
105
+ 105
106
+ 106
107
+ 107
108
+ 108
109
+ 109
110
+ 110
111
+ 111
112
+ 112
113
+ 113
114
+ 114
115
+ 115
116
+ 116
117
+ 117
118
+ 118
119
+ 119
120
+ 120
121
+ 121
122
+ 122
123
+ 123
124
+ 124
125
+ 125
126
+ 126
@@ -0,0 +1,154 @@
1
+ $FontName = Arial
2
+ $FontSize = 30
3
+ $HorzAlign = Center // Left or Right
4
+ $VertAlign = Bottom // Top or Center
5
+ $Bold = TRUE
6
+ $UnderLined = FALSE
7
+ $Italic = FALSE
8
+ $XOffset = 0 // Pixel offset (can be negative)
9
+ $YOffset = 0 // Pixel offset (can be negative)
10
+ $TextContrast = 10
11
+ $Outline1Contrast = 15
12
+ $Outline2Contrast = 7
13
+ $BackgroundContrast = 0
14
+ $ForceDisplay = TRUE // DVD Force Display Flag
15
+ $FadeIn = 0 // In number of Frames
16
+ $Fadeout = 0 // In number of Frames
17
+
18
+ $TapeOffset = TRUE
19
+
20
+ 00:00:03:15 , 00:00:05:26 , Tonight, The Deep Dive.
21
+ 00:00:05:27 , 00:00:10:01 , One company's secret weapon for innovation
22
+ 00:00:22:28 , 00:00:26:12 , We went to IDEO, the product design folk
23
+ 00:00:26:13 , 00:00:30:08 , and said take something old and familiar like, say, the shopping cart
24
+ 00:00:30:09 , 00:00:34:10 , and completely redesign it for us in just 5 days
25
+ 00:00:34:11 , 00:00:39:28 , ABC News correspondent Jack Smith tells us what happened next
26
+ 00:00:41:00 , 00:00:45:03 , 9 in the morning, day one and these people have a deadline to meet
27
+ 00:00:45:05 , 00:00:49:15 , So welcome to the kickoff of the shopping cart project
28
+ 00:00:49:17 , 00:00:52:29 , This is Palo Alto, California, in the heart of Silicon Valley
29
+ 00:00:53:00 , 00:00:55:17 , and these are designers at IDEO
30
+ 00:00:55:18 , 00:00:59:12 , probably the most influential product development firm in the world
31
+ 00:00:59:13 , 00:01:03:16 , IDEO has designed everything from high tech medical equipment
32
+ 00:01:03:17 , 00:01:06:25 , to the 25-foot mechanical whale in the movie, free Willy
33
+ 00:01:06:26 , 00:01:10:02 , and the first computer mouse for Apple, Smith ski goggles,
34
+ 00:01:10:03 , 00:01:15:18 , Nike sunglasses, NEC computer screens, hundreds of products we take for granted
35
+ 00:01:15:20 , 00:01:21:09 , The point is that we are not actually experts at any given area
36
+ 00:01:21:10 , 00:01:24:13 , We are kind of experts on the process of how you design stuff
37
+ 00:01:24:14 , 00:01:26:10 , So we don't care if you give us a toothbrush
38
+ 00:01:26:11 , 00:01:27:20 , a toothpaste tube
39
+ 00:01:27:21 , 00:01:29:15 , a tractor, a space shuttle
40
+ 00:01:29:16 , 00:01:31:02 , you know, a chair
41
+ 00:01:31:03 , 00:01:32:05 , It's all the same to us
42
+ 00:01:32:06 , 00:01:37:08 , We like want to figure out how to innovate and by using our process applying it
43
+ 00:01:37:09 , 00:01:41:06 , Project leader is Peter Skillman, a 35 year old Stanford engineer
44
+ 00:01:41:07 , 00:01:45:11 , project leader because he's good with groups,not because of seniority
45
+ 00:01:45:12 , 00:01:47:08 , He's only been at IDEO for 6 years.
46
+ 00:01:47:09 , 00:01:50:25 , The rest of the team is electric, but that's typical here
47
+ 00:01:50:26 , 00:01:53:01 , Whitney Mortimer, Harvard MBA
48
+ 00:01:53:02 , 00:01:55:05 , Peter Coughlan, linguist
49
+ 00:01:55:06 , 00:01:58:06 , Tom Kelly, Dave's brother, marketing expert
50
+ 00:01:58:07 , 00:02:00:18 , Jane Fulton-Suri, psychologist
51
+ 00:02:00:19 , 00:02:06:14 , Alex Kazaks,26, a biology major who's turned down medical school 3 times
52
+ 00:02:06:15 , 00:02:08:25 , because he's having too much fun at IDEO
53
+ 00:02:08:27 , 00:02:11:28 , Safety emerges early as an important issue
54
+ 00:02:11:29 , 00:02:17:22 , 22 thousand child injuries a year, which is-- so they're hospitalized injuries.
55
+ 00:02:17:23 , 00:02:19:08 , I mean there are many others
56
+ 00:02:19:09 , 00:02:22:25 , And theft. It turns out a lot of carts are stolen
57
+ 00:02:22:26 , 00:02:27:18 , As the team works, it becomes clear there are no titles here, no permanent assignments
58
+ 00:02:27:19 , 00:02:31:13 , And the other side says, give us a lot of help, be safe
59
+ 00:02:32:29 , 00:02:36:11 , I'll give you a big red ball on a post
60
+ 00:02:36:12 , 00:02:37:13 , and that says you're a big guy
61
+ 00:02:37:14 , 00:02:39:17 , If you've got a ball you're a senior vice president
62
+ 00:02:39:18 , 00:02:40:29 , you know, what do I care?
63
+ 00:02:41:00 , 00:02:42:22 , Or the desk, red ball, it's all the same
64
+ 00:02:42:24 , 00:02:48:02 , In a very innovative culture you can't have a kind of hierarchy of
65
+ 00:02:48:03 , 00:02:50:18 , here's the boss and the next person down and the next person down
66
+ 00:02:50:19 , 00:02:53:08 , and the next person down because it's impossible that
67
+ 00:02:53:09 , 00:02:57:04 , the boss is the one who's had the insightful experience with shopping carts.
68
+ 00:02:57:05 , 00:02:58:00 , It's just not possible
69
+ 00:02:58:01 , 00:03:02:17 , The team spreads into groups to find out firsthand what the people who use
70
+ 00:03:02:18 , 00:03:04:29 , make and repair shopping carts really think
71
+ 00:03:05:00 , 00:03:06:17 , Ok, go
72
+ 00:03:06:18 , 00:03:08:13 , The problem with plastic cart is the wind catches it and
73
+ 00:03:08:14 , 00:03:11:22 , these things have been clocked at 35 across the parking lot
74
+ 00:03:11:23 , 00:03:14:25 , Oh,man, that's actually a pretty good point.
75
+ 00:03:14:26 , 00:03:20:01 , The trick is to find these real experts so that you can learn much more quickly than you
76
+ 00:03:20:02 , 00:03:22:12 , could by just kind of doing it in the normal way
77
+ 00:03:22:13 , 00:03:24:06 , and trying to learn about it yourself
78
+ 00:03:24:07 , 00:03:26:24 , From everything I read these things aren't that safe either
79
+ 00:03:26:25 , 00:03:32:07 , you know, so probably the seat itself is going to have to be redesigned
80
+ 00:03:32:08 , 00:03:36:16 , One of the interesting things for me is looking at how people really don't like to let go of the cart
81
+ 00:03:36:17 , 00:03:38:04 , except for the professional shopper
82
+ 00:03:38:05 , 00:03:41:05 , whose strategy is to leave the cart at various places
83
+ 00:03:41:06 , 00:03:44:21 , Three thirty in the afternoon and the group is back at IDEO
84
+ 00:03:44:22 , 00:03:46:15 , There is no let up
85
+ 00:03:46:16 , 00:03:52:10 , Each team is going to demonstrate and communicate and share everything that they've learned today
86
+ 00:03:52:11 , 00:03:58:07 , A shopping cart has been clocked at 35 miles an hour traveling through a parking lot in the wind
87
+ 00:03:58:08 , 00:03:59:06 , We were in the store, what
88
+ 00:03:59:07 , 00:04:03:17 , two hours and it was truly frightening just to see the kind of stuff going on
89
+ 00:04:03:18 , 00:04:08:03 , You ought to designate some people to make damn sure that the store owner's point of view is represented
90
+ 00:04:08:04 , 00:04:12:20 , After nine straight hours, the team is tired. They call it a day
91
+ 00:04:12:21 , 00:04:15:00 , Is everybody cool?
92
+ 00:04:15:01 , 00:04:17:11 , Well, that's great. Thanks a lot. And we had a great time today
93
+ 00:04:17:13 , 00:04:24:02 , IDEO's mantra for innovation is written everywhere
94
+ 00:04:24:03 , 00:04:29:08 , one conversation at a time, stay focused, encourage wild ideas
95
+ 00:04:29:09 , 00:04:32:10 , defer judgement, build on the ideas of others
96
+ 00:04:32:11 , 00:04:39:19 , That's hardest thing for people to do is to restrain themselves from criticizing an idea
97
+ 00:04:39:20 , 00:04:42:05 , So if anybody starts to nail an idea, they get the bell
98
+ 00:04:42:06 , 00:04:47:03 , The ideas pour out and are posted on the walls
99
+ 00:04:47:04 , 00:04:49:09 , Oh, the blind, the privacy blind
100
+ 00:04:49:10 , 00:04:52:14 , Like when you're buying 6 cases of condoms and you don't want them to see
101
+ 00:04:52:15 , 00:04:55:04 , If it doesn't nest, we don't have a solution
102
+ 00:04:55:05 , 00:05:00:08 , Organized chaos. It's not organized. What it is is it's focused chaos
103
+ 00:05:00:09 , 00:05:05:21 , Vote with your post, it's not with an idea that's cool, but with an idea that's cool and buildable
104
+ 00:05:05:22 , 00:05:11:13 , If it's too far out there and it can't be build in a day then I don't think we should vote on it
105
+ 00:05:11:14 , 00:05:15:25 , Enlightened trial and error succeeds over the planning of the lone genius
106
+ 00:05:15:26 , 00:05:20:02 , Enlightened trial and error succeeds over the planning of the lone genius
107
+ 00:05:20:03 , 00:05:23:25 , If anything sums up IDEO's approach, that is it
108
+ 00:05:23:26 , 00:05:26:14 , Worried that the team is drifting
109
+ 00:05:26:15 , 00:05:32:21 , what can only be called a group of self-appointed adults under Dave Kelly holds an informal side session
110
+ 00:05:32:22 , 00:05:33:21 , Four, four or five
111
+ 00:05:33:22 , 00:05:38:00 , Four of five teams, and we give each team a need area
112
+ 00:05:38:01 , 00:05:44:08 , It becomes very autocratic for a short period of time in defining what things people are going to work on
113
+ 00:05:44:09 , 00:05:47:17 , If you don't work under time constraints you could never get anything done
114
+ 00:05:47:18 , 00:05:49:23 , because it's a messy process that can go on forever
115
+ 00:05:49:24 , 00:05:53:20 , Back at the shop it is 6 o'clock
116
+ 00:05:53:21 , 00:05:55:24 , The four mockups are ready for showing
117
+ 00:05:55:25 , 00:06:01:05 , Baskets also can be, if you think you will have more volume, baskets can be put in
118
+ 00:06:01:06 , 00:06:04:17 , A modular shopping cart you pile hard baskets onto
119
+ 00:06:04:18 , 00:06:08:19 , A high tech cart that gets you through the traffic jam at check out
120
+ 00:06:08:20 , 00:06:13:23 , That you could mount a scanner on the shopping cart so that you as the customer
121
+ 00:06:13:24 , 00:06:18:02 , as you pull it off the shelf, would scan each item
122
+ 00:06:18:03 , 00:06:25:14 , One that's build around child safety and another that lets shoppers talk to supermarket staff remotely
123
+ 00:06:25:15 , 00:06:27:15 , Yeah, where can I find the yogurt?
124
+ 00:06:27:16 , 00:06:36:02 , But the adults again decide more work needs to be done before the mockups can be combined into one last prototype
125
+ 00:06:36:03 , 00:06:38:21 , Why don't we have all the carts come up here for a second?
126
+ 00:06:38:22 , 00:06:44:23 , I think you take a piece of each one of these ideas and kind of back it off a little bit and then put it in the design
127
+ 00:06:44:24 , 00:06:47:02 , The design is still not there
128
+ 00:06:47:03 , 00:06:48:29 , But there's another motto at IDEO
129
+ 00:06:49:00 , 00:06:51:19 , fail often in order to succeed sooner
130
+ 00:06:51:20 , 00:06:57:10 , and some of the team will be up half the night trying to put together a design finally that does work
131
+ 00:06:57:11 , 00:06:59:01 , Here it is!
132
+ 00:07:01:00 , 00:07:05:15 , So we took the best elements out of each prototype
133
+ 00:07:05:16 , 00:07:09:12 , The cart, which is designed to cost about the same as today's carts
134
+ 00:07:09:13 , 00:07:11:23 , is different in every other way
135
+ 00:07:11:24 , 00:07:12:16 , What do you think?
136
+ 00:07:12:17 , 00:07:17:12 , Well, I'm very proud of the team. I think it's great
137
+ 00:07:17:13 , 00:07:18:17 , This, does this work for you?
138
+ 00:07:18:18 , 00:07:20:26 , It works for me great. It's also beautiful
139
+ 00:07:20:27 , 00:07:24:15 , The cart's wheels turn 90 degrees so it can move sideways
140
+ 00:07:24:16 , 00:07:26:27 , No more lifting up the rear in a tight spot
141
+ 00:07:26:28 , 00:07:30:00 , And you shop in a totally different way
142
+ 00:07:30:01 , 00:07:33:08 , The bags are hung on the hooks on the cart's frame
143
+ 00:07:33:09 , 00:07:35:15 , Remember there is no basket here
144
+ 00:07:35:16 , 00:07:38:00 , At first I was a little shocked
145
+ 00:07:38:01 , 00:07:41:03 , but I think it's you have some fantastic ideas here
146
+ 00:07:41:04 , 00:07:44:08 , It needs a little refining but I think that it's great
147
+ 00:07:44:09 , 00:07:45:22 , I mean we would want them
148
+ 00:07:45:23 , 00:07:49:04 , And she also gave us some really good comments about how we can make this thing better
149
+ 00:07:49:06 , 00:07:50:22 , A lot of hours
150
+ 00:07:50:23 , 00:07:56:17 , Also an open mind, a boss who demands fresh ideas be quirky and clash with his
151
+ 00:07:56:18 , 00:08:00:25 , a belief that chaos can be constructive and teamwork
152
+ 00:08:00:26 , 00:08:02:26 , a great deal of teamwork
153
+ 00:08:02:27 , 00:08:07:08 , And these are the recipe for how innovation takes place
154
+ 00:08:07:09 , 00:08:11:24 , This is Jack Smith for Nightline, Palo Alto, California
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby -w
2
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
3
+ require 'subtitle_converter'
4
+
5
+ SubtitleConvertorCommandLine.process(ARGV)
data/filename ADDED
@@ -0,0 +1,2 @@
1
+ 1
2
+ 2
@@ -0,0 +1,29 @@
1
+ # encoding: utf-8
2
+
3
+ class STLReader
4
+ attr_reader :stl_sub_title_lines
5
+ def initialize
6
+ @stl_sub_title_lines = []
7
+ end
8
+
9
+ def import_stl_content(file_name)
10
+ begin
11
+ file =File.open(file_name, "r")
12
+ parse_srt_content(file)
13
+ file.close
14
+ rescue SystemCallError
15
+ puts "File not found"
16
+ end
17
+ end
18
+
19
+ private
20
+ def parse_srt_content(file)
21
+ @stl_sub_title_lines = file.select{|line|
22
+ line =~ /\d{2}(:[0-5]\d){3}\s+,\s+\d{2}(:[0-5]\d){3}\s+,\s+.*/
23
+ }.map{|line|
24
+ line.gsub!(", \t", ",\t")
25
+ line.gsub!("\t ,", "\t,")
26
+ line.split("\t,\t").map(&:strip).join("#")
27
+ }
28
+ end
29
+ end
@@ -0,0 +1,33 @@
1
+ # encoding: utf-8
2
+
3
+ class SubRibWriter
4
+ attr_reader :subrib_sub_title_lines
5
+
6
+ def initialize
7
+ @subrib_sub_title_lines = []
8
+ end
9
+
10
+ def parse_stl_lines(stl_sub_title_lines)
11
+ stl_sub_title_lines.to_enum.with_index(1) do |line, subtitle_number|
12
+ start_time, end_time, text_of_subtitle = line.split("#")
13
+ @subrib_sub_title_lines.push("#{subtitle_number}\n#{re_format(start_time)} --> #{re_format(end_time)}\n#{text_of_subtitle}\n\n")
14
+ end
15
+ end
16
+
17
+ def re_format(hh_mm_ss_fps)
18
+ hh_mm_ss_fps.sub(/(...)$/){|fps| ","+convert_fps_to_millisec(fps[1,2])}
19
+ end
20
+
21
+ def convert_fps_to_millisec(frames_per_sec)
22
+ milliseconds = 33*frames_per_sec.to_i
23
+ milliseconds.to_s.rjust(3, "0")
24
+ end
25
+
26
+ def to_file(filename)
27
+ file = File.open filename, "w" do |file|
28
+ subrib_sub_title_lines.each do |line|
29
+ file.puts line
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,22 @@
1
+ # encoding: utf-8
2
+
3
+ class SubtitleConvertor
4
+
5
+ def from(filename)
6
+ @reader = STLReader.new
7
+ @reader.import_stl_content(filename)
8
+ self
9
+ end
10
+
11
+ def to(filename)
12
+ @writer = SubRibWriter.new
13
+ @output_file = filename
14
+ self
15
+ end
16
+
17
+ def convert
18
+ @writer.parse_stl_lines(@reader.stl_sub_title_lines)
19
+ @writer.to_file(@output_file)
20
+ end
21
+
22
+ end
@@ -0,0 +1,28 @@
1
+ # encoding: utf-8
2
+
3
+ module SubtitleConvertorCommandLine
4
+
5
+ def self.error message
6
+ puts message
7
+ usage
8
+ end
9
+
10
+ def self.usage
11
+ puts "usage: convert source [destination]"
12
+ end
13
+
14
+ def self.target_file_from_source source_file
15
+ File.basename(source_file, File.extname(source_file)) + ".srt"
16
+ end
17
+
18
+ def self.process(command_line_arguments)
19
+ return error "convert_subtitle: missing arguments!\n" if command_line_arguments.empty?
20
+ return error "convert_subtitle: too much arguments!\n" if command_line_arguments.size > 2
21
+
22
+ source_file = command_line_arguments[0]
23
+ target_file = command_line_arguments[1] || target_file_from_source(source_file)
24
+
25
+ SubtitleConvertor.new.from(source_file).to(target_file).convert
26
+ puts "Finished converting subtitle"
27
+ end
28
+ end
@@ -0,0 +1,4 @@
1
+
2
+ module SubtitleConverterVersion
3
+ VERSION = "0.0.3"
4
+ end
@@ -0,0 +1,5 @@
1
+
2
+ require 'subtitle_converter/stl_reader'
3
+ require 'subtitle_converter/sub_rib_writer'
4
+ require 'subtitle_converter/subtitle_convertor'
5
+ require 'subtitle_converter/subtitle_convertor_command_line'