Skip to content

Commit

Permalink
use the new parser
Browse files Browse the repository at this point in the history
  • Loading branch information
mat-hek committed Aug 16, 2023
1 parent f37ea37 commit fd44a5d
Show file tree
Hide file tree
Showing 14 changed files with 41 additions and 49 deletions.
1 change: 0 additions & 1 deletion examples/demuxer_isom.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
Mix.install([
:membrane_aac_plugin,
:membrane_h264_ffmpeg_plugin,
:membrane_hackney_plugin,
{:membrane_mp4_plugin, path: __DIR__ |> Path.join("..") |> Path.expand()}
])
Expand Down
8 changes: 3 additions & 5 deletions examples/muxer_cmaf.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Mix.install([
:membrane_aac_plugin,
:membrane_h264_ffmpeg_plugin,
:membrane_h264_plugin,
:membrane_hackney_plugin,
:membrane_http_adaptive_stream_plugin,
{:membrane_mp4_plugin, path: __DIR__ |> Path.join("..") |> Path.expand()}
Expand Down Expand Up @@ -28,10 +28,8 @@ defmodule Example do
location: @video_url,
hackney_opts: [follow_redirect: true]
})
|> child(:video_parser, %Membrane.H264.FFmpeg.Parser{
framerate: {25, 1},
alignment: :au,
attach_nalus?: true
|> child(:video_parser, %Membrane.H264.Parser{
generate_best_effort_timestamps: %{framerate: {25, 1}}
})
|> child(:video_payloader, Membrane.MP4.Payloader.H264)
|> via_in(Pad.ref(:input, :video))
Expand Down
8 changes: 3 additions & 5 deletions examples/muxer_isom.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Mix.install([
:membrane_aac_plugin,
:membrane_h264_ffmpeg_plugin,
:membrane_h264_plugin,
:membrane_hackney_plugin,
{:membrane_mp4_plugin, path: __DIR__ |> Path.join("..") |> Path.expand()}
])
Expand All @@ -20,10 +20,8 @@ defmodule Example do
location: @video_url,
hackney_opts: [follow_redirect: true]
})
|> child(:video_parser, %Membrane.H264.FFmpeg.Parser{
framerate: {30, 1},
alignment: :au,
attach_nalus?: true
|> child(:video_parser, %Membrane.H264.Parser{
generate_best_effort_timestamps: %{framerate: {30, 1}}
})
|> child(:video_payloader, Membrane.MP4.Payloader.H264),
child(:audio_source, %Membrane.Hackney.Source{
Expand Down
2 changes: 1 addition & 1 deletion lib/membrane_mp4/depayloader/h264.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ defmodule Membrane.MP4.Depayloader.H264 do
spec =
bin_input()
|> child(:remote_stream_depayloader, Depayloader.H264.Filter)
|> child(:parser, %Parser{skip_until_keyframe?: true})
|> child(:parser, Parser)
|> bin_output()

{[spec: spec], %{}}
Expand Down
3 changes: 1 addition & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ defmodule Membrane.MP4.Plugin.MixProject do
{:membrane_aac_format, "~> 0.7.0"},
{:membrane_h264_format, "~> 0.5.0"},
{:membrane_opus_format, "~> 0.3.0"},
{:membrane_h264_plugin, "~> 0.5.0"},
{:membrane_h264_plugin, "~> 0.6.0"},
{:bunch, "~> 1.5"},
{:membrane_file_plugin, "~> 0.15.0"},
{:membrane_h264_ffmpeg_plugin, "~> 0.27.0", only: :test},
{:membrane_aac_plugin, "~> 0.15.0", only: :test},
{:membrane_opus_plugin, "~> 0.17.0", only: :test},
{:membrane_stream_plugin, "~> 0.3.0", only: :test},
Expand Down
4 changes: 1 addition & 3 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@
"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"},
"membrane_core": {:hex, :membrane_core, "0.12.7", "9d3dd564e32768919c1105b4579bd2eef12df7473da5d789185544ae22610e2d", [: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", "321e4009b7068ca04b65daf5c79b8c3772d4286c27d05e50939ec6d9b4d50e59"},
"membrane_file_plugin": {:hex, :membrane_file_plugin, "0.15.0", "ddf9535fda82aae5b0688a98de1d02268287ffc8bcc6dba1a85e057d71c522af", [:mix], [{:membrane_core, "~> 0.12.0", [hex: :membrane_core, repo: "hexpm", optional: false]}], "hexpm", "fa2f7219f96c9e815475dc0d8c238c0a5648012917584756eb3eee476f737ce2"},
"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"},
"membrane_h264_format": {:hex, :membrane_h264_format, "0.5.0", "95c1cc00896dab6de322cee3be0c9b0b0840537b4cc49e82a34e901b4e4763f9", [:mix], [], "hexpm", "7b44e0b02d86b45d24699de3c970186dffbca6d51aca80bbed2f6a3fe5c9eba1"},
"membrane_h264_plugin": {:hex, :membrane_h264_plugin, "0.5.0", "1deaf61e9194aeb9641721043aad82fbc43600b9938bc3eece739dbf273d87b9", [:mix], [{:bunch, "~> 1.4", [hex: :bunch, repo: "hexpm", optional: false]}, {:membrane_core, "~> 0.12.7", [hex: :membrane_core, repo: "hexpm", optional: false]}, {:membrane_h264_format, "~> 0.5.0", [hex: :membrane_h264_format, repo: "hexpm", optional: false]}], "hexpm", "d4f6b0cf2500e043cbf61272eadedc89fbc4b284f9ba5eaa999906efa6db2489"},
"membrane_h264_plugin": {:hex, :membrane_h264_plugin, "0.6.0", "0ad95da388f3e885fe75d778e2e634854626bd73a6b3bbe1465137cb3299c8cd", [:mix], [{:bunch, "~> 1.4", [hex: :bunch, repo: "hexpm", optional: false]}, {:membrane_core, "~> 0.12.7", [hex: :membrane_core, repo: "hexpm", optional: false]}, {:membrane_h264_format, "~> 0.5.0", [hex: :membrane_h264_format, repo: "hexpm", optional: false]}], "hexpm", "392be4b151cab137f40bba0589e69ac28f53e8dd9687b5e38a465ba2000050be"},
"membrane_mp4_format": {:hex, :membrane_mp4_format, "0.7.0", "0cc33f21dc571b43b4d2db66a056e2b7eecdc7ada71a9e0e923ab7a1554f15f2", [:mix], [], "hexpm", "7653a20e7b0c048ea05ffad6df88249abf4c1b63772c14dee843acffcad6b038"},
"membrane_opus_format": {:hex, :membrane_opus_format, "0.3.0", "3804d9916058b7cfa2baa0131a644d8186198d64f52d592ae09e0942513cb4c2", [:mix], [], "hexpm", "8fc89c97be50de23ded15f2050fe603dcce732566fe6fdd15a2de01cb6b81afe"},
"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"},
"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"},
"membrane_raw_video_format": {:hex, :membrane_raw_video_format, "0.3.0", "ba10f475e0814a6fe79602a74536b796047577c7ef5b0e33def27cd344229699", [:mix], [], "hexpm", "2f08760061c8a5386ecf04273480f10e48d25a1a40aa99476302b0bcd34ccb1c"},
"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"},
"nimble_parsec": {:hex, :nimble_parsec, "1.3.1", "2c54013ecf170e249e9291ed0a62e5832f70a476c61da16f6aac6dca0189f2af", [:mix], [], "hexpm", "2682e3c0b2eb58d90c6375fc0cc30bc7be06f365bf72608804fb9cffa5e1b167"},
"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"},
Expand Down
Binary file modified test/fixtures/cmaf/muxed_audio_video/segment_1.m4s
Binary file not shown.
Binary file modified test/fixtures/cmaf/muxed_audio_video/segment_2.m4s
Binary file not shown.
Binary file modified test/fixtures/cmaf/ref_video_segment1.m4s
Binary file not shown.
Binary file modified test/fixtures/cmaf/ref_video_segment2.m4s
Binary file not shown.
9 changes: 5 additions & 4 deletions test/membrane_mp4/demuxer/isom/integration_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ defmodule Membrane.MP4.Demuxer.ISOM.IntegrationTest do

