thumbnail

package
v0.0.0-...-3911a41 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2017 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package thumbnail generates image thumbnails from videos.

(*Service).Generate spawns an HTTP server listening on a local random port to serve the video to an external program (see Thumbnailer interface). The external program is expected to output the thumbnail image on its standard output.

The default implementation uses ffmpeg.

See ServiceFromConfig for accepted configuration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FFmpegThumbnailer

type FFmpegThumbnailer struct{}

FFmpegThumbnailer is a Thumbnailer that generates a thumbnail with ffmpeg.

func (FFmpegThumbnailer) Command

func (f FFmpegThumbnailer) Command(uri *url.URL) (string, []string)

Command implements the Command method for the Thumbnailer interface.

type Service

type Service struct {
	// contains filtered or unexported fields
}

A Service controls the generation of video thumbnails.

func NewService

func NewService(th Thumbnailer, timeout time.Duration, maxProcs int) *Service

NewService builds a new Service. Zero timeout or maxProcs means no limit.

func ServiceFromConfig

func ServiceFromConfig(conf jsonconfig.Obj) (*Service, error)

ServiceFromConfig builds a new Service from configuration. Example expected configuration object (all keys are optional) :

{
  // command defaults to FFmpegThumbnailer and $uri is replaced by
  // the real value at runtime.
  "command": ["/opt/local/bin/ffmpeg", "-i", "$uri", "pipe:1"],
  // Maximun number of milliseconds for running the thumbnailing subprocess.
  // A zero or negative timeout means no timeout.
  "timeout": 2000,
  // Maximum number of thumbnailing subprocess running at same time.
  // A zero or negative maxProcs means no limit.
  "maxProcs": 5
}

func (*Service) Generate

func (s *Service) Generate(videoRef blob.Ref, w io.Writer, src blob.Fetcher) error

Generate reads the video given by videoRef from src and writes its thumbnail image to w.

type Thumbnailer

type Thumbnailer interface {
	Command(*url.URL) (prog string, args []string)
}

Thumbnailer is the interface that wraps the Command method.

Command receives the (HTTP) uri from where to get the video to generate a thumbnail and returns program and arguments. The command is expected to output the thumbnail image on its stdout, or exit with an error code.

See FFmpegThumbnailer.Command for example.

var DefaultThumbnailer Thumbnailer = FFmpegThumbnailer{}

DefaultThumbnailer is the default Thumbnailer when no config is set.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL