{"id":22704791,"url":"https://github.com/hey-red/imagesharp.avcodecformats","last_synced_at":"2025-04-13T10:51:41.573Z","repository":{"id":55400345,"uuid":"299220371","full_name":"hey-red/ImageSharp.AVCodecFormats","owner":"hey-red","description":"FFmpeg decoders for ImageSharp","archived":false,"fork":false,"pushed_at":"2024-01-23T18:48:30.000Z","size":42719,"stargazers_count":19,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-12T04:29:09.470Z","etag":null,"topics":["ffmpeg","image-processing","imagesharp","video-processing"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hey-red.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"open_collective":"imagesharpavcodecformats"}},"created_at":"2020-09-28T07:09:55.000Z","updated_at":"2025-02-28T22:00:23.000Z","dependencies_parsed_at":"2023-12-16T08:05:27.572Z","dependency_job_id":"e1d67efd-28bc-43c9-b6cd-fa9f3f40ffab","html_url":"https://github.com/hey-red/ImageSharp.AVCodecFormats","commit_stats":{"total_commits":171,"total_committers":2,"mean_commits":85.5,"dds":"0.49122807017543857","last_synced_commit":"4f43164141c8f86cfc0678d91a086d6408a5a329"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hey-red%2FImageSharp.AVCodecFormats","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hey-red%2FImageSharp.AVCodecFormats/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hey-red%2FImageSharp.AVCodecFormats/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hey-red%2FImageSharp.AVCodecFormats/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hey-red","download_url":"https://codeload.github.com/hey-red/ImageSharp.AVCodecFormats/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248702998,"owners_count":21148116,"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":["ffmpeg","image-processing","imagesharp","video-processing"],"created_at":"2024-12-10T09:07:53.290Z","updated_at":"2025-04-13T10:51:41.530Z","avatar_url":"https://github.com/hey-red.png","language":"C#","funding_links":["https://opencollective.com/imagesharpavcodecformats"],"categories":[],"sub_categories":[],"readme":"# ImageSharp.AVCodecFormats\nFFmpeg decoders for [ImageSharp](https://github.com/SixLabors/ImageSharp)\n\n## Install\nvia [NuGet](https://www.nuget.org/packages/ImageSharp.AVCodecFormats):\n```\nPM\u003e Install-Package ImageSharp.AVCodecFormats\n```\nNative libs for **x64** Linux and Windows:\n```\nPM\u003e Install-Package ImageSharp.AVCodecFormats.Native\n```\nalso, we can install separate native packages:\n\n```\nPM\u003e Install-Package ImageSharp.AVCodecFormats.Native.win-x64\nPM\u003e Install-Package ImageSharp.AVCodecFormats.Native.linux-x64\n```\n\nWithout native packages you should provide your own shared FFmpeg build and set path:\n\n`FFmpegBinaries.Path = \"/path/to/native/binaries\"`\n\nOn Linux you have another way to get native libs. Just install ffmpeg from your package manager, but I have no guarantees that it will work as expected.\n\n## Usage\n\n```C#\nusing System.IO;\n\nusing SixLabors.ImageSharp;\nusing SixLabors.ImageSharp.Formats.Jpeg;\nusing SixLabors.ImageSharp.Processing;\n\nusing HeyRed.ImageSharp.AVCodecFormats;\n\n// Create custom configuration with all available decoders\nvar configuration = new Configuration().WithAVDecoders();\n\n// Or only required decoders\nvar configuration = new Configuration(\n    new AviConfigurationModule(),\n    new MkvConfigurationModule(),\n    new MovConfigurationModule(),\n    new Mp4ConfigurationModule(),\n    new WebmConfigurationModule(),\n    new WmvConfigurationModule(),\n    new MpegTsConfigurationModule(),\n    new Mp3ConfigurationModule());\n\n// NOTE: Don't forget to set max frames.\n// Without this limit you can run into huge memory usage.\nvar decoderOptions = new DecoderOptions\n{\n    MaxFrames = 50,\n    Configuration = configuration,\n    // The TargetSize option is also supported. \n    // This will reduce memory usage in result image.   \n};\n\nusing var inputStream = File.OpenRead(\"/path/to/video.mp4\");\nusing var image = Image.Load(decoderOptions, inputStream);\n\n// Resize\nimage.Mutate(x =\u003e x.Resize(image.Width / 2, image.Height / 2)); \n\n// Save all frames using png encoder\nfor (int i = 0; i \u003c image.Frames.Count; i++)\n{\n    image.Frames\n        .CloneFrame(i)\n        .SaveAsPng($\"frame{i}.png\");\n}\n```\nMore info \u003chttps://docs.sixlabors.com/articles/imagesharp/configuration.html\u003e\n\n## Frame filter\nFrame filter is a delegate that provides the way to skip frames based on their content.\n\nIt can be useful for various scenarios like black/white frames filter, skip every n frame or something else.\n\n```C#\nvar decoderOptions = new AVDecoderOptions\n{\n    GeneralOptions = new DecoderOptions\n    {\n        MaxFrames = 100,\n    },\n    FrameFilter = (imageFrame, frameNum) =\u003e\n    {\n        var frame = (ImageFrame\u003cRgba32\u003e)frame; // Pix format should match with Load/Decode methods\n\n        // Do something with frame\n\n        // Return true when frame should be not present in result image\n        return false;\n    },\n};\n\nusing var inputStream = File.OpenRead(/path/to/video.mp4);\nusing var image = Mp4Decoder.Instance.Decode(decoderOptions, inputStream);\n\n// do something\n```\nSee [tests](https://github.com/hey-red/ImageSharp.AVCodecFormats/blob/master/test/ImageSharp.AVCodecFormats.Tests/FrameFilterTests.cs) for basic implementation of black frames filter.\n\n## Additional tips\nIf you want preserve aspect ratio when TargetSize is set:\n\n```C#\nvar decoderOptions = new AVDecoderOptions\n{\n    PreserveAspectRatio = true,\n    GeneralOptions = new DecoderOptions\n    {\n        TargetSize = new Size(500),\n    },\n};\n```\n\nAn additional format specific information about the file:\n\n```C#\n// Get infogmation about webm file\nAVMetadata metadata = Image.Identify(decoderOptions, inputStream).Metadata.GetWebmMetadata();\n```\n[More extensions methods](https://github.com/hey-red/ImageSharp.AVCodecFormats/blob/master/src/ImageSharp.AVCodecFormats/MetadataExtensions.cs)\n\n## Supported formats\nmp4, webm, avi, mkv, mov, ts, wmv, mp3(cover image).\n\n## Supported codecs\n[Native package](https://www.nuget.org/packages/ImageSharp.AVCodecFormats.Native) provides codecs listed below:\n\nH263, H264, H.265(HEVC), VP8, VP9, AV1, MPEG-4, MJPEG, PNG, MS MPEG4(v1,v2,v3), WMV(v1,v2,v3), VC-1, MPEG-1 Audio Layer 3.\n\n## License\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhey-red%2Fimagesharp.avcodecformats","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhey-red%2Fimagesharp.avcodecformats","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhey-red%2Fimagesharp.avcodecformats/lists"}