muxing_spec = [
child(:file, %Membrane.File.Source{location: in_path})
|> child(:parser, %Membrane.H264.FFmpeg.Parser{framerate: {30, 1}, attach_nalus?: true})
|> child(:parser, %Membrane.H264.Parser{
generate_best_effort_timestamps: %{framerate: {30, 1}}
})
|> child(:payloader, Membrane.MP4.Payloader.H264)
|> child(:muxer, %Membrane.MP4.Muxer.ISOM{
chunk_duration: Membrane.Time.seconds(1),
Expand Down Expand Up @@ -93,9 +95,8 @@ defmodule Membrane.MP4.Demuxer.ISOM.IntegrationTest do

muxing_spec = [
child(:file_video, %Membrane.File.Source{location: in_video_path})
|> child(:video_parser, %Membrane.H264.FFmpeg.Parser{
framerate: {30, 1},
attach_nalus?: true
|> child(:video_parser, %Membrane.H264.Parser{
generate_best_effort_timestamps: %{framerate: {30, 1}}
})
|> child(:video_payloader, Membrane.MP4.Payloader.H264)
|> child(:muxer, %Membrane.MP4.Muxer.ISOM{
Expand Down
25 changes: 8 additions & 17 deletions test/membrane_mp4/muxer/cmaf/integration_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,8 @@ defmodule Membrane.MP4.Muxer.CMAF.IntegrationTest do
|> child(:audio_parser, %Membrane.AAC.Parser{out_encapsulation: :none})
|> child(:audio_payloader, Membrane.MP4.Payloader.AAC),
child(:video_source, %Membrane.File.Source{location: "test/fixtures/in_video.h264"})
|> child(:video_parser, %Membrane.H264.FFmpeg.Parser{
framerate: {30, 1},
attach_nalus?: true,
max_frame_reorder: 0
|> child(:video_parser, %Membrane.H264.Parser{
generate_best_effort_timestamps: %{framerate: {30, 1}}
})
|> child(:video_payloader, Membrane.MP4.Payloader.H264),
child(:cmaf, %Membrane.MP4.Muxer.CMAF{
Expand Down Expand Up @@ -185,10 +183,10 @@ defmodule Membrane.MP4.Muxer.CMAF.IntegrationTest do
|> child(:audio_payloader, Membrane.MP4.Payloader.AAC),
# NOTE: keyframes are every 2 seconds
child(:video_source, %Membrane.File.Source{location: "test/fixtures/in_video_gop_30.h264"})
|> child(:video_parser, %Membrane.H264.FFmpeg.Parser{
framerate: {30, 1},
attach_nalus?: true,
max_frame_reorder: 0
|> child(:video_parser, %Membrane.H264.Parser{
# TODO: This test fails without `add_dts_offset: false` and it seems like a bug
# in the muxer
generate_best_effort_timestamps: %{framerate: {30, 1}, add_dts_offset: false}
})
|> child(:video_payloader, Membrane.MP4.Payloader.H264),
child(:cmaf, %Membrane.MP4.Muxer.CMAF{
Expand Down Expand Up @@ -338,15 +336,8 @@ defmodule Membrane.MP4.Muxer.CMAF.IntegrationTest do

parser =
case type do
:audio ->
%Membrane.AAC.Parser{out_encapsulation: :none}

:video ->
%Membrane.H264.FFmpeg.Parser{
framerate: {30, 1},
attach_nalus?: true,
max_frame_reorder: 0
}
:audio -> %Membrane.AAC.Parser{out_encapsulation: :none}
:video -> %Membrane.H264.Parser{generate_best_effort_timestamps: %{framerate: {30, 1}}}
end

payloader =
Expand Down
26 changes: 16 additions & 10 deletions test/membrane_mp4/muxer/isom/integration_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ defmodule Membrane.MP4.Muxer.ISOM.IntegrationTest do

structure = [
child(:file, %Membrane.File.Source{location: "test/fixtures/in_video.h264"})
|> child(:parser, %Membrane.H264.FFmpeg.Parser{framerate: {30, 1}, attach_nalus?: true})
|> child(:parser, %Membrane.H264.Parser{
generate_best_effort_timestamps: %{framerate: {30, 1}}
})
|> child(:payloader, Membrane.MP4.Payloader.H264)
|> child(:muxer, %Membrane.MP4.Muxer.ISOM{chunk_duration: Time.seconds(1)})
|> child(:sink, %Membrane.File.Sink{location: out_path_for("video")})
Expand Down Expand Up @@ -97,9 +99,8 @@ defmodule Membrane.MP4.Muxer.ISOM.IntegrationTest do

structure = [
child(:video_file, %Membrane.File.Source{location: "test/fixtures/in_video.h264"})
|> child(:video_parser, %Membrane.H264.FFmpeg.Parser{
framerate: {30, 1},
attach_nalus?: true
|> child(:video_parser, %Membrane.H264.Parser{
generate_best_effort_timestamps: %{framerate: {30, 1}}
})
|> child(:video_payloader, Membrane.MP4.Payloader.H264),
child(:audio_file, %Membrane.File.Source{location: "test/fixtures/in_audio.aac"})
Expand All @@ -123,7 +124,9 @@ defmodule Membrane.MP4.Muxer.ISOM.IntegrationTest do

structure = [
child(:file, %Membrane.File.Source{location: "test/fixtures/in_video.h264"})
|> child(:parser, %Membrane.H264.FFmpeg.Parser{framerate: {30, 1}, attach_nalus?: true})
|> child(:parser, %Membrane.H264.Parser{
generate_best_effort_timestamps: %{framerate: {30, 1}}
})
|> child(:payloader, Membrane.MP4.Payloader.H264)
|> child(:muxer, %Membrane.MP4.Muxer.ISOM{
chunk_duration: Time.seconds(1),
Expand Down Expand Up @@ -161,9 +164,8 @@ defmodule Membrane.MP4.Muxer.ISOM.IntegrationTest do

structure = [
child(:video_file, %Membrane.File.Source{location: "test/fixtures/in_video.h264"})
|> child(:video_parser, %Membrane.H264.FFmpeg.Parser{
framerate: {30, 1},
attach_nalus?: true
|> child(:video_parser, %Membrane.H264.Parser{
generate_best_effort_timestamps: %{framerate: {30, 1}}
})
|> child(:video_payloader, Membrane.MP4.Payloader.H264),
child(:audio_file, %Membrane.File.Source{location: "test/fixtures/in_audio.aac"})
Expand All @@ -185,7 +187,9 @@ defmodule Membrane.MP4.Muxer.ISOM.IntegrationTest do
test "raise when stream format's inband_parameters are not used" do
structure = [
child(:file, %Membrane.File.Source{location: "test/fixtures/in_video_vp.h264"})
|> child(:parser, %Membrane.H264.FFmpeg.Parser{framerate: {30, 1}, attach_nalus?: true})
|> child(:parser, %Membrane.H264.Parser{
generate_best_effort_timestamps: %{framerate: {30, 1}}
})
|> child(:payloader, Membrane.MP4.Payloader.H264)
|> child(:muxer, %Membrane.MP4.Muxer.ISOM{
chunk_duration: Time.seconds(1),
Expand All @@ -209,7 +213,9 @@ defmodule Membrane.MP4.Muxer.ISOM.IntegrationTest do

structure = [
child(:file, %Membrane.File.Source{location: "test/fixtures/in_video_vp.h264"})
|> child(:parser, %Membrane.H264.FFmpeg.Parser{framerate: {30, 1}, attach_nalus?: true})
|> child(:parser, %Membrane.H264.Parser{
generate_best_effort_timestamps: %{framerate: {30, 1}}
})
|> child(:payloader, %Membrane.MP4.Payloader.H264{parameters_in_band?: true})
|> child(:muxer, %Membrane.MP4.Muxer.ISOM{
chunk_duration: Time.seconds(1),
Expand Down
4 changes: 3 additions & 1 deletion test/membrane_mp4/payloader_depayloader_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ defmodule Membrane.MP4.PayloaderDepayloaderTest do

spec = [
child(:file, %Membrane.File.Source{location: in_path})
|> child(:parser, %Membrane.H264.FFmpeg.Parser{framerate: {30, 1}, attach_nalus?: true})
|> child(:parser, %Membrane.H264.Parser{
generate_best_effort_timestamps: %{framerate: {30, 1}}
})
|> child(:payloader, Membrane.MP4.Payloader.H264)
|> child(:depayloader, Membrane.MP4.Depayloader.H264)
|> child(:sink, %Membrane.File.Sink{location: out_path})
Expand Down

0 comments on commit fd44a5d

Please sign in to comment.