diff --git a/Makefile b/Makefile index 36a65e4..8121dbf 100755 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ BUILD_DIR := "build" CMD_DIR := $(filter-out cmd/ffmpeg/README.md, $(wildcard cmd/ffmpeg/*)) BUILD_TAG := ${DOCKER_REGISTRY}/go-media-${OS}-${ARCH}:${VERSION} -all: clean cli cmds +all: clean cmds cmds: $(CMD_DIR) diff --git a/README.md b/README.md index c91a5e4..b5a69e2 100644 --- a/README.md +++ b/README.md @@ -16,12 +16,46 @@ 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 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: +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 and SDL2 for the video player. + +### MacOS + +On Macintosh with [homebrew](http://bew.sh/), for example: ```bash brew install ffmpeg@6 chromaprint make +brew link ffmpeg@6 +``` + +### Debian + +If you're using Debian you may not be able to get the ffmpeg 6 unless you first of all add the debi-multimedia repository. +You can do this by adding the following line to your `/etc/apt/sources.list` file: + +```bash +# Run commands as privileged user +echo "deb https://www.deb-multimedia.org $(lsb_release -sc) main" >> /etc/apt/sources.list +apt update -y -oAcquire::AllowInsecureRepositories=true +apt install -y --force-yes deb-multimedia-keyring +``` + +Then you can proceed to install the ffmpeg 6 and the other dependencies: + +```bash +# Run commands as privileged user +apt install -y libavcodec-dev libavdevice-dev libavfilter-dev libavutil-dev libswscale-dev libswresample-dev +apt install -y libchromaprint-dev +apt install -y libsdl2-dev ``` +### Docker Container + +TODO + +## Examples + There are some examples in the `cmd` folder of the main repository on how to use the package. The various make targets are: @@ -43,8 +77,6 @@ cd go-media DOCKER_REGISTRY=ghcr.io/mutablelogic make docker ``` -## Examples - There are a variety of types of object needed as part of media processing. All examples require a `Manager` to be created, which is used to enumerate all supported formats and open media files and byte streams. diff --git a/cmd/cli/context.go b/_old/cli/context.go similarity index 100% rename from cmd/cli/context.go rename to _old/cli/context.go diff --git a/cmd/cli/decode.go b/_old/cli/decode.go similarity index 100% rename from cmd/cli/decode.go rename to _old/cli/decode.go diff --git a/cmd/cli/fingerprint.go b/_old/cli/fingerprint.go similarity index 100% rename from cmd/cli/fingerprint.go rename to _old/cli/fingerprint.go diff --git a/cmd/cli/formats.go b/_old/cli/formats.go similarity index 100% rename from cmd/cli/formats.go rename to _old/cli/formats.go diff --git a/cmd/cli/main.go b/_old/cli/main.go similarity index 100% rename from cmd/cli/main.go rename to _old/cli/main.go diff --git a/cmd/cli/metadata_artwork.go b/_old/cli/metadata_artwork.go similarity index 100% rename from cmd/cli/metadata_artwork.go rename to _old/cli/metadata_artwork.go diff --git a/cmd/cli/muxers_demuxers.go b/_old/cli/muxers_demuxers.go similarity index 100% rename from cmd/cli/muxers_demuxers.go rename to _old/cli/muxers_demuxers.go diff --git a/cmd/cli/probe.go b/_old/cli/probe.go similarity index 100% rename from cmd/cli/probe.go rename to _old/cli/probe.go diff --git a/cmd/cli/thumbnails.go b/_old/cli/thumbnails.go similarity index 100% rename from cmd/cli/thumbnails.go rename to _old/cli/thumbnails.go diff --git a/cmd/cli/version.go b/_old/cli/version.go similarity index 100% rename from cmd/cli/version.go rename to _old/cli/version.go diff --git a/cmd/examples/transcode/context.go b/cmd/examples/transcode/context.go new file mode 100644 index 0000000..97c8708 --- /dev/null +++ b/cmd/examples/transcode/context.go @@ -0,0 +1,33 @@ +package main + +import ( + "context" + "os" + "os/signal" +) + +/////////////////////////////////////////////////////////////////////////////// +// PUBLIC METHODS + +// ContextForSignal returns a context object which is cancelled when a signal +// is received. It returns nil if no signal parameter is provided +func ContextForSignal(signals ...os.Signal) context.Context { + if len(signals) == 0 { + return nil + } + + ch := make(chan os.Signal, 1) + ctx, cancel := context.WithCancel(context.Background()) + + // Send message on channel when signal received + signal.Notify(ch, signals...) + + // When any signal received, call cancel + go func() { + <-ch + cancel() + }() + + // Return success + return ctx +} diff --git a/cmd/examples/transcode/main.go b/cmd/examples/transcode/main.go new file mode 100644 index 0000000..319dfd4 --- /dev/null +++ b/cmd/examples/transcode/main.go @@ -0,0 +1,24 @@ +package main + +import ( + "log" + "os" + + // Packages + ffmpeg "github.com/mutablelogic/go-media/pkg/ffmpeg" +) + +// This example encodes an audio an video stream to a file +func main() { + // Check we have a filename + if len(os.Args) != 3 { + log.Fatal("Usage: transcode ") + } + + // Read the input + in, err := ffmpeg.Open(os.Args[1]) + if err != nil { + log.Fatal(err) + } + defer in.Close() +}