diff --git a/README.md b/README.md index a113b4a..525cb79 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ The package can be installed by adding `membrane_aac_fdk_plugin` to your list of ```elixir def deps do [ - {:membrane_aac_fdk_plugin, "~> 0.18.4"} + {:membrane_aac_fdk_plugin, "~> 0.18.5"} ] end ``` diff --git a/lib/membrane_aac_fdk_plugin/encoder.ex b/lib/membrane_aac_fdk_plugin/encoder.ex index ba2d48d..f377ad1 100644 --- a/lib/membrane_aac_fdk_plugin/encoder.ex +++ b/lib/membrane_aac_fdk_plugin/encoder.ex @@ -132,7 +132,11 @@ defmodule Membrane.AAC.FDK.Encoder do encapsulation: :ADTS } - {[stream_format: {:output, out_format}], %{state | native: native}} + {[stream_format: {:output, out_format}], + Map.merge(state, %{ + native: native, + input_stream_format: format + })} end @impl true @@ -157,9 +161,8 @@ defmodule Membrane.AAC.FDK.Encoder do {encoded_buffers, bytes_used, state} when bytes_used > 0 -> <<_handled::binary-size(bytes_used), rest::binary>> = to_encode - if check_pts_integrity? and length(encoded_buffers) >= 2 and - Enum.at(encoded_buffers, 1).pts > input_pts do - Membrane.Logger.warning("PTS values are overlapping") + if check_pts_integrity? do + validate_pts_integrity(encoded_buffers, input_pts) end {[buffer: {:output, encoded_buffers}], %{state | queue: rest}} @@ -270,4 +273,19 @@ defmodule Membrane.AAC.FDK.Encoder do defp validate_bitrate_mode!(bitrate_mode) do raise "Invalid bitrate_mode: #{inspect(bitrate_mode)}" end + + defp validate_pts_integrity(packets, input_pts) do + cond do + length(packets) < 2 or Enum.at(packets, 1).pts == input_pts -> + :ok + + Enum.at(packets, 1).pts > input_pts -> + Membrane.Logger.warning("PTS values are overlapping") + :ok + + Enum.at(packets, 1).pts < input_pts -> + Membrane.Logger.warning("PTS values are not continous") + :ok + end + end end diff --git a/mix.exs b/mix.exs index 82cc949..f60a913 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule Membrane.AAC.FDK.Plugin.MixProject do use Mix.Project - @version "0.18.4" + @version "0.18.5" @github_url "https://github.com/membraneframework/membrane_aac_fdk_plugin" def project do