{"id":13906219,"url":"https://github.com/asticode/go-astiav","last_synced_at":"2025-08-06T18:50:44.864Z","repository":{"id":38538774,"uuid":"455826815","full_name":"asticode/go-astiav","owner":"asticode","description":"Better C bindings for ffmpeg in GO","archived":false,"fork":false,"pushed_at":"2024-04-14T09:13:45.000Z","size":1247,"stargazers_count":169,"open_issues_count":5,"forks_count":28,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-04-16T00:19:12.663Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","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/asticode.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":"2022-02-05T09:26:19.000Z","updated_at":"2024-05-05T17:49:33.983Z","dependencies_parsed_at":"2024-02-07T18:26:43.327Z","dependency_job_id":"5f2097e8-41c6-4816-9514-f13ef97cb306","html_url":"https://github.com/asticode/go-astiav","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asticode%2Fgo-astiav","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asticode%2Fgo-astiav/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asticode%2Fgo-astiav/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asticode%2Fgo-astiav/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asticode","download_url":"https://codeload.github.com/asticode/go-astiav/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226344582,"owners_count":17610169,"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-08-06T23:01:31.442Z","updated_at":"2025-07-18T04:30:38.120Z","avatar_url":"https://github.com/asticode.png","language":"Go","funding_links":[],"categories":["Video","HarmonyOS","视频","Go"],"sub_categories":["Utility/Miscellaneous","Windows Manager","实用程序/Miscellaneous"],"readme":"[![GoReportCard](http://goreportcard.com/badge/github.com/asticode/go-astiav)](http://goreportcard.com/report/github.com/asticode/go-astiav)\n[![GoDoc](https://godoc.org/github.com/asticode/go-astiav?status.svg)](https://godoc.org/github.com/asticode/go-astiav)\n[![Test](https://github.com/asticode/go-astiav/actions/workflows/test.yml/badge.svg)](https://github.com/asticode/go-astiav/actions/workflows/test.yml)\n[![Coveralls](https://coveralls.io/repos/github/asticode/go-astiav/badge.svg?branch=master)](https://coveralls.io/github/asticode/go-astiav)\n\n`astiav` is a Golang library providing C bindings for [ffmpeg](https://github.com/FFmpeg/FFmpeg)\n\nIt's only compatible with `ffmpeg` `n7.0`.\n\nIts main goals are to:\n\n- [x] provide a better GO idiomatic API\n    - standard error pattern\n    - typed constants and flags\n    - struct-based functions\n    - ...\n- [x] provide the GO version of [ffmpeg examples](https://github.com/FFmpeg/FFmpeg/tree/n7.0/doc/examples)\n- [x] be fully tested\n\n:warning: breaking changes will be introduced in `go-astiav` **without** using the `v2` golang pattern. You can see the list of breaking changes [here](BREAKING_CHANGES.md).\n\n# Examples\n\nExamples are located in the [examples](examples) directory and mirror as much as possible the [ffmpeg examples](https://github.com/FFmpeg/FFmpeg/tree/n7.0/doc/examples).\n\n|name|astiav|ffmpeg|\n|---|---|---|\n|BitStream Filtering|[see](examples/bit_stream_filtering/main.go)|X\n|Custom IO Demuxing|[see](examples/custom_io_demuxing/main.go)|[see](https://github.com/FFmpeg/FFmpeg/blob/n7.0/doc/examples/avio_read_callback.c)\n|Custom IO Muxing|[see](examples/custom_io_muxing/main.go)|X\n|Demuxing/Decoding|[see](examples/demuxing_decoding/main.go)|[see](https://github.com/FFmpeg/FFmpeg/blob/n7.0/doc/examples/demux_decode.c)\n|Filtering|[see](examples/filtering/main.go)|[see](https://github.com/FFmpeg/FFmpeg/blob/n7.0/doc/examples/decode_filter_video.c)\n|Frame data manipulation|[see](examples/frame_data_manipulation/main.go)|X\n|Hardware Decoding/Filtering|[see](examples/hardware_decoding_filtering/main.go)|[see](https://github.com/FFmpeg/FFmpeg/blob/n7.0/doc/examples/hw_decode.c)\n|Hardware Encoding|[see](examples/hardware_encoding/main.go)|[see](https://github.com/FFmpeg/FFmpeg/blob/n7.0/doc/examples/vaapi_encode.c)\n|Remuxing|[see](examples/remuxing/main.go)|[see](https://github.com/FFmpeg/FFmpeg/blob/n7.0/doc/examples/remux.c)\n|Resampling audio|[see](examples/resampling_audio/main.go)|[see](https://github.com/FFmpeg/FFmpeg/blob/n7.0/doc/examples/resample_audio.c)\n|Scaling video|[see](examples/scaling_video/main.go)|[see](https://github.com/FFmpeg/FFmpeg/blob/n7.0/doc/examples/scale_video.c)\n|Transcoding|[see](examples/transcoding/main.go)|[see](https://github.com/FFmpeg/FFmpeg/blob/n7.0/doc/examples/transcode.c)\n\n*Tip: you can use the video sample located in the `testdata` directory for your tests*\n\n# Patterns\n\n*NB: errors are not checked below for readibility purposes, however you should!*\n\nFirst off, all use cases are different and it's impossible to provide patterns that work in every situation. That's why `ffmpeg`'s doc or source code should be your ultimate source of truth regarding how to use this library. That's why all methods of this library have been documented with a link referencing the documentation of the C function they use.\n\nHowever it's possible to give rules of thumb and patterns that fit most use cases and can kickstart most people. Here's a few of them:\n\n## When to call `Alloc()`, `.Unref()` and `.Free()`\n\nLet's take the `FormatContext.ReadFrame()` pattern as an example. The pattern is similar with frames.\n\n```go\n// You can allocate the packet once and reuse the same object in the for loop below\npkt := astiav.AllocPacket()\n\n// However, once you're done using the packet, you need to make sure to free it\ndefer pkt.Free()\n\n// Loop\nfor {\n    // We'll use a closure to ease unreferencing the packet\n    func() {\n        // Read frame using the same packet every time\n        formatContext.ReadFrame(pkt)\n\n        // However make sure to unreference the packet once you're done with what \n        // have been \"injected\" by the .ReadFrame() method\n        defer pkt.Unref()\n\n        // Here you can do whatever you feel like with your packet\n    }()\n}\n```\n\n# Install ffmpeg from source\n\nIf you don't know how to install `ffmpeg`, you can use the following to install it from source:\n\n```sh\n$ make install-ffmpeg\n```\n\n`ffmpeg` will be built from source in a directory named `tmp` and located in you working directory\n\nFor your GO code to pick up `ffmpeg` dependency automatically, you'll need to add the following environment variables:\n\n(don't forget to replace `{{ path to your working directory }}` with the absolute path to your working directory)\n\n```sh\nexport CGO_LDFLAGS=\"-L{{ path to your working directory }}/tmp/n7.0/lib/\",\nexport CGO_CFLAGS=\"-I{{ path to your working directory }}/tmp/n7.0/include/\",\nexport PKG_CONFIG_PATH=\"{{ path to your working directory }}/tmp/n7.0/lib/pkgconfig\",\n```\n\n## Building on Windows\n\nBuilding on Windows requires msys2 / mingw64 gcc toolchain. Read the [Quickstart guide](https://www.msys2.org) to install Msys2.\n\nOnce complete run the Mingw64 shell from the installation folder, run the below commands:\n\n```shell\n# Update Packages\npacman -Syu\n# Install Requirements to Build\npacman -S --noconfirm --needed git diffutils mingw-w64-x86_64-toolchain pkg-config make yasm\n# Clone the repository using git\ngit clone https://github.com/asticode/go-astiav\ncd go-astiav\n```\n\nThen once you clone this repository, follow along the build instructions above.\n\n\u003e **Notes:**\n\u003e For `pkg-config` use `pkgconfiglite` from choco.\n\u003e Remember to set `CGO` and `PKG_CONFIG` env vars properly to point to the folder where ffmpeg was built.\n\n# Why astiav?\n\nAfter maintaining for several years the most starred [fork](https://github.com/asticode/goav) of [goav](https://github.com/giorgisio/goav), I've decided to write from scratch my own C bindings to fix most of the problems I still encountered using `goav`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasticode%2Fgo-astiav","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasticode%2Fgo-astiav","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasticode%2Fgo-astiav/lists"}