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.
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 }
type Thumbnailer ¶
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.