Skip to content

Commit

Permalink
test FFMPEG::Stream
Browse files Browse the repository at this point in the history
  • Loading branch information
drbrain committed Sep 9, 2009
1 parent 976395b commit eae7660
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/ffmpeg/stream.rb
Expand Up @@ -127,9 +127,11 @@ class FFMPEG::Stream
builder.accessor :start_time, 'int64_t'

builder.accessor :quality, 'double'

end

##
# FIFO for audio streams

attr_accessor :fifo
attr_reader :format_context
attr_accessor :next_pts
Expand All @@ -141,6 +143,7 @@ def initialize(format_context=nil)
@next_pts = FFMPEG::NOPTS_VALUE
@pts = 0
@sync_pts = 0
@fifo = nil
end

def inspect
Expand Down
14 changes: 14 additions & 0 deletions lib/ffmpeg/test_case.rb
@@ -1,11 +1,25 @@
require 'rubygems'
require 'fileutils'
require 'minitest/autorun'
require 'tmpdir'

require 'ffmpeg'

class FFMPEG::TestCase < MiniTest::Unit::TestCase

def setup
@thumbs_up = File.expand_path 'Thumbs Up!.3gp', 'test'

@tmpdir = File.join Dir.tmpdir, "ffmpeg_test_#{$$}"

FileUtils.mkdir_p @tmpdir

@thumbs_out = File.join @tmpdir,
File.basename(@thumbs_up).sub(/3gp$/, 'wmv')
end

def teardown
FileUtils.rm_rf @tmpdir
end

##
Expand Down
57 changes: 57 additions & 0 deletions test/test_ffmpeg_stream.rb
@@ -0,0 +1,57 @@
require 'ffmpeg/test_case'

class TestFFMPEGStream < FFMPEG::TestCase

def setup
super

@fc = FFMPEG::FormatContext.new @thumbs_out, true
@s = @fc.output_stream(FFMPEG::Codec::VIDEO, 'wmv', :bit_rate => 202_396,
:width => 196, :height => 144,
:fps => FFMPEG.Rational(25, 1))
end

def test_codec_context
assert_equal 'msmpeg4', @s.codec_context.codec.name
end

def test_context_defaults
@s.context_defaults FFMPEG::Codec::VIDEO

assert_equal FFMPEG::PixelFormat::NONE, @s.codec_context.pixel_format
end

def test_r_frame_rate
@s.r_frame_rate = FFMPEG.Rational(10, 1)

assert_equal FFMPEG.Rational(10, 1), @s.r_frame_rate
end

def test_r_frame_rate_equals
r = FFMPEG.Rational(10, 1)
@s.r_frame_rate = r

assert_equal r, @s.r_frame_rate
refute_same r, @s.r_frame_rate
end

def test_time_base
@s.time_base = FFMPEG.Rational(10, 1)

assert_equal FFMPEG.Rational(10, 1), @s.time_base
end

def test_time_base_equals
r = FFMPEG.Rational(10, 1)
@s.time_base = r

assert_equal r, @s.time_base
refute_same r, @s.time_base
end

def test_type
assert_equal :VIDEO, @s.type
end

end

0 comments on commit eae7660

Please sign in to comment.