Sha256: 1e6ceb620aad0be2a3ad47e9c75e4e7a58c8776bc4538ebbe38c412119a719d0

Contents?: true

Size: 1.56 KB

Versions: 1

Compression:

Stored size: 1.56 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe AviGlitch, 'datamosh cli' do

  before :all do
    FileUtils.mkdir OUTPUT_DIR unless File.exist? OUTPUT_DIR
    @in = FILES_DIR + 'sample.avi'
    @out = OUTPUT_DIR + 'out.avi'
    datamosh = Pathname.new(
      File.join(File.dirname(__FILE__), '..', 'bin/datamosh')
    ).realpath
    @cmd = "ruby %s -o %s " % [datamosh, @out]
  end

  after :each do
    FileUtils.rm Dir.glob((OUTPUT_DIR + '*').to_s)
  end

  after :all do
    FileUtils.rmdir OUTPUT_DIR
  end

  it 'should correctly process files' do
    system [@cmd, @in].join(' ')
    o = AviGlitch.open @out
    o.frames.each_with_index do |f, i|
      if f.is_keyframe? && i == 0
        f.data.should_not match /^\000+$/
      elsif f.is_keyframe?
        f.data.should match /^\000+$/
      end
    end
    o.close
    AviGlitch::Base.surely_formatted?(@out, true).should be true

    system [@cmd, '-a', @in].join(' ')
    o = AviGlitch.open @out
    o.frames.each do |f|
      if f.is_keyframe?
        f.data.should match /^\000+$/
      end
    end
    o.close
    AviGlitch::Base.surely_formatted?(@out, true).should be true

    system [@cmd, @in, @in, @in].join(' ')
    a = AviGlitch.open @in
    o = AviGlitch.open @out
    o.frames.size.should == a.frames.size * 3
    o.frames.each_with_index do |f, i|
      if f.is_keyframe? && i == 0
        f.data.should_not match /^\000+$/
      elsif f.is_keyframe?
        f.data.should match /^\000+$/
      end
    end
    o.close
    AviGlitch::Base.surely_formatted?(@out, true).should be true
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aviglitch-0.0.3 spec/datamosh_spec.rb