movie_merge 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +13 -0
- data/Rakefile +1 -0
- data/bin/moviemerge +7 -0
- data/lib/movie_merge.rb +6 -0
- data/lib/movie_merge/cli.rb +88 -0
- data/lib/movie_merge/version.rb +3 -0
- data/movie_merge.gemspec +21 -0
- metadata +73 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use 1.9.3@movie_merge --create
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Mike Fulcher
|
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,13 @@
|
|
1
|
+
# MovieMerge
|
2
|
+
|
3
|
+
Joins multiple video files together using the `cat` command and ffmpeg.
|
4
|
+
|
5
|
+
```
|
6
|
+
moviemerge INPUT-1 .. INPUT-N
|
7
|
+
|
8
|
+
Options (all are optional):
|
9
|
+
-f, [--framerate=N] # Default: 25
|
10
|
+
-t, [--target=TARGET]
|
11
|
+
-d, [--dry-run]
|
12
|
+
-h, [--help]
|
13
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/moviemerge
ADDED
data/lib/movie_merge.rb
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
require "thor"
|
2
|
+
|
3
|
+
module MovieMerge
|
4
|
+
class Cli < ::Thor
|
5
|
+
include Thor::Actions
|
6
|
+
|
7
|
+
desc "INPUT-1 .. INPUT-N", "Combines multiple video files into a single video file."
|
8
|
+
option :framerate, :type => :numeric, :aliases => "-f", :default => 25
|
9
|
+
option :target, :type => :string, :aliases => "-t"
|
10
|
+
option :'dry-run', :type => :boolean, :aliases => "-d", :default => false
|
11
|
+
option :help, :type => :boolean, :aliases => "-h", :default => false
|
12
|
+
def join(*sources)
|
13
|
+
# Check if the help flag is present and if so return the help information.
|
14
|
+
if options[:help]
|
15
|
+
return self.class.task_help(self, :join)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Minimum of 2 input files are required.
|
19
|
+
return say("Too few files (#{sources.size}) supplied (required: 2)", :red) if sources.size < 2
|
20
|
+
|
21
|
+
# Get the current working directory.
|
22
|
+
cwd = `pwd`.gsub(/\s*$/, '')
|
23
|
+
|
24
|
+
# Determine if homebrew and ffmpeg are present.
|
25
|
+
has_homebrew = `which brew` != ''
|
26
|
+
has_ffmpeg = `which ffmpeg` != ''
|
27
|
+
|
28
|
+
# Build a message to display if ffmpeg isn't found. Appends the homebrew install command
|
29
|
+
# if homebrew is found.
|
30
|
+
ffmpeg_msg = "ffmpeg not found; cannot continue."
|
31
|
+
ffmpeg_msg << " You may need to `brew install ffmpeg`." if has_homebrew
|
32
|
+
return say(ffmpeg_msg, :red) unless has_ffmpeg
|
33
|
+
|
34
|
+
# Fetch the framerate.
|
35
|
+
framerate = options[:framerate]
|
36
|
+
|
37
|
+
# Ensure each of the input files have the same extension.
|
38
|
+
file_types = sources.map { |s| s.split('.').last }.uniq
|
39
|
+
return say("Supplied sources must be of the same file type (supplied #{file_types.join(', ')})", :red) if file_types.size > 1
|
40
|
+
file_type = file_types.first
|
41
|
+
|
42
|
+
# Build the target and temp file names.
|
43
|
+
target = options[:target] || "moviemerged-x#{sources.size}.#{file_type}"
|
44
|
+
temp = ".#{target}"
|
45
|
+
|
46
|
+
# Ensure each of the input files actually exist.
|
47
|
+
sources.each do |source|
|
48
|
+
source_exists = File.exists?(File.join(cwd, source))
|
49
|
+
return say("Source file not found; cannot continue (#{source})", :red) unless source_exists
|
50
|
+
end
|
51
|
+
|
52
|
+
# Check if the target exists and offer to overwrite.
|
53
|
+
target_exists = File.exists?(File.join(cwd, target))
|
54
|
+
can_overwrite = yes?("Target file exists (#{target}). Overwrite?") if target_exists
|
55
|
+
return say("Stopping.", :red) if target_exists && !can_overwrite
|
56
|
+
|
57
|
+
# Return here if doing a dry run only.
|
58
|
+
return say("Dry run successful.", :green) if options[:'dry-run']
|
59
|
+
|
60
|
+
# Concatenate the input files and output to a temp file.
|
61
|
+
say("Concatenating files.", :green)
|
62
|
+
`cat #{sources.join(' ')} > #{temp}`
|
63
|
+
|
64
|
+
unless $?.success?
|
65
|
+
`rm -f #{temp}`
|
66
|
+
return say("Unable to join files. Exiting...", :red)
|
67
|
+
end
|
68
|
+
|
69
|
+
# Reindex the temp file using ffmpeg.
|
70
|
+
say("Reindexing combined output at framerate of #{framerate}.", :green)
|
71
|
+
`ffmpeg -i #{temp} -r #{framerate} -sameq #{target} 2>&1`
|
72
|
+
|
73
|
+
unless $?.success?
|
74
|
+
`rm -f #{temp}`
|
75
|
+
return say("Unable to reindex files. Exiting...", :red)
|
76
|
+
end
|
77
|
+
|
78
|
+
# Remove the temp file.
|
79
|
+
say("Cleaning up temp files.", :green)
|
80
|
+
`rm -f #{temp}`
|
81
|
+
say("Unable to remove temp file: #{temp}", :red) unless $?.success?
|
82
|
+
|
83
|
+
# Done!
|
84
|
+
say("Finished generating #{target}", :green)
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
end
|
data/movie_merge.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'movie_merge/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "movie_merge"
|
8
|
+
gem.version = MovieMerge::VERSION
|
9
|
+
gem.authors = ["Mike Fulcher"]
|
10
|
+
gem.email = ["mike@plan9design.co.uk"]
|
11
|
+
gem.description = %q{Write a gem description}
|
12
|
+
gem.summary = %q{Write a gem summary}
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_dependency('thor', '0.16.0')
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: movie_merge
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Mike Fulcher
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-01-08 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: thor
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - '='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.16.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - '='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.16.0
|
30
|
+
description: Write a gem description
|
31
|
+
email:
|
32
|
+
- mike@plan9design.co.uk
|
33
|
+
executables:
|
34
|
+
- moviemerge
|
35
|
+
extensions: []
|
36
|
+
extra_rdoc_files: []
|
37
|
+
files:
|
38
|
+
- .gitignore
|
39
|
+
- .rvmrc
|
40
|
+
- Gemfile
|
41
|
+
- LICENSE.txt
|
42
|
+
- README.md
|
43
|
+
- Rakefile
|
44
|
+
- bin/moviemerge
|
45
|
+
- lib/movie_merge.rb
|
46
|
+
- lib/movie_merge/cli.rb
|
47
|
+
- lib/movie_merge/version.rb
|
48
|
+
- movie_merge.gemspec
|
49
|
+
homepage: ''
|
50
|
+
licenses: []
|
51
|
+
post_install_message:
|
52
|
+
rdoc_options: []
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ! '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ! '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
requirements: []
|
68
|
+
rubyforge_project:
|
69
|
+
rubygems_version: 1.8.24
|
70
|
+
signing_key:
|
71
|
+
specification_version: 3
|
72
|
+
summary: Write a gem summary
|
73
|
+
test_files: []
|