From b397a37923899d3ee38341756d6e3693e1a9242e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Feliks=20Pobiedzi=C5=84ski?= <38541925+FelonEkonom@users.noreply.github.com> Date: Mon, 20 Nov 2023 10:31:40 +0100 Subject: [PATCH] Release membrane_camera_capture_plugin v0.7.0 (#19) * bump to 0.7.0 * update readme * update to core 1.0 API * update readme --------- Co-authored-by: Mateusz Front --- README.md | 8 +++----- lib/membrane_camera_capture_plugin/camera.ex | 9 +++------ mix.exs | 9 ++++----- mix.lock | 14 ++++++-------- .../camera_capture_plugin_test.exs | 19 +++++++------------ 5 files changed, 23 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index b746c17..5e0dcf2 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ It is part of [Membrane Multimedia Framework](https://membraneframework.org). Add the following line to your `deps` in `mix.exs`. Run `mix deps.get`. ```elixir - {:membrane_camera_capture_plugin, "~> 0.6.1"} + {:membrane_camera_capture_plugin, "~> 0.7.0"} ``` This package depends on the [ffmpeg](https://www.ffmpeg.org) libraries. The precompiled builds will be pulled and linked automatically. However, should there be any problems, consider installing it manually. @@ -44,7 +44,7 @@ Dependencies: ```elixir def deps do [ - {:membrane_camera_capture_plugin, "~> 0.5.0"} + {:membrane_camera_capture_plugin, "~> 0.7.0"} {:membrane_h264_ffmpeg_plugin, "~> 0.21"}, {:membrane_file_plugin, "~> 0.10"}, {:membrane_ffmpeg_swscale_plugin, "~> 0.10"} @@ -71,8 +71,6 @@ end ## Testing -Running this manual test, you should be able to record a 5-sec long video stream from your webcam and then play it using ffplay (you need to have ffmpeg installed). - To run manual tests, you need to install dependencies: ```shell @@ -85,7 +83,7 @@ And run manual (you observe the result and decide whether it works) tests: $ mix test --include manual ``` -If run successfully, you should be able to see video recorded by your camera. +If it runs successfully, you should be able to see video from your camera. _You might be asked to grant access to your camera, as some operating systems require that_ diff --git a/lib/membrane_camera_capture_plugin/camera.ex b/lib/membrane_camera_capture_plugin/camera.ex index bbed58b..eeba745 100644 --- a/lib/membrane_camera_capture_plugin/camera.ex +++ b/lib/membrane_camera_capture_plugin/camera.ex @@ -7,10 +7,7 @@ defmodule Membrane.CameraCapture do alias __MODULE__.Native alias Membrane.Buffer - def_output_pad :output, - accepted_format: _any, - availability: :always, - mode: :push + def_output_pad :output, accepted_format: _any, flow_control: :push def_options device: [ spec: String.t(), @@ -26,7 +23,7 @@ defmodule Membrane.CameraCapture do @impl true def handle_init(_ctx, %__MODULE__{} = options) do with {:ok, native} <- Native.open(options.device, options.framerate) do - state = %{native: native, provider: nil} + state = %{native: native, provider: nil, framerate: options.framerate} {[], state} end end @@ -40,7 +37,7 @@ defmodule Membrane.CameraCapture do height: height, pixel_format: pixel_format_to_atom(pixel_format), aligned: true, - framerate: {30, 1} + framerate: {state.framerate, 1} } my_pid = self() diff --git a/mix.exs b/mix.exs index de06090..3803f70 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule Membrane.CameraCapture.Mixfile do use Mix.Project - @version "0.6.1" + @version "0.7.0" @github_url "https://github.com/membraneframework/membrane_camera_capture_plugin" def project do @@ -38,16 +38,15 @@ defmodule Membrane.CameraCapture.Mixfile do defp deps do [ - {:membrane_core, "~> 0.12.0"}, + {:membrane_core, "~> 1.0"}, {:bundlex, "~> 1.2"}, {:unifex, "~> 1.0"}, {:membrane_raw_video_format, "~> 0.3.0"}, {:ex_doc, ">= 0.0.0", only: :dev, runtime: false}, {:dialyxir, ">= 0.0.0", only: :dev, runtime: false}, {:credo, ">= 0.0.0", only: :dev, runtime: false}, - {:membrane_h264_ffmpeg_plugin, "~> 0.30.0", only: :test}, - {:membrane_file_plugin, "~> 0.14.0", only: :test}, - {:membrane_ffmpeg_swscale_plugin, "~> 0.14.0", only: :test} + {:membrane_ffmpeg_swscale_plugin, "~> 0.15.0", only: :test}, + {:membrane_sdl_plugin, ">= 0.0.0", only: :test} ] end diff --git a/mix.lock b/mix.lock index 0acbc5f..e0a19e2 100644 --- a/mix.lock +++ b/mix.lock @@ -17,13 +17,11 @@ "makeup": {:hex, :makeup, "1.1.0", "6b67c8bc2882a6b6a445859952a602afc1a41c2e08379ca057c0f525366fc3ca", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "0a45ed501f4a8897f580eabf99a2e5234ea3e75a4373c8a52824f6e873be57a6"}, "makeup_elixir": {:hex, :makeup_elixir, "0.16.1", "cc9e3ca312f1cfeccc572b37a09980287e243648108384b97ff2b76e505c3555", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "e127a341ad1b209bd80f7bd1620a15693a9908ed780c3b763bccf7d200c767c6"}, "makeup_erlang": {:hex, :makeup_erlang, "0.1.2", "ad87296a092a46e03b7e9b0be7631ddcf64c790fa68a9ef5323b6cbb36affc72", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "f3f5a1ca93ce6e092d92b6d9c049bcda58a3b617a8d888f8e7231c85630e8108"}, - "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.9", "b80239deacf98f24cfd2e0703b632e92ddded8b989227cd6e724140f433b0aac", [: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", "389b4b22da0e35d5b053ec2fa87bf36882e0ab88f8fb841af895982fb4abe504"}, - "membrane_ffmpeg_swscale_plugin": {:hex, :membrane_ffmpeg_swscale_plugin, "0.14.0", "593eba6f7d66adaa45fd4ab4ce84971905b8f0c16343c818ce9cf2225941720f", [:mix], [{:bundlex, "~> 1.2", [hex: :bundlex, repo: "hexpm", optional: false]}, {:membrane_common_c, "~> 0.15.0", [hex: :membrane_common_c, repo: "hexpm", optional: false]}, {:membrane_core, "~> 0.12.8", [hex: :membrane_core, repo: "hexpm", optional: false]}, {:membrane_raw_video_format, "~> 0.3.0", [hex: :membrane_raw_video_format, repo: "hexpm", optional: false]}], "hexpm", "27f29d594189070b2a97082d9be888dc0cf6b1fd8f3911abc08705579caa6a9c"}, - "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"}, - "membrane_h264_ffmpeg_plugin": {:hex, :membrane_h264_ffmpeg_plugin, "0.30.1", "68d9de925c9fa040be08852474ce6deae1fa3e0274d128abb00d8407d8faa90f", [:mix], [{:bunch, "~> 1.6", [hex: :bunch, repo: "hexpm", optional: false]}, {:bundlex, "~> 1.2.0", [hex: :bundlex, repo: "hexpm", optional: false]}, {:membrane_common_c, "~> 0.15.0", [hex: :membrane_common_c, repo: "hexpm", optional: false]}, {:membrane_core, "~> 0.12.9", [hex: :membrane_core, repo: "hexpm", optional: false]}, {:membrane_h264_format, "~> 0.6.1", [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.0", [hex: :unifex, repo: "hexpm", optional: false]}], "hexpm", "ebbabcb417381bc2b5b3fd9acd05764b0626b18a977c9efd0d746c651c00250a"}, - "membrane_h264_format": {:hex, :membrane_h264_format, "0.6.1", "44836cd9de0abe989b146df1e114507787efc0cf0da2368f17a10c47b4e0738c", [:mix], [], "hexpm", "4b79be56465a876d2eac2c3af99e115374bbdc03eb1dea4f696ee9a8033cd4b0"}, + "membrane_common_c": {:hex, :membrane_common_c, "0.16.0", "caf3f29d2f5a1d32d8c2c122866110775866db2726e4272be58e66dfdf4bce40", [:mix], [{:membrane_core, "~> 1.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", "a3c7e91de1ce1f8b23b9823188a5d13654d317235ea0ca781c05353ed3be9b1c"}, + "membrane_core": {:hex, :membrane_core, "1.0.0", "1b543aefd952283be1f2a215a1db213aa4d91222722ba03cd35280622f1905ee", [:mix], [{:bunch, "~> 1.6", [hex: :bunch, repo: "hexpm", optional: false]}, {:qex, "~> 0.3", [hex: :qex, repo: "hexpm", optional: false]}, {:ratio, "~> 3.0", [hex: :ratio, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "352c90fd0a29942143c4bf7a727cc05c632e323f50a1a4e99321b1e8982f1533"}, + "membrane_ffmpeg_swscale_plugin": {:hex, :membrane_ffmpeg_swscale_plugin, "0.15.0", "0ab032e8f6138182dcb35829fc23352ef83bb84fdf1485f693c4a9a184af3394", [:mix], [{:bundlex, "~> 1.2", [hex: :bundlex, repo: "hexpm", optional: false]}, {:membrane_common_c, "~> 0.16.0", [hex: :membrane_common_c, repo: "hexpm", optional: false]}, {:membrane_core, "~> 1.0", [hex: :membrane_core, repo: "hexpm", optional: false]}, {:membrane_raw_video_format, "~> 0.3.0", [hex: :membrane_raw_video_format, repo: "hexpm", optional: false]}], "hexpm", "c1a7a682aa62daa2163019b11e761c284d9926b0cdd7955c691ed67a75e40e3f"}, "membrane_raw_video_format": {:hex, :membrane_raw_video_format, "0.3.0", "ba10f475e0814a6fe79602a74536b796047577c7ef5b0e33def27cd344229699", [:mix], [], "hexpm", "2f08760061c8a5386ecf04273480f10e48d25a1a40aa99476302b0bcd34ccb1c"}, + "membrane_sdl_plugin": {:hex, :membrane_sdl_plugin, "0.18.0", "39c2671a4c0c457a928d552d450bcc4576c60a6f3623232120f70596401f758a", [:mix], [{:bundlex, "~> 1.2", [hex: :bundlex, repo: "hexpm", optional: false]}, {:membrane_common_c, "~> 0.16.0", [hex: :membrane_common_c, repo: "hexpm", optional: false]}, {:membrane_core, "~> 1.0", [hex: :membrane_core, repo: "hexpm", optional: false]}, {:membrane_raw_video_format, "~> 0.3.0", [hex: :membrane_raw_video_format, repo: "hexpm", optional: false]}], "hexpm", "d3e60072a07ab15b955316681a3ded7bfbb704ba3f5c1a19c96cbc9c5e4341a5"}, "mime": {:hex, :mime, "2.0.5", "dc34c8efd439abe6ae0343edbb8556f4d63f178594894720607772a041b04b02", [:mix], [], "hexpm", "da0d64a365c45bc9935cc5c8a7fc5e49a0e0f9932a761c55d6c52b142780a05c"}, "mint": {:hex, :mint, "1.5.1", "8db5239e56738552d85af398798c80648db0e90f343c8469f6c6d8898944fb6f", [:mix], [{:castore, "~> 0.1.0 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:hpax, "~> 0.1.1", [hex: :hpax, repo: "hexpm", optional: false]}], "hexpm", "4a63e1e76a7c3956abd2c72f370a0d0aecddc3976dea5c27eccbecfa5e7d5b1e"}, "nimble_options": {:hex, :nimble_options, "1.0.2", "92098a74df0072ff37d0c12ace58574d26880e522c22801437151a159392270e", [:mix], [], "hexpm", "fd12a8db2021036ce12a309f26f564ec367373265b53e25403f0ee697380f1b8"}, @@ -31,8 +29,8 @@ "nimble_pool": {:hex, :nimble_pool, "1.0.0", "5eb82705d138f4dd4423f69ceb19ac667b3b492ae570c9f5c900bb3d2f50a847", [:mix], [], "hexpm", "80be3b882d2d351882256087078e1b1952a28bf98d0a287be87e4a24a710b67a"}, "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"}, "qex": {:hex, :qex, "0.5.1", "0d82c0f008551d24fffb99d97f8299afcb8ea9cf99582b770bd004ed5af63fd6", [:mix], [], "hexpm", "935a39fdaf2445834b95951456559e9dc2063d0a055742c558a99987b38d6bab"}, - "ratio": {:hex, :ratio, "2.4.2", "c8518f3536d49b1b00d88dd20d49f8b11abb7819638093314a6348139f14f9f9", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}, {:numbers, "~> 5.2.0", [hex: :numbers, repo: "hexpm", optional: false]}], "hexpm", "441ef6f73172a3503de65ccf1769030997b0d533b1039422f1e5e0e0b4cbf89e"}, - "req": {:hex, :req, "0.4.4", "a17b6bec956c9af4f08b5d8e8a6fc6e4edf24ccc0ac7bf363a90bba7a0f0138c", [:mix], [{:brotli, "~> 0.3.1", [hex: :brotli, repo: "hexpm", optional: true]}, {:ezstd, "~> 1.0", [hex: :ezstd, repo: "hexpm", optional: true]}, {:finch, "~> 0.9", [hex: :finch, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:mime, "~> 1.6 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:nimble_csv, "~> 1.0", [hex: :nimble_csv, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "2618c0493444fee927d12073afb42e9154e766b3f4448e1011f0d3d551d1a011"}, + "ratio": {:hex, :ratio, "3.0.2", "60a5976872a4dc3d873ecc57eed1738589e99d1094834b9c935b118231297cfb", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}, {:numbers, "~> 5.2.0", [hex: :numbers, repo: "hexpm", optional: false]}], "hexpm", "3a13ed5a30ad0bfd7e4a86bf86d93d2b5a06f5904417d38d3f3ea6406cdfc7bb"}, + "req": {:hex, :req, "0.4.5", "2071bbedd280f107b9e33e1ddff2beb3991ec1ae06caa2cca2ab756393d8aca5", [:mix], [{:brotli, "~> 0.3.1", [hex: :brotli, repo: "hexpm", optional: true]}, {:ezstd, "~> 1.0", [hex: :ezstd, repo: "hexpm", optional: true]}, {:finch, "~> 0.9", [hex: :finch, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:mime, "~> 1.6 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:nimble_csv, "~> 1.0", [hex: :nimble_csv, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "dd23e9c7303ddeb2dee09ff11ad8102cca019e38394456f265fb7b9655c64dd8"}, "secure_random": {:hex, :secure_random, "0.5.1", "c5532b37c89d175c328f5196a0c2a5680b15ebce3e654da37129a9fe40ebf51b", [:mix], [], "hexpm", "1b9754f15e3940a143baafd19da12293f100044df69ea12db5d72878312ae6ab"}, "shmex": {:hex, :shmex, "0.5.0", "7dc4fb1a8bd851085a652605d690bdd070628717864b442f53d3447326bcd3e8", [:mix], [{:bunch_native, "~> 0.5.0", [hex: :bunch_native, repo: "hexpm", optional: false]}, {:bundlex, "~> 1.0", [hex: :bundlex, repo: "hexpm", optional: false]}], "hexpm", "b67bb1e22734758397c84458dbb746519e28eac210423c267c7248e59fc97bdc"}, "telemetry": {:hex, :telemetry, "1.2.1", "68fdfe8d8f05a8428483a97d7aab2f268aaff24b49e0f599faa091f1d4e7f61c", [:rebar3], [], "hexpm", "dad9ce9d8effc621708f99eac538ef1cbe05d6a874dd741de2e689c47feafed5"}, diff --git a/test/membrane_media_capture_plugin/camera_capture_plugin_test.exs b/test/membrane_media_capture_plugin/camera_capture_plugin_test.exs index 7b563b5..94746e0 100644 --- a/test/membrane_media_capture_plugin/camera_capture_plugin_test.exs +++ b/test/membrane_media_capture_plugin/camera_capture_plugin_test.exs @@ -7,24 +7,19 @@ defmodule Membrane.CameraCaptureTest do @tag :manual @tag :tmp_dir - test "integration test", %{tmp_dir: tmp_dir} do - output_path = Path.join(tmp_dir, "output.h264") + test "integration test" do + spec = + child(Membrane.CameraCapture) + |> child(%Membrane.FFmpeg.SWScale.PixelFormatConverter{format: :I420}) + |> child(Membrane.SDL.Player) - structure = - child(:source, Membrane.CameraCapture) - |> child(:converter, %Membrane.FFmpeg.SWScale.PixelFormatConverter{format: :I420}) - |> child(:encoder, Membrane.H264.FFmpeg.Encoder) - |> child(:sink, %Membrane.File.Sink{location: output_path}) + pipeline = Testing.Pipeline.start_link_supervised!(spec: spec) - pipeline = Testing.Pipeline.start_link_supervised!(structure: structure) - - Process.sleep(5000) + Process.sleep(10_000) # Check if pipeline is alive assert Process.alive?(pipeline) Membrane.Pipeline.terminate(pipeline) - - System.cmd("ffplay", [output_path]) end end