Skip to content

Commit

Permalink
Removed cli temporarily
Browse files Browse the repository at this point in the history
  • Loading branch information
djthorpe committed Jul 6, 2024
1 parent c142e8e commit 36b24b6
Show file tree
Hide file tree
Showing 14 changed files with 93 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
38 changes: 35 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
33 changes: 33 additions & 0 deletions cmd/examples/transcode/context.go
Original file line number Diff line number Diff line change
@@ -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
}
24 changes: 24 additions & 0 deletions cmd/examples/transcode/main.go
Original file line number Diff line number Diff line change
@@ -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 <in> <out>")
}

// Read the input
in, err := ffmpeg.Open(os.Args[1])
if err != nil {
log.Fatal(err)
}
defer in.Close()
}

0 comments on commit 36b24b6

Please sign in to comment.