{"id":13644862,"url":"https://github.com/mutablelogic/go-media","last_synced_at":"2026-01-06T11:20:09.849Z","repository":{"id":46913827,"uuid":"130900253","full_name":"mutablelogic/go-media","owner":"mutablelogic","description":"go media services","archived":false,"fork":false,"pushed_at":"2024-08-16T10:40:16.000Z","size":56663,"stargazers_count":30,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-13T20:18:00.529Z","etag":null,"topics":["chromaprint","dvb","dvb-t","ffmpeg","golang","media","mpeg","mpegts","raspberrypi"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/mutablelogic/go-media","language":"Go","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/mutablelogic.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":"2018-04-24T18:52:58.000Z","updated_at":"2024-11-15T11:48:10.000Z","dependencies_parsed_at":"2024-06-29T09:36:37.602Z","dependency_job_id":"7a725c95-d032-4d6b-b711-479b13628793","html_url":"https://github.com/mutablelogic/go-media","commit_stats":{"total_commits":293,"total_committers":1,"mean_commits":293.0,"dds":0.0,"last_synced_commit":"c3b80a5acfcd8388a953e3fb43730798ea0ae2be"},"previous_names":["djthorpe/go-media","djthorpe/mmal","djthorpe/gopi-media"],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mutablelogic%2Fgo-media","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mutablelogic%2Fgo-media/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mutablelogic%2Fgo-media/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mutablelogic%2Fgo-media/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mutablelogic","download_url":"https://codeload.github.com/mutablelogic/go-media/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230788489,"owners_count":18280343,"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":["chromaprint","dvb","dvb-t","ffmpeg","golang","media","mpeg","mpegts","raspberrypi"],"created_at":"2024-08-02T01:02:16.662Z","updated_at":"2026-01-06T11:20:09.836Z","avatar_url":"https://github.com/mutablelogic.png","language":"Go","funding_links":[],"categories":["HarmonyOS","Go"],"sub_categories":["Windows Manager"],"readme":"\n# go-media\n\nThis module provides Go bindings and utilities for FFmpeg, including:\n\n* Low-level CGO bindings for [FFmpeg 8.0](https://ffmpeg.org/) (in `sys/ffmpeg80`)\n* High-level Go API for media operations (in `pkg/ffmpeg`)\n* Task manager for common media operations (in `pkg/ffmpeg/task`)\n* Audio fingerprinting with Chromaprint/AcoustID (in `pkg/chromaprint`)\n* Command-line tool `gomedia` for media inspection and manipulation\n* HTTP server for media services\n\n## Current Status\n\nThis module is in development (meaning the API might change).\nFFmpeg 8.0 bindings are complete with support for:\n\n* Codecs, formats, filters, pixel formats, sample formats\n* Audio channel layouts\n* Demuxing, muxing, remuxing\n* Audio and video decoding/encoding (transcoding is TBC)\n* Filtering and resampling\n* Metadata extraction\n* Hardware acceleration support\n\n## Requirements\n\n### Building FFmpeg\n\nThe module includes scripts to build FFmpeg with common codecs. Install dependencies first:\n\n**macOS (Homebrew):**\n\n```bash\nbrew install pkg-config freetype lame opus libvorbis libvpx x264 x265\n```\n\n**Debian/Ubuntu:**\n\n```bash\napt install pkg-config libfreetype-dev libmp3lame-dev libopus-dev \\\n  libvorbis-dev libvpx-dev libx264-dev libx265-dev libnuma-dev\n```\n\n**Fedora:**\n\n```bash\ndnf install pkg-config freetype-devel lame-devel opus-devel \\\n  libvorbis-devel libvpx-devel x264-devel x265-devel numactl-devel\n```\n\n**Vulkan Hardware Support (Linux):**\n\nFor Vulkan-based hardware acceleration on Linux, install:\n\n```bash\n# Debian/Ubuntu\napt install libvulkan-dev\n\n# Fedora\ndnf install vulkan-loader-devel\n```\n\nThen build FFmpeg:\n\n```bash\ngit clone https://github.com/mutablelogic/go-media\ncd go-media\nmake ffmpeg chromaprint\n```\n\nThis creates static libraries in `build/install` with the necessary pkg-config files.\n\n### Building the Go Module\n\nThe module uses CGO and requires the FFmpeg libraries. The Makefile handles the necessary\nenvironment variables:\n\n```bash\nmake              # Build the gomedia command-line tool\nmake test         # Run all tests\nmake test-sys     # Run system/FFmpeg binding tests only\n```\n\nTo build manually:\n\n```bash\nexport PKG_CONFIG_PATH=\"${PWD}/build/install/lib/pkgconfig\"\nexport CGO_LDFLAGS_ALLOW=\"-(W|D).*\"\nexport CGO_LDFLAGS=\"-lstdc++ -Wl,-no_warn_duplicate_libraries\"\ngo build -o build/gomedia ./cmd/gomedia\n```\n\n## Usage\n\n### Command-Line Tool\n\nThe `gomedia` tool provides various media operations:\n\n```bash\n# List available codecs\ngomedia list-codecs\n\n# List available filters  \ngomedia list-filters\n\n# List supported formats\ngomedia list-formats\n\n# List pixel/sample formats\ngomedia list-pixel-formats\ngomedia list-sample-formats\n\n# Probe a media file\ngomedia probe \u003cfile\u003e\n\n# Remux a file (change container without re-encoding)\ngomedia remux --input \u003cinput\u003e --output \u003coutput\u003e\n\n# Audio fingerprinting and lookup (requires AcoustID API key)\nexport CHROMAPRINT_KEY=\u003cyour-key\u003e\ngomedia audio-lookup \u003cfile\u003e\n\n# Run HTTP server\ngomedia server run\n```\n\n### Go API - Task Manager\n\nThe task manager provides a high-level API for media operations:\n\n```go\npackage main\n\nimport (\n \"context\"\n \"fmt\"\n \n task \"github.com/mutablelogic/go-media/pkg/ffmpeg/task\"\n schema \"github.com/mutablelogic/go-media/pkg/ffmpeg/schema\"\n)\n\nfunc main() {\n // Create a task manager\n manager, err := task.NewManager()\n if err != nil {\n  panic(err)\n }\n\n // List all video codecs\n codecs, err := manager.ListCodecs(context.Background(), \u0026schema.ListCodecRequest{\n  Type: \"video\",\n })\n if err != nil {\n  panic(err)\n }\n \n for _, codec := range codecs {\n  fmt.Printf(\"%s: %s\\n\", codec.Name, codec.LongName)\n }\n\n // Probe a media file\n info, err := manager.Probe(context.Background(), \u0026schema.ProbeRequest{\n  Input: \"video.mp4\",\n })\n if err != nil {\n  panic(err)\n }\n \n fmt.Printf(\"Format: %s\\n\", info.Format)\n fmt.Printf(\"Duration: %v\\n\", info.Duration)\n for _, stream := range info.Streams {\n  fmt.Printf(\"Stream %d: %s\\n\", stream.Index, stream.Type)\n }\n}\n```\n\n### Available Task Manager Methods\n\nThe task manager (`pkg/ffmpeg/task.Manager`) provides these methods:\n\n**Query Operations:**\n\n* `ListCodecs(ctx, *ListCodecRequest) (ListCodecResponse, error)` - List available codecs\n* `ListFilters(ctx, *ListFilterRequest) (ListFilterResponse, error)` - List available filters\n* `ListFormats(ctx, *ListFormatRequest) (ListFormatResponse, error)` - List formats and devices\n* `ListPixelFormats(ctx, *ListPixelFormatRequest) (ListPixelFormatResponse, error)` - List pixel formats\n* `ListSampleFormats(ctx, *ListSampleFormatRequest) (ListSampleFormatResponse, error)` - List sample formats\n* `ListAudioChannelLayouts(ctx, *ListAudioChannelLayoutRequest) (ListAudioChannelLayoutResponse, error)` - List audio layouts\n\n**Media Operations:**\n\n* `Probe(ctx, *ProbeRequest) (*ProbeResponse, error)` - Inspect media files\n* `Remux(ctx, *RemuxRequest) error` - Remux media without re-encoding\n* `AudioFingerprint(ctx, *AudioFingerprintRequest) (*AudioFingerprintResponse, error)` - Generate fingerprints and lookup\n\n### Low-Level FFmpeg Bindings\n\nFor direct FFmpeg access, use the `sys/ffmpeg80` package:\n\n```go\nimport (\n ff \"github.com/mutablelogic/go-media/sys/ffmpeg80\"\n)\n\n// Low-level FFmpeg operations\nfilter := ff.AVFilter_get_by_name(\"scale\")\ngraph := ff.AVFilterGraph_alloc()\n// ... etc\n```\n\n### HTTP Server\n\nThe module includes an HTTP server exposing the task manager via REST API:\n\n```bash\n# Start server\ngomedia server run --url http://localhost:8080/api\n\n# Query endpoints\ncurl http://localhost:8080/api/codec\ncurl http://localhost:8080/api/filter?name=scale\ncurl http://localhost:8080/api/format?type=muxer\n```\n\n### Audio Fingerprinting\n\n```go\nimport (\n chromaprint \"github.com/mutablelogic/go-media/pkg/chromaprint\"\n)\n\n// Requires CHROMAPRINT_KEY environment variable or explicit API key\nclient, err := chromaprint.NewClient(apiKey)\nif err != nil {\n panic(err)\n}\n\n// Generate fingerprint and lookup\nresult, err := client.Lookup(context.Background(), \"audio.mp3\")\nif err != nil {\n panic(err)\n}\n\nfmt.Printf(\"Title: %s\\n\", result.Title)\nfmt.Printf(\"Artist: %s\\n\", result.Artist)\n```\n\n## Docker\n\nBuild a Docker image with all dependencies:\n\n```bash\nDOCKER_REGISTRY=docker.io/user make docker\n```\n\n## Project Structure\n\n```\nsys/ffmpeg80/          # Low-level CGO FFmpeg bindings\npkg/ffmpeg/            # High-level Go API\n  task/                # Task manager for common operations\n  schema/              # Request/response schemas\n  httphandler/         # HTTP handlers\npkg/chromaprint/       # Audio fingerprinting\ncmd/gomedia/           # Command-line tool\n```\n\n## Contributing \u0026 Distribution\n\nPlease file feature requests and bugs at [github.com/mutablelogic/go-media/issues](https://github.com/mutablelogic/go-media/issues).\n\nLicensed under Apache 2.0. Redistributions must include copyright notice.\n\n\u003e **go-media**  \n\u003e [https://github.com/mutablelogic/go-media/](https://github.com/mutablelogic/go-media/)  \n\u003e Copyright (c) 2021-2026 David Thorpe, All rights reserved.\n\nThis software links to [FFmpeg](http://ffmpeg.org/) libraries licensed under the\n[LGPLv2.1](http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html).\n\n## References\n\n* [FFmpeg 8.0 Documentation](https://ffmpeg.org/doxygen/8.0/index.html)\n* [Go Package Documentation](https://pkg.go.dev/github.com/mutablelogic/go-media)\n* [AcoustID API](https://acoustid.org/webservice)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmutablelogic%2Fgo-media","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmutablelogic%2Fgo-media","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmutablelogic%2Fgo-media/lists"}