diff --git a/README.md b/README.md index ca0cb5c1..6c51acb6 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ The package can be installed by adding `membrane_mp4_plugin` to your list of dep ```elixir defp deps do [ - {:membrane_mp4_plugin, "~> 0.29.1"} + {:membrane_mp4_plugin, "~> 0.30.0"} ] end ``` diff --git a/lib/membrane_mp4/container/schema.ex b/lib/membrane_mp4/container/schema.ex index eb01ccb5..7d80c61c 100644 --- a/lib/membrane_mp4/container/schema.ex +++ b/lib/membrane_mp4/container/schema.ex @@ -14,6 +14,34 @@ defmodule Membrane.MP4.Container.Schema do flags: {:uint24, store: :fo_flags} ] + @avc_schema [ + version: 0, + fields: + @full_box ++ + [ + num_of_entries: :uint32, + reserved: <<0::128>>, + width: :uint16, + height: :uint16, + horizresolution: :fp16d16, + vertresolution: :fp16d16, + reserved: <<0::32>>, + frame_count: :uint16, + compressor_name: :str256, + depth: :uint16, + reserved: <<-1::16-integer>> + ], + avcC: [ + black_box?: true + ], + pasp: [ + fields: [ + h_spacing: :uint32, + v_spacing: :uint32 + ] + ] + ] + @schema_def ftyp: [ fields: [ major_brand: :str32, @@ -148,33 +176,8 @@ defmodule Membrane.MP4.Container.Schema do [ entry_count: :uint32 ], - avc1: [ - version: 0, - fields: - @full_box ++ - [ - num_of_entries: :uint32, - reserved: <<0::128>>, - width: :uint16, - height: :uint16, - horizresolution: :fp16d16, - vertresolution: :fp16d16, - reserved: <<0::32>>, - frame_count: :uint16, - compressor_name: :str256, - depth: :uint16, - reserved: <<-1::16-integer>> - ], - avcC: [ - black_box?: true - ], - pasp: [ - fields: [ - h_spacing: :uint32, - v_spacing: :uint32 - ] - ] - ], + avc1: @avc_schema, + avc3: @avc_schema, mp4a: [ fields: [ reserved: <<0::6*8>>, diff --git a/lib/membrane_mp4/movie_box/sample_table_box.ex b/lib/membrane_mp4/movie_box/sample_table_box.ex index 1e1de3a5..443f03a0 100644 --- a/lib/membrane_mp4/movie_box/sample_table_box.ex +++ b/lib/membrane_mp4/movie_box/sample_table_box.ex @@ -69,35 +69,36 @@ defmodule Membrane.MP4.MovieBox.SampleTableBox do end defp assemble_sample_description(%H264{ - stream_structure: {_avc, dcr} = structure, + stream_structure: {avc, dcr} = structure, width: width, height: height }) when H264.is_avc(structure) do [ - avc1: %{ - children: [ - avcC: %{ - content: dcr - }, - pasp: %{ - children: [], - fields: %{h_spacing: 1, v_spacing: 1} - } - ], - fields: %{ - compressor_name: <<0::size(32)-unit(8)>>, - depth: 24, - flags: 0, - frame_count: 1, - height: height, - horizresolution: {0, 0}, - num_of_entries: 1, - version: 0, - vertresolution: {0, 0}, - width: width - } - } + {avc, + %{ + children: [ + avcC: %{ + content: dcr + }, + pasp: %{ + children: [], + fields: %{h_spacing: 1, v_spacing: 1} + } + ], + fields: %{ + compressor_name: <<0::size(32)-unit(8)>>, + depth: 24, + flags: 0, + frame_count: 1, + height: height, + horizresolution: {0, 0}, + num_of_entries: 1, + version: 0, + vertresolution: {0, 0}, + width: width + } + }} ] end @@ -234,11 +235,12 @@ defmodule Membrane.MP4.MovieBox.SampleTableBox do sizes |> Enum.map(fn %{entry_size: size} -> size end) end - defp unpack_sample_description(%{children: [{:avc1, %{children: boxes, fields: fields}}]}) do + defp unpack_sample_description(%{children: [{avc, %{children: boxes, fields: fields}}]}) + when avc in [:avc1, :avc3] do %H264{ width: fields.width, height: fields.height, - stream_structure: {:avc1, boxes[:avcC].content} + stream_structure: {avc, boxes[:avcC].content} } end diff --git a/lib/membrane_mp4/track.ex b/lib/membrane_mp4/track.ex index 80b1b98a..743bdb3c 100644 --- a/lib/membrane_mp4/track.ex +++ b/lib/membrane_mp4/track.ex @@ -84,8 +84,7 @@ defmodule Membrane.MP4.Track do def get_encoding_info(%__MODULE__{ stream_format: %H264{ - stream_structure: - {_avc, <<1, profile, compatibility, level, _rest::binary>>} = structure + stream_structure: {avc, <<1, profile, compatibility, level, _rest::binary>>} = structure } }) when H264.is_avc(structure) do @@ -95,7 +94,7 @@ defmodule Membrane.MP4.Track do level: level } - {:avc1, map} + {avc, map} end def get_encoding_info(_unknown), do: nil diff --git a/mix.exs b/mix.exs index 419b7aaa..83cc8abe 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule Membrane.MP4.Plugin.MixProject do use Mix.Project - @version "0.29.1" + @version "0.30.0" @github_url "https://github.com/membraneframework/membrane_mp4_plugin" def project do