# File lib/flv/video_tag.rb, line 45 def after_initialize(new_object) @tag_type = VIDEO read_header end
# 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
# File lib/flv/video_tag.rb, line 67 def interframe? frame_type == INTERFRAME || frame_type == DISPOSABLEINTERFRAME end
# File lib/flv/video_tag.rb, line 63 def keyframe? frame_type == KEYFRAME end
# 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
# 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 bit_sequence = data_stream.read(9).unpack('B72').to_s if @codec_id == H263VIDEOPACKET @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 @width, @height = bit2uint(bit_sequence[4,12]), bit2uint(bit_sequence[16,12]) end end