{"id":18352789,"url":"https://github.com/membraneframework/membrane_ffmpeg_swscale_plugin","last_synced_at":"2025-04-06T11:33:10.906Z","repository":{"id":39995517,"uuid":"379578425","full_name":"membraneframework/membrane_ffmpeg_swscale_plugin","owner":"membraneframework","description":"Plugin providing an element scaling raw video frames, using SWScale module of FFmpeg library.","archived":false,"fork":false,"pushed_at":"2024-10-23T09:31:56.000Z","size":3185,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-21T22:33:49.762Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/membraneframework.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-23T11:22:53.000Z","updated_at":"2024-10-23T09:31:25.000Z","dependencies_parsed_at":"2023-01-31T06:31:19.805Z","dependency_job_id":"9059e94c-6c35-43f6-a3c1-a406907d86b6","html_url":"https://github.com/membraneframework/membrane_ffmpeg_swscale_plugin","commit_stats":{"total_commits":72,"total_committers":11,"mean_commits":6.545454545454546,"dds":0.7777777777777778,"last_synced_commit":"e87dfea8994a79fa67e68b47a897e6ebae1e48f8"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":"membraneframework/membrane_template_plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/membraneframework%2Fmembrane_ffmpeg_swscale_plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/membraneframework%2Fmembrane_ffmpeg_swscale_plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/membraneframework%2Fmembrane_ffmpeg_swscale_plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/membraneframework%2Fmembrane_ffmpeg_swscale_plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/membraneframework","download_url":"https://codeload.github.com/membraneframework/membrane_ffmpeg_swscale_plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247478152,"owners_count":20945258,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T21:37:25.521Z","updated_at":"2025-04-06T11:33:05.896Z","avatar_url":"https://github.com/membraneframework.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Membrane FFmpeg SWScale plugin\n\n[![Hex.pm](https://img.shields.io/hexpm/v/membrane_ffmpeg_swscale_plugin.svg)](https://hex.pm/packages/membrane_ffmpeg_swscale_plugin)\n[![API Docs](https://img.shields.io/badge/api-docs-yellow.svg?style=flat)](https://hexdocs.pm/membrane_ffmpeg_swscale_plugin/)\n[![CircleCI](https://circleci.com/gh/membraneframework/membrane_ffmpeg_swscale_plugin.svg?style=svg)](https://circleci.com/gh/membraneframework/membrane_ffmpeg_swscale_plugin)\n\nPlugin providing an element scaling raw video frames and performing pixel format conversions, using SWScale module of [FFmpeg](https://www.ffmpeg.org/) library.\n\nIt is a part of [Membrane Multimedia Framework](https://membrane.stream).\n\n## Installation\n\nAdd the following line to your `deps` in `mix.exs`. Run `mix deps.get`.\n\n```elixir\n{:membrane_ffmpeg_swscale_plugin, \"~\u003e 0.16.2\"}\n```\n\nThe precompiled builds of the [ffmpeg](https://www.ffmpeg.org) will be pulled and linked automatically. However, should there be any problems, consider installing it manually.\n\n### Manual instalation of dependencies\n\n#### macOS\n\n```shell\nbrew install ffmpeg\n```\n\n#### Ubuntu\n\n```shell\nsudo apt-get install ffmpeg\n```\n\n#### Arch / Manjaro\n\n```shell\npacman -S ffmpeg\n```\n\n## Description\n\n### Converter\nConverter accepts raw video in any of the pixel formats specified in type [`Membrane.RawVideo.pixel_format()`](https://hexdocs.pm/membrane_raw_video_format/Membrane.RawVideo.html#t:pixel_format/0).\nThe element requires `Membrane.RawVideo` stream format on the input with `aligned: true` constraint, meaning that each buffer must contain exactly one raw video frame.\n\n#### Converting pixel format\n\nWhen creating the element you can specify a single option `format` defining the desired pixel format of the output.\n`format` has to be [`Membrane.RawVideo.pixel_format()`](https://hexdocs.pm/membrane_raw_video_format/Membrane.RawVideo.html#t:pixel_format/0).\n\n#### Scaling\n\nConverter needs to receive stream format with input video width and height. To meet all requirements either `Membrane.RawVideo.Parser` or some decoder\n(e.g. `Membrane.H264.FFmpeg.Decoder`) have to precede Converter in the pipeline.\n\nThere are two options related to scaling, that can be specified when creating the element:\n\n- `output_width` - desired scaled video width.\n- `output_height` - desired scaled video height.\n\nBoth need to be even numbers.\n\nScaling consists of two operations:\n\n- scaling itself - resizing video frame with keeping original ratio. After that operation at least one of the\ndimensions of the input frame match the respective dimension of the desired output size. The second one\n(if does not match) is smaller than its respective dimension.\n- adding paddings - if one dimension does not match after scaling, paddings have to be added. They are put on both\nsides of the scaled frame equally. They are either above and below the frame or on the left and right sides of it.\nIt depends on the dimension that did not match after scaling.\n\nThe output of the element has the size as specified in the options.\n\n## Usage\n\nConverting the pixel format of an encoded (using H.264 standard) video requires a parser and a decoder\nbecause the `SWScale.Converter` performs conversion only on the raw, decoded video. The pipeline scales the video to the `640x640`\nshape, changes the pixel format of the video to the `I422` format and reencodes it.\n\n```elixir\ndefmodule Converting.Pipeline do\n  use Membrane.Pipeline\n\n  @impl true\n  def handle_init(_ctx, _options) do\n    structure = [\n      child(:file_src, %Membrane.File.Source{location: \"/tmp/input.h264\"})\n      |\u003e child(:parser, Membrane.H264.Parser)\n      |\u003e child(:decoder, Membrane.H264.FFmpeg.Decoder)\n      |\u003e child(:converter, %Membrane.FFmpeg.SWScale.Converter{\n        output_height: 640, \n        output_width: 640, \n        format: :I422\n      })\n      |\u003e child(:encoder, Membrane.H264.FFmpeg.Encoder)\n      |\u003e child(:file_sink, %Membrane.File.Sink{location: \"/tmp/output.h264\"})\n    ]\n    \n    {[spec: structure], %{}}\n  end\nend\n```\n\n## Copyright and License\n\nCopyright 2021, [Software Mansion](https://swmansion.com/?utm_source=git\u0026utm_medium=readme\u0026utm_campaign=membrane)\n\n[![Software Mansion](https://logo.swmansion.com/logo?color=white\u0026variant=desktop\u0026width=200\u0026tag=membrane-github)](https://swmansion.com/?utm_source=git\u0026utm_medium=readme\u0026utm_campaign=membrane)\n\nLicensed under the [Apache License, Version 2.0](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmembraneframework%2Fmembrane_ffmpeg_swscale_plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmembraneframework%2Fmembrane_ffmpeg_swscale_plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmembraneframework%2Fmembrane_ffmpeg_swscale_plugin/lists"}