Module: MP4::Binary::Hev1

Defined in:
lib/mp4/binary/hev1.rb

Class Method Summary collapse

Class Method Details

.find_atom(bytes, atom_name, atom_handler) ⇒ Object



64
65
66
67
68
69
70
71
# File 'lib/mp4/binary/hev1.rb', line 64

def self.find_atom(bytes, atom_name, atom_handler)
  atom_name_position = bytes.index(atom_name)
  atom_start_pos = atom_name_position - 4
  atom_size = BinData::Uint32be.read(bytes[atom_start_pos..atom_start_pos + 4]).to_i
  atom_bytes = bytes[atom_start_pos..atom_start_pos + 4 + atom_size]

  atom_handler.read(atom_bytes)
end

.read(bytes) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/mp4/binary/hev1.rb', line 51

def self.read(bytes)
  hev1 = CodecOptions.read(bytes)
  pasp = find_atom(bytes, 'pasp', PixelAspectRatioBox)
  bitrate = find_atom(bytes, 'btrt', BitRateBox)

  {
    width: hev1.width,
    height: hev1.height,
    pasp: pasp,
    bitrate: bitrate,
  }
end