Skip to content

Commit

Permalink
Merge pull request #12 from mutablelogic/ffmpeg61
Browse files Browse the repository at this point in the history
Update to ffmpeg 61
  • Loading branch information
djthorpe authored Jun 17, 2024
2 parents 9aa5e2f + 0a2b66e commit bd06e71
Show file tree
Hide file tree
Showing 142 changed files with 8,955 additions and 1,046 deletions.
80 changes: 44 additions & 36 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,63 @@
GO=$(shell which go)
DOCKER=$(shell which docker)

# Paths to locations, etc
BUILD_DIR := "build"
CMD_DIR := $(filter-out cmd/README.md, $(wildcard cmd/*))

# Build flags
BUILD_MODULE := $(shell go list -m)
BUILD_LD_FLAGS += -X $(BUILD_MODULE)/pkg/config.GitSource=${BUILD_MODULE}
BUILD_LD_FLAGS += -X $(BUILD_MODULE)/pkg/config.GitTag=$(shell git describe --tags)
BUILD_LD_FLAGS += -X $(BUILD_MODULE)/pkg/config.GitBranch=$(shell git name-rev HEAD --name-only --always)
BUILD_LD_FLAGS += -X $(BUILD_MODULE)/pkg/config.GitHash=$(shell git rev-parse HEAD)
BUILD_LD_FLAGS += -X $(BUILD_MODULE)/pkg/config.GoBuildTime=$(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
BUILD_MODULE := $(shell cat go.mod | head -1 | cut -d ' ' -f 2)
BUILD_LD_FLAGS += -X $(BUILD_MODULE)/pkg/version.GitSource=${BUILD_MODULE}
BUILD_LD_FLAGS += -X $(BUILD_MODULE)/pkg/version.GitTag=$(shell git describe --tags --always)
BUILD_LD_FLAGS += -X $(BUILD_MODULE)/pkg/version.GitBranch=$(shell git name-rev HEAD --name-only --always)
BUILD_LD_FLAGS += -X $(BUILD_MODULE)/pkg/version.GitHash=$(shell git rev-parse HEAD)
BUILD_LD_FLAGS += -X $(BUILD_MODULE)/pkg/version.GoBuildTime=$(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
BUILD_FLAGS = -ldflags "-s -w $(BUILD_LD_FLAGS)"

all: clean test cmd

cmd: clean dependencies $(CMD_DIR)
# Set OS and Architecture
ARCH ?= $(shell arch | tr A-Z a-z | sed 's/x86_64/amd64/' | sed 's/i386/amd64/' | sed 's/armv7l/arm/' | sed 's/aarch64/arm64/')
OS ?= $(shell uname | tr A-Z a-z)
VERSION ?= $(shell git describe --tags --always | sed 's/^v//')
DOCKER_REGISTRY ?= ghcr.io/mutablelogic

$(CMD_DIR): FORCE
@echo Build cmd $(notdir $@)
@${GO} build -o ${BUILD_DIR}/$(notdir $@) ${BUILD_FLAGS} ./$@
# Paths to locations, etc
BUILD_DIR := "build"
CMD_DIR := $(filter-out cmd/ffmpeg/README.md, $(wildcard cmd/ffmpeg/*))
BUILD_TAG := ${DOCKER_REGISTRY}/go-media-${OS}-${ARCH}:${VERSION}

$(PLUGIN_DIR): FORCE
@echo Build plugin $(notdir $@)
@${GO} build -buildmode=plugin -o ${BUILD_DIR}/$(notdir $@).plugin ${BUILD_FLAGS} ./$@
all: clean cmds

FORCE:
cmds: $(CMD_DIR)

docker:
@echo Build docker image
docker: docker-dep
@echo build docker image: ${BUILD_TAG} for ${OS}/${ARCH}
@${DOCKER} build \
--tag go-media:$(shell git describe --tags) \
--build-arg PLATFORM=$(shell ${GO} env GOOS) \
--build-arg ARCH=$(shell ${GO} env GOARCH) \
--build-arg VERSION=kinetic \
--tag ${BUILD_TAG} \
--build-arg ARCH=${ARCH} \
--build-arg OS=${OS} \
--build-arg SOURCE=${BUILD_MODULE} \
--build-arg VERSION=${VERSION} \
-f etc/docker/Dockerfile .

test: clean dependencies
@echo Test sys/
@${GO} test ./sys/...
@echo Test pkg/
@${GO} test ./pkg/...
docker-push: docker-dep
@echo push docker image: ${BUILD_TAG}
@${DOCKER} push ${BUILD_TAG}

test: go-dep
@echo Test
@${GO} mod tidy
@${GO} test ./sys/ffmpeg61

$(CMD_DIR): go-dep mkdir
@echo Build cmd $(notdir $@)
@${GO} build ${BUILD_FLAGS} -o ${BUILD_DIR}/$(notdir $@) ./$@

FORCE:

go-dep:
@test -f "${GO}" && test -x "${GO}" || (echo "Missing go binary" && exit 1)

dependencies: mkdir
ifeq (,${GO})
$(error "Missing go binary")
endif
docker-dep:
@test -f "${DOCKER}" && test -x "${DOCKER}" || (echo "Missing docker binary" && exit 1)

mkdir:
@echo Mkdir
@echo Mkdir ${BUILD_DIR}
@install -d ${BUILD_DIR}

clean:
Expand Down
69 changes: 25 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@

This module provides an interface for media services, including:

* Bindings in golang for [ffmpeg 5.1](https://ffmpeg.org/);
* Opening media files, devices and network sockets for reading
and writing;
* Retrieving metadata and artwork from audio and video media;
* Re-multiplexing media files from one format to another;
* Fingerprinting audio files to identify music.
* Bindings in golang for [ffmpeg 6](https://ffmpeg.org/);
* Opening media files, devices and network sockets for reading and writing;
* Retrieving metadata and artwork from audio and video media;
* Re-multiplexing media files from one format to another;
* Fingerprinting audio files to identify music.

## Current Status

Expand All @@ -17,66 +16,48 @@ you are interested in, please see below "Contributing & Distribution" below.

## Requirements

In order to build the examples, you'll need the library and header files for [ffmpeg 5.1](https://ffmpeg.org/download.html) installed. The `chromaprint` library is also required for fingerprinting audio files.

On Macintosh with [homebrew](http://bew.sh/), for example:
In order to build the examples, you'll need the library and header files for [ffmpeg 6](https://ffmpeg.org/download.html) installed.
The `chromaprint` library is also required for fingerprinting audio files. On Macintosh with [homebrew](http://bew.sh/), for example:

```bash
brew install ffmpeg chromaprint make
brew install ffmpeg@6 chromaprint make
```

There are some examples in the `cmd` folder of the main repository on how to use
the package. The various make targets are:

* `make all` will perform tests, build all examples and the backend API;
* `make test` will perform tests;
* `make cmd` will build example command-line tools into the `build` folder;
* `make clean` will remove all build artifacts.
* `make all` will perform tests, build all examples and the backend API;
* `make test` will perform tests;
* `make cmd` will build example command-line tools into the `build` folder;
* `make clean` will remove all build artifacts.

There are also some targets to build a docker image:

* `DOCKER_REGISTRY=docker.io/user make docker` will build a docker image;
* `DOCKER_REGISTRY=docker.io/user make docker-push` will push the docker image to the registry.

For example,

```bash
git clone [email protected]:djthorpe/go-media.git
cd go-media
make
DOCKER_REGISTRY=ghcr.io/mutablelogic make docker
```

## Examples

There are two example [Command Line applications](https://github.com/mutablelogic/go-media/tree/master/cmd):

* `extractartwork` can be used to walk through a directory and extract artwork from media
files and save the artwork into files;
* `transcode` can be used to copy, re-mux and re-sample media files from one format to another.

You can compile both applications with `make cmd`which places the binaries into the `build` folder.
Use the `-help` option on either application to see the options.


## Media Transcoding

You can programmatically demultiplex, re-multiplex and re-sample media files using the following packages:

* `sys/ffmpeg51` provides the implementation of the lower-level function calls
to ffmpeg. The documentation is [here](https://pkg.go.dev/github.com/mutablelogic/go-media/sys/ffmpeg51)
* `pkg/media` provides the higher-level API for opening media files, reading,
transcoding, resampling and writing media files. The interfaces and documentation
are best read here:
* [Audio](https://github.com/mutablelogic/go-media/blob/master/audio.go)
* [Video](https://github.com/mutablelogic/go-media/blob/master/video.go)
* [Media](https://github.com/mutablelogic/go-media/blob/master/media.go)
* And [here](https://pkg.go.dev/github.com/mutablelogic/go-media/)

## Audio Fingerprinting

You can programmatically fingerprint audio files, compare fingerprints and identify music using the following packages:

* `sys/chromaprint` provides the implementation of the lower-level function calls
to chromaprint. The documentation is [here](https://pkg.go.dev/github.com/mutablelogic/go-media/sys/chromaprint)
* `pkg/chromaprint` provides the higher-level API for fingerprinting and identifying music. The documentation
is [here](https://pkg.go.dev/github.com/mutablelogic/go-media/pkg/chromaprint).
* `sys/chromaprint` provides the implementation of the lower-level function calls
to chromaprint. The documentation is [here](https://pkg.go.dev/github.com/mutablelogic/go-media/sys/chromaprint)
* `pkg/chromaprint` provides the higher-level API for fingerprinting and identifying music. The documentation
is [here](https://pkg.go.dev/github.com/mutablelogic/go-media/pkg/chromaprint).

You'll need an API key in order to use the [AcoustID](https://acoustid.org/) service. You can get a key
You'll need an API key in order to use the [AcoustID](https://acoustid.org/) service. You can get a key
[here](https://acoustid.org/login).

## Contributing & Distribution
Expand All @@ -88,9 +69,9 @@ The license is Apache 2 so feel free to redistribute. Redistributions in either
code or binary form must reproduce the copyright notice, and please link back to this
repository for more information:

> Copyright (c) 2021-2023 David Thorpe, All rights reserved.
> Copyright (c) 2021-2024 David Thorpe, All rights reserved.
## References

* https://ffmpeg.org/doxygen/5.1/index.html
* https://ffmpeg.org/doxygen/6.1/index.html

Loading

0 comments on commit bd06e71

Please sign in to comment.