Skip to content

Commit

Permalink
Rework file structure for gemspec
Browse files Browse the repository at this point in the history
  • Loading branch information
wayspurrchen committed Sep 12, 2015
1 parent fab8dd4 commit 3a9eed7
Show file tree
Hide file tree
Showing 18 changed files with 259 additions and 252 deletions.
22 changes: 22 additions & 0 deletions .gitignore
@@ -0,0 +1,22 @@
*.gem
*.rbc
.bundle
.config
.yardoc
Gemfile.lock
InstalledFiles
_yardoc
coverage
doc/
lib/bundler/man
pkg
rdoc
spec/reports
test/tmp
test/version_tmp
tmp
*.bundle
*.so
*.o
*.a
mkmf.log
8 changes: 3 additions & 5 deletions Gemfile
@@ -1,6 +1,4 @@
ruby '2.0.0'
source 'http://rubygems.org'
source 'https://rubygems.org'

gem 'aviglitch'
gem 'slop'
gem 'av'
# Specify your gem's dependencies in moshy.gemspec
gemspec
35 changes: 12 additions & 23 deletions Gemfile.lock
@@ -1,32 +1,21 @@
PATH
remote: .
specs:
moshy (0.1.0)
aviglitch
slop

GEM
remote: http://rubygems.org/
remote: https://rubygems.org/
specs:
activesupport (4.2.4)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
av (0.9.0)
cocaine (~> 0.5.3)
aviglitch (0.1.5)
climate_control (0.0.3)
activesupport (>= 3.0)
cocaine (0.5.7)
climate_control (>= 0.0.3, < 1.0)
i18n (0.7.0)
json (1.8.3)
minitest (5.8.0)
rake (10.4.2)
slop (4.2.0)
thread_safe (0.3.5)
tzinfo (1.2.2)
thread_safe (~> 0.1)

PLATFORMS
ruby
x86-mingw32

DEPENDENCIES
av
aviglitch
slop
bundler (~> 1.6)
moshy!
rake
21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

22 changes: 22 additions & 0 deletions LICENSE.txt
@@ -0,0 +1,22 @@
Copyright (c) 2015 Way Spurr-Chen <wayspurrchen@gmail.com> <http://wayspurrchen.com/>

MIT License

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
43 changes: 17 additions & 26 deletions README.md
@@ -1,38 +1,29 @@
# moshy
# Moshy

