Skip to content

Commit e930a3c

Browse files
Rados13mat-hek
andauthored
Use extended version of cmaf_format and release 0.25.0 (#75)
* Use extended version of cmaf_format * Update lib/membrane_mp4/muxer/cmaf.ex Co-authored-by: Mateusz Front <mfront3@gmail.com> * Use AAC.sampling_frequency_id_to_sample_rate in track.ex * Fix credo issue * Bump version and update deps --------- Co-authored-by: Mateusz Front <mfront3@gmail.com>
1 parent b2e4596 commit e930a3c

File tree

5 files changed

+78
-11
lines changed

5 files changed

+78
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The package can be installed by adding `membrane_mp4_plugin` to your list of dep
1212
```elixir
1313
defp deps do
1414
[
15-
{:membrane_mp4_plugin, "~> 0.24.1"}
15+
{:membrane_mp4_plugin, "~> 0.25.0"}
1616
]
1717
end
1818
```

lib/membrane_mp4/muxer/cmaf.ex

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,15 @@ defmodule Membrane.MP4.Muxer.CMAF do
359359
defp generate_output_stream_format(state) do
360360
tracks = Enum.map(state.pad_to_track_data, fn {_pad, track_data} -> track_data.track end)
361361

362+
resolution =
363+
tracks
364+
|> Enum.find_value(fn
365+
%Track{width: 0} -> nil
366+
track -> {track.width, track.height}
367+
end)
368+
369+
codecs = Map.new(tracks, fn track -> Track.get_encoding_info(track) end)
370+
362371
header = Header.serialize(tracks)
363372

364373
content_type =
@@ -371,7 +380,9 @@ defmodule Membrane.MP4.Muxer.CMAF do
371380

372381
%Membrane.CMAF.Track{
373382
content_type: content_type,
374-
header: header
383+
header: header,
384+
resolution: resolution,
385+
codecs: codecs
375386
}
376387
end
377388

lib/membrane_mp4/track.ex

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ defmodule Membrane.MP4.Track do
77
can be flushed later in form of chunks.
88
"""
99
alias __MODULE__.SampleTable
10+
alias Membrane.AAC
1011
alias Membrane.MP4.Helper
1112

1213
@type t :: %__MODULE__{
@@ -68,6 +69,61 @@ defmodule Membrane.MP4.Track do
6869
|> Map.update!(:sample_table, &SampleTable.reverse/1)
6970
end
7071

72+
@spec get_encoding_info(__MODULE__.t()) ::
73+
{:avc1, %{aot_id: binary(), channels: integer(), frequency: integer()}}
74+
| {:mp4a, %{profile: binary(), compatibiliy: binary(), level: binary()}}
75+
| nil
76+
77+
def get_encoding_info(%__MODULE__{
78+
content: %Membrane.MP4.Payload.AAC{
79+
esds: esds
80+
}
81+
}) do
82+
with <<_elementary_stream_id::16, _priority::8, rest::binary>> <- find_esds_section(3, esds),
83+
<<_section_4::binary-size(13), rest::binary>> <- find_esds_section(4, rest),
84+
<<aot_id::5, frequency_id::4, channel_config_id::4, _rest::bitstring>> <-
85+
find_esds_section(5, rest) do
86+
map = %{
87+
aot_id: aot_id,
88+
channels: channel_config_id,
89+
frequency: AAC.sampling_frequency_id_to_sample_rate(frequency_id)
90+
}
91+
92+
{:mp4a, map}
93+
end
94+
end
95+
96+
def get_encoding_info(%__MODULE__{
97+
content: %Membrane.MP4.Payload.AVC1{
98+
avcc: <<1, profile, compatibility, level, _rest::binary>>
99+
}
100+
}) do
101+
map = %{
102+
profile: profile,
103+
compatibility: compatibility,
104+
level: level
105+
}
106+
107+
{:avc1, map}
108+
end
109+
110+
def get_encoding_info(_unknown), do: nil
111+
112+
defp find_esds_section(section_number, payload) do
113+
case payload do
114+
<<^section_number::8, 128, 128, 128, section_size::8, payload::binary-size(section_size),
115+
__rest::binary>> ->
116+
payload
117+
118+
<<_other_section::8, 128, 128, 128, section_size::8, _payload::binary-size(section_size),
119+
rest::binary>> ->
120+
find_esds_section(section_number, rest)
121+
122+
_other ->
123+
nil
124+
end
125+
end
126+
71127
defp put_durations(track, movie_timescale) do
72128
use Ratio
73129

mix.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule Membrane.MP4.Plugin.MixProject do
22
use Mix.Project
33

4-
@version "0.24.1"
4+
@version "0.25.0"
55
@github_url "https://github.com/membraneframework/membrane_mp4_plugin"
66

77
def project do
@@ -39,7 +39,7 @@ defmodule Membrane.MP4.Plugin.MixProject do
3939
[
4040
{:membrane_core, "~> 0.12.3"},
4141
{:membrane_mp4_format, "~> 0.7.0"},
42-
{:membrane_cmaf_format, "~> 0.6.0"},
42+
{:membrane_cmaf_format, "~> 0.7.0"},
4343
{:membrane_aac_format, "~> 0.7.0"},
4444
{:membrane_h264_format, "~> 0.5.0"},
4545
{:membrane_opus_format, "~> 0.3.0"},

mix.lock

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
"bundlex": {:hex, :bundlex, "1.1.1", "e637b79a1eaab1bf019de4100b6db262aa3b660beff0cd2f3617949b1618eeda", [:mix], [{:bunch, "~> 1.0", [hex: :bunch, repo: "hexpm", optional: false]}, {:qex, "~> 0.5", [hex: :qex, repo: "hexpm", optional: false]}, {:secure_random, "~> 0.5", [hex: :secure_random, repo: "hexpm", optional: false]}], "hexpm", "1fdfa3d6240baa5a2d5496a86e2e43116f80105e93d9adfd4f1fc75be487ea30"},
66
"bunt": {:hex, :bunt, "0.2.1", "e2d4792f7bc0ced7583ab54922808919518d0e57ee162901a16a1b6664ef3b14", [:mix], [], "hexpm", "a330bfb4245239787b15005e66ae6845c9cd524a288f0d141c148b02603777a5"},
77
"coerce": {:hex, :coerce, "1.0.1", "211c27386315dc2894ac11bc1f413a0e38505d808153367bd5c6e75a4003d096", [:mix], [], "hexpm", "b44a691700f7a1a15b4b7e2ff1fa30bebd669929ac8aa43cffe9e2f8bf051cf1"},
8-
"crc": {:hex, :crc, "0.10.4", "06f5f54e2ec2954968703dcd37d7a4c65cee7a5305c48a23c509dc20a5469d4f", [:mix, :rebar3], [{:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "90bdd5b5ac883f0b1860692324ed3f53fdaa6f1e8483771873fea07e71def91d"},
8+
"crc": {:hex, :crc, "0.10.5", "ee12a7c056ac498ef2ea985ecdc9fa53c1bfb4e53a484d9f17ff94803707dfd8", [:mix, :rebar3], [{:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "3e673b6495a9525c5c641585af1accba59a1eb33de697bedf341e247012c2c7f"},
99
"credo": {:hex, :credo, "1.7.0", "6119bee47272e85995598ee04f2ebbed3e947678dee048d10b5feca139435f75", [:mix], [{:bunt, "~> 0.2.1", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "6839fcf63d1f0d1c0f450abc8564a57c43d644077ab96f2934563e68b8a769d7"},
1010
"dialyxir": {:hex, :dialyxir, "1.3.0", "fd1672f0922b7648ff9ce7b1b26fcf0ef56dda964a459892ad15f6b4410b5284", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "00b2a4bcd6aa8db9dcb0b38c1225b7277dca9bc370b6438715667071a304696f"},
11-
"earmark_parser": {:hex, :earmark_parser, "1.4.32", "fa739a0ecfa34493de19426681b23f6814573faee95dfd4b4aafe15a7b5b32c6", [:mix], [], "hexpm", "b8b0dd77d60373e77a3d7e8afa598f325e49e8663a51bcc2b88ef41838cca755"},
11+
"earmark_parser": {:hex, :earmark_parser, "1.4.33", "3c3fd9673bb5dcc9edc28dd90f50c87ce506d1f71b70e3de69aa8154bc695d44", [:mix], [], "hexpm", "2d526833729b59b9fdb85785078697c72ac5e5066350663e5be6a1182da61b8f"},
1212
"elixir_make": {:hex, :elixir_make, "0.7.7", "7128c60c2476019ed978210c245badf08b03dbec4f24d05790ef791da11aa17c", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}], "hexpm", "5bc19fff950fad52bbe5f211b12db9ec82c6b34a9647da0c2224b8b8464c7e6c"},
1313
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
1414
"ex_doc": {:hex, :ex_doc, "0.29.4", "6257ecbb20c7396b1fe5accd55b7b0d23f44b6aa18017b415cb4c2b91d997729", [:mix], [{:earmark_parser, "~> 1.4.31", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "2c6699a737ae46cb61e4ed012af931b57b699643b24dabe2400a8168414bc4f5"},
@@ -19,19 +19,19 @@
1919
"makeup_erlang": {:hex, :makeup_erlang, "0.1.2", "ad87296a092a46e03b7e9b0be7631ddcf64c790fa68a9ef5323b6cbb36affc72", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "f3f5a1ca93ce6e092d92b6d9c049bcda58a3b617a8d888f8e7231c85630e8108"},
2020
"membrane_aac_format": {:hex, :membrane_aac_format, "0.7.0", "93ea75b57d5cbee5db59f0250baba65a8949d32ee4cfa38224e93ea306c30048", [:mix], [{:bimap, "~> 1.1", [hex: :bimap, repo: "hexpm", optional: false]}], "hexpm", "3233d2a5a1b264039a198abcef3b7f1c64f5bde9704ec01afbf1bab43a56d415"},
2121
"membrane_aac_plugin": {:hex, :membrane_aac_plugin, "0.15.0", "070367d3d2e5f5279cd52eb5511bafea7d7a3cf4f14229f0eb66978ffaae0451", [:mix], [{:bunch, "~> 1.0", [hex: :bunch, repo: "hexpm", optional: false]}, {:crc, "~> 0.10.2", [hex: :crc, repo: "hexpm", optional: false]}, {:membrane_aac_format, "~> 0.7.0", [hex: :membrane_aac_format, repo: "hexpm", optional: false]}, {:membrane_core, "~> 0.12.0", [hex: :membrane_core, repo: "hexpm", optional: false]}], "hexpm", "0ba6e70c484a65c6264cdfa70c974c417eaa611341e16136d5ba02991fdda868"},
22-
"membrane_cmaf_format": {:hex, :membrane_cmaf_format, "0.6.1", "89d130b5f8786d4285d395697b0f7763a2c82a02de1658cdeb4f8e37e6a6c85c", [:mix], [], "hexpm", "e916e3c8216f3bf999b069ffda94da48c9bdbe3181ce7155a458d1ccf1a97b3d"},
22+
"membrane_cmaf_format": {:hex, :membrane_cmaf_format, "0.7.0", "573bfff6acf2371c5046b9174569f6316f4205e3d6e13e814bf7e613e5653a54", [:mix], [], "hexpm", "4ac6a24a33f61347a2714c982a5f84aa6207641f4de2ad5afde68a8b800da8de"},
2323
"membrane_common_c": {:hex, :membrane_common_c, "0.15.0", "4b6005c562bf025e4a53c95a9646a9f5fa993ac440dd44c1a4d1ea210ec53793", [:mix], [{:membrane_core, "~> 0.12.0", [hex: :membrane_core, repo: "hexpm", optional: false]}, {:shmex, "~> 0.5.0", [hex: :shmex, repo: "hexpm", optional: false]}, {:unifex, "~> 1.0", [hex: :unifex, repo: "hexpm", optional: false]}], "hexpm", "f9584cca9865ed754b8333e362d49d6c449c708d7c87be6c5f7bd5a1d978d6bf"},
24-
"membrane_core": {:hex, :membrane_core, "0.12.3", "0df89535fa485dded43a1d813e482f3a93978a4e94debdd135b4170db953e21a", [:mix], [{:bunch, "~> 1.6", [hex: :bunch, repo: "hexpm", optional: false]}, {:qex, "~> 0.3", [hex: :qex, repo: "hexpm", optional: false]}, {:ratio, "~> 2.0", [hex: :ratio, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "4e7b6148c746ced53b1cd11a11a7d5464fbe4844baaf9cde4d7b08d32b03df52"},
24+
"membrane_core": {:hex, :membrane_core, "0.12.5", "098733b1677bd9235a74fc3dabcdff5459d879466c7dc4b862e485c161153947", [:mix], [{:bunch, "~> 1.6", [hex: :bunch, repo: "hexpm", optional: false]}, {:qex, "~> 0.3", [hex: :qex, repo: "hexpm", optional: false]}, {:ratio, "~> 2.0", [hex: :ratio, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "59ecef38a9c184a41810d23dfc77b899717538dd0a177bdbd57383c199f7675b"},
2525
"membrane_file_plugin": {:hex, :membrane_file_plugin, "0.14.0", "87f19f5f5afbfbaf2219b8f1d8496534cb9ad01fca74687910bf3f7aa866e244", [:mix], [{:membrane_core, "~> 0.12.0", [hex: :membrane_core, repo: "hexpm", optional: false]}], "hexpm", "28956f8d5d87735d499c57f1c24f62aeab71e0211863759e7e695ead966eb433"},
2626
"membrane_h264_ffmpeg_plugin": {:hex, :membrane_h264_ffmpeg_plugin, "0.27.0", "4fced15b5791b87758869537770d00b39d103d1239ef7311f4a883e036d83d7b", [:mix], [{:bunch, "~> 1.6", [hex: :bunch, repo: "hexpm", optional: false]}, {:membrane_common_c, "~> 0.15.0", [hex: :membrane_common_c, repo: "hexpm", optional: false]}, {:membrane_core, "~> 0.12.0", [hex: :membrane_core, repo: "hexpm", optional: false]}, {:membrane_h264_format, "~> 0.5.0", [hex: :membrane_h264_format, repo: "hexpm", optional: false]}, {:membrane_raw_video_format, "~> 0.3.0", [hex: :membrane_raw_video_format, repo: "hexpm", optional: false]}, {:ratio, "~> 2.4.0", [hex: :ratio, repo: "hexpm", optional: false]}, {:unifex, "~> 1.1", [hex: :unifex, repo: "hexpm", optional: false]}], "hexpm", "031887921970f793d11bfd2e2ed36ba6c3010b17c61a4702bcf50028431786dc"},
2727
"membrane_h264_format": {:hex, :membrane_h264_format, "0.5.0", "95c1cc00896dab6de322cee3be0c9b0b0840537b4cc49e82a34e901b4e4763f9", [:mix], [], "hexpm", "7b44e0b02d86b45d24699de3c970186dffbca6d51aca80bbed2f6a3fe5c9eba1"},
2828
"membrane_h264_plugin": {:hex, :membrane_h264_plugin, "0.4.1", "73f4019a298091605fc34f21296328cae81d1223991ae4cb1aae96509f6e20b9", [:mix], [{:bunch, "~> 1.4", [hex: :bunch, repo: "hexpm", optional: false]}, {:membrane_core, "~> 0.12.0", [hex: :membrane_core, repo: "hexpm", optional: false]}, {:membrane_h264_format, "~> 0.5.0", [hex: :membrane_h264_format, repo: "hexpm", optional: false]}], "hexpm", "4593d6f43e4a4829dd35c1d7e5405c411b42aa0a11fd0548e337852407ad3118"},
2929
"membrane_mp4_format": {:hex, :membrane_mp4_format, "0.7.0", "0cc33f21dc571b43b4d2db66a056e2b7eecdc7ada71a9e0e923ab7a1554f15f2", [:mix], [], "hexpm", "7653a20e7b0c048ea05ffad6df88249abf4c1b63772c14dee843acffcad6b038"},
3030
"membrane_opus_format": {:hex, :membrane_opus_format, "0.3.0", "3804d9916058b7cfa2baa0131a644d8186198d64f52d592ae09e0942513cb4c2", [:mix], [], "hexpm", "8fc89c97be50de23ded15f2050fe603dcce732566fe6fdd15a2de01cb6b81afe"},
31-
"membrane_opus_plugin": {:hex, :membrane_opus_plugin, "0.17.0", "d14ce3b6dd75269c5e9cd5ee61913d75db91a312da0b32847cc8887c5866495f", [:mix], [{:bunch, "~> 1.3", [hex: :bunch, repo: "hexpm", optional: false]}, {:membrane_common_c, "~> 0.15.0", [hex: :membrane_common_c, repo: "hexpm", optional: false]}, {:membrane_core, "~> 0.12.0", [hex: :membrane_core, repo: "hexpm", optional: false]}, {:membrane_opus_format, "~> 0.3.0", [hex: :membrane_opus_format, repo: "hexpm", optional: false]}, {:membrane_raw_audio_format, "~> 0.10.0", [hex: :membrane_raw_audio_format, repo: "hexpm", optional: false]}, {:unifex, "~> 1.0", [hex: :unifex, repo: "hexpm", optional: false]}], "hexpm", "f74275ae2f83fde238dd9334a27a14a7edcfa2eee818d4d0a64ad66cc4409c5e"},
32-
"membrane_raw_audio_format": {:hex, :membrane_raw_audio_format, "0.10.0", "4ff07002d95b8e9259c38991ead8d98e907ee66346545c168b8a8ad6ae73d87e", [:mix], [{:bimap, "~> 1.1", [hex: :bimap, repo: "hexpm", optional: false]}, {:bunch, "~> 1.0", [hex: :bunch, repo: "hexpm", optional: false]}, {:membrane_core, "~> 0.11", [hex: :membrane_core, repo: "hexpm", optional: false]}], "hexpm", "d5b4201d0e634e9fdbc2b9528f1fee245eb667c82ace91c745af6604401003ae"},
31+
"membrane_opus_plugin": {:hex, :membrane_opus_plugin, "0.17.1", "533d694d8c6f38fbf7f09a514e16037e8980d167899d4c35cb5017b088122ce9", [:mix], [{:bunch, "~> 1.3", [hex: :bunch, repo: "hexpm", optional: false]}, {:membrane_common_c, "~> 0.15.0", [hex: :membrane_common_c, repo: "hexpm", optional: false]}, {:membrane_core, "~> 0.12.3", [hex: :membrane_core, repo: "hexpm", optional: false]}, {:membrane_opus_format, "~> 0.3.0", [hex: :membrane_opus_format, repo: "hexpm", optional: false]}, {:membrane_raw_audio_format, "~> 0.11.0", [hex: :membrane_raw_audio_format, repo: "hexpm", optional: false]}, {:unifex, "~> 1.0", [hex: :unifex, repo: "hexpm", optional: false]}], "hexpm", "8d2bf3d97651f136fd393ce80c099a4f282bbe1dfafde887f8ab18668fd349aa"},
32+
"membrane_raw_audio_format": {:hex, :membrane_raw_audio_format, "0.11.0", "9b7e8c77f321a3fa1cac2ef157c897938084b704a90ac5450d9f5c87a249b613", [:mix], [{:bimap, "~> 1.1", [hex: :bimap, repo: "hexpm", optional: false]}, {:bunch, "~> 1.0", [hex: :bunch, repo: "hexpm", optional: false]}, {:membrane_core, "~> 0.12.0", [hex: :membrane_core, repo: "hexpm", optional: false]}], "hexpm", "89e0d46893b7cd63d1ab76467d3aae95bd8081e487b18ab0d1679c70d75f7bd8"},
3333
"membrane_raw_video_format": {:hex, :membrane_raw_video_format, "0.3.0", "ba10f475e0814a6fe79602a74536b796047577c7ef5b0e33def27cd344229699", [:mix], [], "hexpm", "2f08760061c8a5386ecf04273480f10e48d25a1a40aa99476302b0bcd34ccb1c"},
34-
"membrane_stream_plugin": {:hex, :membrane_stream_plugin, "0.3.0", "b3ccececca81b79b0b7718ab90a8d5030e5802cb4675897dec2800dc8b1d7e32", [:mix], [{:membrane_core, "~> 0.12.0", [hex: :membrane_core, repo: "hexpm", optional: false]}], "hexpm", "bf980ef0dd3316e6b585abb5d65c08e982d033a81eecd618ffede540ddfa5368"},
34+
"membrane_stream_plugin": {:hex, :membrane_stream_plugin, "0.3.1", "265f327dad815a8ef18f8872bdebc6c1aa1fea3d059446c937b76ff067c166e6", [:mix], [{:membrane_core, "~> 0.12.0", [hex: :membrane_core, repo: "hexpm", optional: false]}], "hexpm", "b504296b9f5a78b43c0d46ad66202a1f0f93d4c122949c27ad4c04f67f3c5907"},
3535
"nimble_parsec": {:hex, :nimble_parsec, "1.3.1", "2c54013ecf170e249e9291ed0a62e5832f70a476c61da16f6aac6dca0189f2af", [:mix], [], "hexpm", "2682e3c0b2eb58d90c6375fc0cc30bc7be06f365bf72608804fb9cffa5e1b167"},
3636
"numbers": {:hex, :numbers, "5.2.4", "f123d5bb7f6acc366f8f445e10a32bd403c8469bdbce8ce049e1f0972b607080", [:mix], [{:coerce, "~> 1.0", [hex: :coerce, repo: "hexpm", optional: false]}, {:decimal, "~> 1.9 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "eeccf5c61d5f4922198395bf87a465b6f980b8b862dd22d28198c5e6fab38582"},
3737
"qex": {:hex, :qex, "0.5.1", "0d82c0f008551d24fffb99d97f8299afcb8ea9cf99582b770bd004ed5af63fd6", [:mix], [], "hexpm", "935a39fdaf2445834b95951456559e9dc2063d0a055742c558a99987b38d6bab"},

0 commit comments

Comments
 (0)