split_video 0.0.1
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 +7 -0
- data/.gitignore +20 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +32 -0
- data/Rakefile +1 -0
- data/bin/vsplit +24 -0
- data/lib/split_video.rb +67 -0
- data/lib/split_video/version.rb +3 -0
- data/split_video.gemspec +23 -0
- metadata +82 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 78530bc65c098d6f59cf9c09d90ade4eb945f941
|
4
|
+
data.tar.gz: d892e9cba044babe4acbb7c1a4b34672b0fd814a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ea88de6485b900c27598886309d898a9da2da8f2beb75c88b5df93c9651d2432c6bbdeb10ac75ae8fc144aed18c983193166c5125591fd81d40273a7f47086cc
|
7
|
+
data.tar.gz: 7e5b0594596f19195b678a4ec0aa192a25a08ee495244d7fb5e790d3d34a90e17fba654c5c21ee0b1662a224b70809efade6a776ec81ccbe99da66376cd2d8b8
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 max thom stahl
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# SplitVideo
|
2
|
+
|
3
|
+
Simple executables for splitting an transcoding videos.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'split_video'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install split_video
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
$ vsplit --slices 10 --file my_awesome_but_super_long_video.m4v
|
22
|
+
|
23
|
+
...will split the video file `my_awesome_but_super_long_video.m4v` into 10
|
24
|
+
slices named like `my_awesome_but_super_long_video-part-0001.m4v`. That's it!
|
25
|
+
|
26
|
+
## Contributing
|
27
|
+
|
28
|
+
1. Fork it ( http://github.com/<my-github-username>/split_video/fork )
|
29
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
30
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
31
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
32
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/vsplit
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$: << File.join(File.dirname(__FILE__), '..', 'lib')
|
4
|
+
|
5
|
+
require 'getopt/long'
|
6
|
+
|
7
|
+
require 'split_video'
|
8
|
+
|
9
|
+
@options = Getopt::Long.getopts(
|
10
|
+
['--slices', '-s', Getopt::OPTIONAL],
|
11
|
+
# ['--duration', '-d', Getopt::OPTIONAL],
|
12
|
+
['--file', '-f', Getopt::REQUIRED]
|
13
|
+
)
|
14
|
+
|
15
|
+
unless filename = ARGV.shift
|
16
|
+
puts SplitVideo::USAGE
|
17
|
+
exit
|
18
|
+
end
|
19
|
+
|
20
|
+
filename = @options['file']
|
21
|
+
|
22
|
+
SplitVideo.split_a_video(filename, @options)
|
23
|
+
|
24
|
+
# vim: set ft=ruby :
|
data/lib/split_video.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'split_video/version'
|
2
|
+
|
3
|
+
module SplitVideo
|
4
|
+
|
5
|
+
USAGE = %{
|
6
|
+
Usage: #{$0} [options] filename
|
7
|
+
|
8
|
+
Options include:
|
9
|
+
|
10
|
+
-s, --slices : Number of pieces to slice the video into
|
11
|
+
-d, --duration : Duration of each slice
|
12
|
+
|
13
|
+
Important: only specify ONE of those!
|
14
|
+
}
|
15
|
+
|
16
|
+
def self.split_a_video(filename, options)
|
17
|
+
unless (!! options['slices']) ^ (!! options['duration'])
|
18
|
+
puts USAGE
|
19
|
+
exit
|
20
|
+
end
|
21
|
+
|
22
|
+
if options['slices']
|
23
|
+
SplitVideo.split_by_slices(filename, options['slices'].to_i, options)
|
24
|
+
elsif options['duration']
|
25
|
+
SplitVideo.split_by_duration(filename, options['duration'].to_i, options)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.split_by_slices(filename, num_slices, options = {})
|
30
|
+
seconds_per_slice = duration_in_seconds(filename) / num_slices
|
31
|
+
|
32
|
+
offset = 0.0
|
33
|
+
(0..(num_slices - 1)).each do |slice|
|
34
|
+
offset += seconds_per_slice
|
35
|
+
print "Cutting slice #{slice}"
|
36
|
+
%x{
|
37
|
+
ffmpeg -i "#{filename}" \
|
38
|
+
-vcodec copy \
|
39
|
+
-acodec copy \
|
40
|
+
-ss "#{offset}" \
|
41
|
+
-t "#{seconds_per_slice}" \
|
42
|
+
#{output_filename_for(filename) % slice}
|
43
|
+
}
|
44
|
+
puts "...done!"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.split_by_duration(filename, duration, options = {})
|
49
|
+
puts "Sorry I haven't implemented this yet."
|
50
|
+
exit
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def self.duration_in_seconds(filename)
|
56
|
+
duration_string = %x{ffmpeg -i #{filename} 2>&1 | grep Duration}
|
57
|
+
duration_string =~ /(\d{2}):(\d{2}):(\d{2}.\d{2})/
|
58
|
+
hours, minutes, seconds = [$1, $2, $3].map(&:to_f)
|
59
|
+
|
60
|
+
hours * 3600 + minutes * 60 + seconds
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.output_filename_for(filename)
|
64
|
+
filename.gsub %r{\A(.*)\.([^\.]+)\Z}, '\1-part-%04d.\2'
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
data/split_video.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'split_video/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "split_video"
|
8
|
+
spec.version = SplitVideo::VERSION
|
9
|
+
spec.authors = ["max thom stahl"]
|
10
|
+
spec.email = ["max@villainousindustries.com"]
|
11
|
+
spec.summary = %q{Use the magic of FFmpeg to split videos with the greatest of ease}
|
12
|
+
spec.description = %q{Split video files without transcoding them using FFmpeg}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: split_video
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- max thom stahl
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Split video files without transcoding them using FFmpeg
|
42
|
+
email:
|
43
|
+
- max@villainousindustries.com
|
44
|
+
executables:
|
45
|
+
- vsplit
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- bin/vsplit
|
55
|
+
- lib/split_video.rb
|
56
|
+
- lib/split_video/version.rb
|
57
|
+
- split_video.gemspec
|
58
|
+
homepage: ''
|
59
|
+
licenses:
|
60
|
+
- MIT
|
61
|
+
metadata: {}
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 2.2.2
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
81
|
+
summary: Use the magic of FFmpeg to split videos with the greatest of ease
|
82
|
+
test_files: []
|