moshy is a datamoshing utility kit for AVI files, based heavily on [aviglitch](https://github.com/ucnv/aviglitch).
It's designed to make common datamoshing tasks easier from a command line interface
without having to open avidemux or other GUI tools. It lets you do stuff like:
TODO: Write a gem description

- Convert video files into AVI video files with minimal I-Frames and no B-frames for ultimate moshability
- Create P-Frame duplication effects quickly
- Split a long video file into multiple clips based on its I-Frames
- "Bake" your datamoshed video, encoding the corruption as actual video content for uploading to video services or moshing even further!
- Identifying keyframe and deltaframe indexes in any AVI file
- ...and more!
## Installation

## Get it!
Add this line to your application's Gemfile:

gem 'moshy'

And then execute:

## What's it do?
$ bundle

## This is cool
Or install it yourself as:

WIP
$ gem install moshy

(note: to use `prep` you must have ffmpeg installed)
## Usage

TODO:
TODO: Write usage instructions here

stitch
## Contributing

i1

i2

b1 e1

b2 e2

o
1. Fork it ( https://github.com/[my-github-username]/moshy/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request
2 changes: 2 additions & 0 deletions Rakefile
@@ -0,0 +1,2 @@
require "bundler/gem_tasks"

105 changes: 105 additions & 0 deletions bin/moshy
@@ -0,0 +1,105 @@
#!/usr/bin/env ruby

require 'optparse'
require 'slop'
require 'moshy'

module Moshy
def self.top_level_help
$options = {

}
opts = OptionParser.new do |opts|
opts.banner = "
moshy, a Ruby utility for making it easier to datamosh AVI files. It has
multiple modes that can be run with the -m or --mode option.
MODES DETAILS
-------------
\"prep\"
------
Preps a video file for datamoshing with moshy by converting it
into an AVI with no B-Frames (they're not good for moshing), and placing as
few I-Frames as possible. Requires ffmpeg be installed locally.
\"isplit\"
--------
Extracts individual clips from an AVI where each clip is
separated by I-frames in the original AVI. Great for getting specific
clips out of a larger video and later doing I-frame moshing.
\"pdupe\"
-------
Duplicates a P-frame at a given frame a certain amount. To find
out which frames are P-frames, use software like avidemux to look at the
frame type. WARNING: This mode is a little glitchy. You may need to set
the interval 1 or 2 above or below the frame number you actually want to
duplicate. I'm not sure why this happens, but try it with a small
duplication amount first. NOTE: This can mode take a while to process
over 60-90 frame dupes.
\"ppulse\"
--------
Takes c number of frames and every n frames and duplicates them a
given amount, resulting in a consistent P-duplication datamosh that's
good for creating rhythmic effects. This was originally created to
create mosh effects in sync with a beat for a music video.
\"bake\"
------
\"Bakes\" your datamosh by creating a new video file from your
datamoshed .avi, causing the datamosh effects to be treated as the actual
content of the new video instead of an error. Requires ffmpeg to be
installed locally.
\"inspect\"
---------
Reads an .avi file and prints which video frames are keyframes
(I-Frames) and which frames are delta frames (P-frames or B-frames). moshy
cannot tell the difference between a P-frame or a B-frame, so you will want
to use avidemux or another program if you need to know.
Run moshy with mode -m <mode> --help to see options for individual modes.
"
end

begin
opts.parse
rescue OptionParser::InvalidOption, OptionParser::InvalidArgument
end

puts opts
end
end

# Because we have multiple modes, we do some initial basic arg checking
# to see if they specified a mode. If not, we show the top-level help menu.
result = Slop.parse suppress_errors: true do |o|
o.string '-m', '--mode'
end

mode_classes = {
"inspect" => Moshy::Inspect,
"isplit" => Moshy::ISplit,
"pdupe" => Moshy::PDupe,
"ppulse" => Moshy::PPulse,
"prep" => Moshy::Prep,
"bake" => Moshy::Bake
}

if mode_classes.has_key? result[:m]
# We need to strip out the "m" otherwise our other arg parsers
# will choke on the extra parameter
ARGV.each_with_index do |o, i|
if o == "-m" || o == "--m"
ARGV.delete_at(i + 1)
ARGV.delete_at(i)
break
end
end

mode_classes[result[:m]].new.cli ARGV
else
Moshy.top_level_help
end
11 changes: 11 additions & 0 deletions lib/moshy.rb
@@ -0,0 +1,11 @@
require_relative "moshy/version"
require_relative "moshy/inspect"
require_relative "moshy/isplit"
require_relative "moshy/pdupe"
require_relative "moshy/bake"
require_relative "moshy/prep"
require_relative "moshy/ppulse"

module Moshy
# Empty skeleton - just used to include the others
end
16 changes: 8 additions & 8 deletions lib/bake.rb → lib/moshy/bake.rb
@@ -1,6 +1,6 @@
module Moshy
class Bake
def initialize(args)
def cli(args)
opts = Slop::Options.new
opts.separator 'Required Parameters:'
opts.string '-i', '--input', 'Input file path - can be anything that ffmpeg supports.'
Expand Down Expand Up @@ -39,28 +39,28 @@ def initialize(args)
exit
end

prep @options[:input]
prep @options[:input], @options[:output], @options[:pframes], @options[:'iframe-interval'], @options[:bitrate]
end

def prep(file)
def prep(file, output, pframes, iframe_interval, bitrate)
ffmpeg = Av::Commands::Ffmpeg.new
ffmpeg.add_source file
ffmpeg.add_destination @options[:output]
ffmpeg.add_destination output

# Ensures all frames come out as P-frames, B-frames don't
# dupe or mosh properly
if @options[:pframes]
if pframes
ffmpeg.add_output_param ['bf', 0]
end

# Keyframe interval, sets as few I-frames as possible.
# ffmpeg will complain about anything over 600 and cap it.
if @options[:'iframe-interval']
ffmpeg.add_output_param ['g', @options[:'iframe-interval'].to_s]
if iframe_interval
ffmpeg.add_output_param ['g', iframe_interval.to_s]
end

# Bitrate
ffmpeg.add_output_param ['b:v', @options[:bitrate].to_s + 'k']
ffmpeg.add_output_param ['b:v', bitrate.to_s + 'k']

ffmpeg.run
end
Expand Down
2 changes: 1 addition & 1 deletion lib/inspect.rb → lib/moshy/inspect.rb
@@ -1,6 +1,6 @@
module Moshy
class Inspect
def initialize(args)
def cli(args)
opts = Slop::Options.new
opts.banner = "Usage: moshy -m inspect -i file.avi\nmoshy -m inspect --help for details"
opts.separator 'Required Parameters:'
Expand Down

0 comments on commit 3a9eed7

Please sign in to comment.