ffsplitter 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ffsplitter.rb +1 -0
- data/lib/ffsplitter/chapter.rb +5 -19
- data/lib/ffsplitter/chapter_list.rb +19 -0
- data/lib/ffsplitter/ffmpeg.rb +3 -2
- data/lib/ffsplitter/version.rb +1 -1
- data/spec/chapter_list_spec.rb +23 -0
- data/spec/chapter_spec.rb +8 -21
- data/spec/ffmpeg_spec.rb +8 -9
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee4772b49ecaa9deb93540af0873470e56b95693
|
4
|
+
data.tar.gz: c644abe550b1e941b8b4508c1ffae21cfe823e63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb614a070fed6e3fc482f0af492d973b19b57ad0ef260d4f7017b5fae75451eb692ab55043ebd268de401d013f0380b937b1ab48874d62272c6807e6e72a460c
|
7
|
+
data.tar.gz: e4b4db244fd584642041470eb250c0dbc56456d6bd7bcb73120d0d570d1291a68cce7ef2bb29e16560b4a5934cf85c852fbe750a3c0a26949790ef39f896ba2f
|
data/lib/ffsplitter.rb
CHANGED
data/lib/ffsplitter/chapter.rb
CHANGED
@@ -1,24 +1,6 @@
|
|
1
1
|
require 'virtus'
|
2
2
|
|
3
3
|
module FFSplitter
|
4
|
-
class ChapterList
|
5
|
-
|
6
|
-
include Enumerable
|
7
|
-
|
8
|
-
def initialize
|
9
|
-
@chapters = []
|
10
|
-
end
|
11
|
-
|
12
|
-
def each(&block)
|
13
|
-
@chapters.each { |c| yield c }
|
14
|
-
end
|
15
|
-
|
16
|
-
def add(chapter)
|
17
|
-
chapter.list = self
|
18
|
-
@chapters << chapter
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
4
|
class Chapter
|
23
5
|
include Virtus.model
|
24
6
|
|
@@ -37,6 +19,10 @@ module FFSplitter
|
|
37
19
|
timebase * end_frames
|
38
20
|
end
|
39
21
|
|
22
|
+
def duration
|
23
|
+
end_time - start_time
|
24
|
+
end
|
25
|
+
|
40
26
|
def filename
|
41
27
|
"#{track} #{title.gsub(/[';:\\]/, '').lstrip}"
|
42
28
|
end
|
@@ -50,4 +36,4 @@ module FFSplitter
|
|
50
36
|
(index + 1).to_s.rjust(2, '0')
|
51
37
|
end
|
52
38
|
end
|
53
|
-
end
|
39
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module FFSplitter
|
2
|
+
class ChapterList
|
3
|
+
|
4
|
+
include Enumerable
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@chapters = []
|
8
|
+
end
|
9
|
+
|
10
|
+
def each(&block)
|
11
|
+
@chapters.each { |c| yield c }
|
12
|
+
end
|
13
|
+
|
14
|
+
def add(chapter)
|
15
|
+
chapter.list = self
|
16
|
+
@chapters << chapter
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/ffsplitter/ffmpeg.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
module FFSplitter
|
2
2
|
class FFMpeg
|
3
|
+
CODEC_OPTIONS= "-c copy -movflags faststart"
|
3
4
|
attr_accessor :filename, :output_directory, :runner
|
4
5
|
|
5
6
|
def initialize(filename, output_directory=nil)
|
@@ -14,12 +15,12 @@ module FFSplitter
|
|
14
15
|
|
15
16
|
def encode(chapters)
|
16
17
|
commands = chapters.collect { |c| chapter_command(c) }
|
17
|
-
runner.run("
|
18
|
+
runner.run("#{commands.join(' && ')}")
|
18
19
|
end
|
19
20
|
|
20
21
|
def chapter_command(chapter)
|
21
22
|
output_file = File.expand_path(chapter.filename, output_directory)
|
22
|
-
"-i '#{filename}' -
|
23
|
+
"ffmpeg -ss #{chapter.start_time} -i '#{filename}' -t #{chapter.duration} #{CODEC_OPTIONS} '#{output_file}.mp4'"
|
23
24
|
end
|
24
25
|
end
|
25
26
|
end
|
data/lib/ffsplitter/version.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module FFSplitter
|
4
|
+
describe ChapterList do
|
5
|
+
describe "#add" do
|
6
|
+
let(:chapter_list) { ChapterList.new }
|
7
|
+
let!(:chapter1) { Chapter.new(title: "Chapter One") }
|
8
|
+
let!(:chapter2) { Chapter.new(title: "Chapter Two") }
|
9
|
+
before do
|
10
|
+
chapter_list.add(chapter1)
|
11
|
+
chapter_list.add(chapter2)
|
12
|
+
end
|
13
|
+
it "adds chapters to its collection" do
|
14
|
+
expect(chapter_list.count).to eq(2)
|
15
|
+
expect(chapter_list).to include(chapter1)
|
16
|
+
expect(chapter_list).to include(chapter2)
|
17
|
+
end
|
18
|
+
it "sets the chapter's list" do
|
19
|
+
expect(chapter1.list).to eq(chapter_list)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/spec/chapter_spec.rb
CHANGED
@@ -1,26 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module FFSplitter
|
4
|
-
describe ChapterList do
|
5
|
-
describe "#add" do
|
6
|
-
let(:chapter_list) { ChapterList.new }
|
7
|
-
let!(:chapter1) { Chapter.new(title: "Chapter One") }
|
8
|
-
let!(:chapter2) { Chapter.new(title: "Chapter Two") }
|
9
|
-
before do
|
10
|
-
chapter_list.add(chapter1)
|
11
|
-
chapter_list.add(chapter2)
|
12
|
-
end
|
13
|
-
it "adds chapters to its collection" do
|
14
|
-
expect(chapter_list.count).to eq(2)
|
15
|
-
expect(chapter_list).to include(chapter1)
|
16
|
-
expect(chapter_list).to include(chapter2)
|
17
|
-
end
|
18
|
-
it "sets the chapter's list" do
|
19
|
-
expect(chapter1.list).to eq(chapter_list)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
4
|
describe Chapter do
|
25
5
|
describe "#start_time, #end_time" do
|
26
6
|
let(:chapter){ Chapter.new(start_frames: 100, end_frames: 200, timebase: 0.5) }
|
@@ -65,5 +45,12 @@ module FFSplitter
|
|
65
45
|
end
|
66
46
|
end
|
67
47
|
end
|
48
|
+
|
49
|
+
describe "#duration" do
|
50
|
+
let(:chapter){ Chapter.new(start_frames: 100, end_frames: 200, timebase: 0.5) }
|
51
|
+
it "is the difference of start and end times" do
|
52
|
+
expect(chapter.duration).to eq 50
|
53
|
+
end
|
54
|
+
end
|
68
55
|
end
|
69
|
-
end
|
56
|
+
end
|
data/spec/ffmpeg_spec.rb
CHANGED
@@ -16,7 +16,7 @@ module FFSplitter
|
|
16
16
|
context "with a single chapter" do
|
17
17
|
before { chapter_list.add(chapter1) }
|
18
18
|
it "encodes the chapter" do
|
19
|
-
expect(runner).to receive(:run).with("
|
19
|
+
expect(runner).to receive(:run).with("#{ffmpeg.chapter_command(chapter1)}")
|
20
20
|
ffmpeg.encode(chapter_list)
|
21
21
|
end
|
22
22
|
end
|
@@ -27,8 +27,8 @@ module FFSplitter
|
|
27
27
|
chapter_list.add(chapter2)
|
28
28
|
end
|
29
29
|
it "encodes the chapters with a single ffmpeg command" do
|
30
|
-
commands = "#{ffmpeg.chapter_command(chapter1)} #{ffmpeg.chapter_command(chapter2)}"
|
31
|
-
expect(runner).to receive(:run).once.with("
|
30
|
+
commands = "#{ffmpeg.chapter_command(chapter1)} && #{ffmpeg.chapter_command(chapter2)}"
|
31
|
+
expect(runner).to receive(:run).once.with("#{commands}")
|
32
32
|
ffmpeg.encode(chapter_list)
|
33
33
|
end
|
34
34
|
end
|
@@ -36,16 +36,15 @@ module FFSplitter
|
|
36
36
|
|
37
37
|
describe "#chapter_command" do
|
38
38
|
let(:command) { ffmpeg.chapter_command(chapter) }
|
39
|
-
let(:chapter) { Chapter.new(start_frames: 10, end_frames:
|
39
|
+
let(:chapter) { Chapter.new(start_frames: 10, end_frames: 30, timebase: 1, title: "test title") }
|
40
40
|
|
41
41
|
context "without an output directory" do
|
42
42
|
let(:output_directory) { nil }
|
43
43
|
it "creates a chapter command" do
|
44
|
-
expect(command).to match("-
|
45
|
-
expect(command).to match("-
|
46
|
-
expect(command).to match("-
|
47
|
-
expect(command).to match(
|
48
|
-
expect(command).to match("-movflags faststart")
|
44
|
+
expect(command).to match("-ss #{chapter.start_time}")
|
45
|
+
expect(command).to match("-i '#{filename}'")
|
46
|
+
expect(command).to match("-t #{chapter.duration}")
|
47
|
+
expect(command).to match(FFSplitter::FFMpeg::CODEC_OPTIONS)
|
49
48
|
expect(command).to match("#{File.expand_path(chapter.filename)}")
|
50
49
|
end
|
51
50
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ffsplitter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Rockwood
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02
|
11
|
+
date: 2014-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: virtus
|
@@ -83,11 +83,13 @@ files:
|
|
83
83
|
- ffsplitter.gemspec
|
84
84
|
- lib/ffsplitter.rb
|
85
85
|
- lib/ffsplitter/chapter.rb
|
86
|
+
- lib/ffsplitter/chapter_list.rb
|
86
87
|
- lib/ffsplitter/command_runner.rb
|
87
88
|
- lib/ffsplitter/ffmpeg.rb
|
88
89
|
- lib/ffsplitter/metadata_parser.rb
|
89
90
|
- lib/ffsplitter/splitter.rb
|
90
91
|
- lib/ffsplitter/version.rb
|
92
|
+
- spec/chapter_list_spec.rb
|
91
93
|
- spec/chapter_spec.rb
|
92
94
|
- spec/end_to_end_spec.rb
|
93
95
|
- spec/ffmpeg_spec.rb
|
@@ -121,6 +123,7 @@ signing_key:
|
|
121
123
|
specification_version: 4
|
122
124
|
summary: ffsplitter will split a video file by its chapters
|
123
125
|
test_files:
|
126
|
+
- spec/chapter_list_spec.rb
|
124
127
|
- spec/chapter_spec.rb
|
125
128
|
- spec/end_to_end_spec.rb
|
126
129
|
- spec/ffmpeg_spec.rb
|