Class: FLV::FLVVideoTag
Constant Summary collapse
- H263VIDEOPACKET =
2
- SCREENVIDEOPACKET =
3
- ON2VP6 =
4
- KEYFRAME =
1
- INTERFRAME =
2
- DISPOSABLEINTERFRAME =
3
Constants inherited from FLVTag
FLV::FLVTag::AUDIO, FLV::FLVTag::META, FLV::FLVTag::UNDEFINED, FLV::FLVTag::VIDEO
Instance Attribute Summary collapse
-
#codec_id ⇒ Object
readonly
Returns the value of attribute codec_id.
-
#frame_type ⇒ Object
readonly
Returns the value of attribute frame_type.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Attributes inherited from FLVTag
#byte_offset, #tag_type, #timestamp
Instance Method Summary collapse
- #after_initialize(new_object) ⇒ Object
- #inspect ⇒ Object
- #interframe? ⇒ Boolean
- #keyframe? ⇒ Boolean
- #name ⇒ Object
- #read_header ⇒ Object
Methods inherited from FLVTag
#data, #data_size, #info, #initialize, #serialize, #size, type2name
Constructor Details
This class inherits a constructor from FLV::FLVTag
Instance Attribute Details
#codec_id ⇒ Object (readonly)
Returns the value of attribute codec_id.
40 41 42 |
# File 'lib/flv/video_tag.rb', line 40 def codec_id @codec_id end |
#frame_type ⇒ Object (readonly)
Returns the value of attribute frame_type.
40 41 42 |
# File 'lib/flv/video_tag.rb', line 40 def frame_type @frame_type end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
40 41 42 |
# File 'lib/flv/video_tag.rb', line 40 def height @height end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
40 41 42 |
# File 'lib/flv/video_tag.rb', line 40 def width @width end |
Instance Method Details
#after_initialize(new_object) ⇒ Object
45 46 47 48 |
# File 'lib/flv/video_tag.rb', line 45 def after_initialize(new_object) @tag_type = VIDEO read_header end |
#inspect ⇒ Object
104 105 106 107 108 109 110 111 112 |
# File 'lib/flv/video_tag.rb', line 104 def inspect out = super out << "frame_type: #{%w{ Keyframe Interframe DisposableInterframe }[@frame_type]}" out << "codec_id: #{@codec_id}" out << "width: #{@width}" out << "height: #{@height}" out << "data_size: #{data_size}" out end |
#interframe? ⇒ Boolean
67 68 69 |
# File 'lib/flv/video_tag.rb', line 67 def interframe? frame_type == INTERFRAME || frame_type == DISPOSABLEINTERFRAME end |
#keyframe? ⇒ Boolean
63 64 65 |
# File 'lib/flv/video_tag.rb', line 63 def keyframe? frame_type == KEYFRAME end |
#name ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/flv/video_tag.rb', line 50 def name case frame_type when KEYFRAME 'Video Tag (Keyframe)' when INTERFRAME 'Video Tag (Interframe)' when DISPOSABLEINTERFRAME 'Video Tag (disposable Interframe)' else 'Video Tag' end end |
#read_header ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/flv/video_tag.rb', line 71 def read_header data_stream = AMFStringBuffer.new(@data) # the sequence is swaped in the swf-file-format description # frame_type <-> codec_id (description: 1. codec_id, 2. frame_type) codec_id_and_frame_type = data_stream.read__UI8 @frame_type = codec_id_and_frame_type >> 4 @codec_id = codec_id_and_frame_type & 0xf if @codec_id == H263VIDEOPACKET bit_sequence = data_stream.read(9).unpack('B72').to_s @width, @height = case bit2uint bit_sequence[30,3] when 0 [bit2uint(bit_sequence[33,8]), bit2uint(bit_sequence[41,8])] when 1 [bit2uint(bit_sequence[33,16]), bit2uint(bit_sequence[49,16])] when 2 [352, 288] when 3 [176, 144] when 4 [128, 96] when 5 [320, 240] when 6 [160, 120] end elsif @codec_id == SCREENVIDEOPACKET bit_sequence = data_stream.read(9).unpack('B72').to_s @width, @height = bit2uint(bit_sequence[4,12]), bit2uint(bit_sequence[16,12]) end end |