camlistore.org: camlistore.org/pkg/video/thumbnail Index | Files

package thumbnail

import "camlistore.org/pkg/video/thumbnail"

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

Package Files

handler.go service.go thumbnailer.go

type FFmpegThumbnailer Uses

type FFmpegThumbnailer struct{}

FFmpegThumbnailer is a Thumbnailer that generates a thumbnail with ffmpeg.

func (FFmpegThumbnailer) Command Uses

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

Command implements the Command method for the Thumbnailer interface.

type Service Uses

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

A Service controls the generation of video thumbnails.

func NewService Uses

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

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

func ServiceFromConfig Uses

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 Uses

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 Uses

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.

Package thumbnail imports 16 packages (graph). Updated 2018-04-30. Refresh now. Tools for package owners.