Documentation
¶
Index ¶
- Constants
- func Convert(ctx context.Context, data []byte, spec *Spec) ([]byte, error)
- func GetThumbnail(ctx context.Context, data []byte, width, height int) ([]byte, error)
- func GetWaveform(ctx context.Context, data []byte, spec *Spec, maxSamples int) ([]byte, error)
- func SetTempDirectory(path string) error
- type AudioCodec
- type MIMEType
- type Spec
- type VideoCodec
Constants ¶
const ( // Audio codecs. CodecOpus AudioCodec = "opus" CodecAAC AudioCodec = "aac" // Video codecs. CodecH264 VideoCodec = "h264" )
Variables ¶
This section is empty.
Functions ¶
func Convert ¶
Convert processes the given data, assumed to represent a media file, according to the target specification given. For information on how these definitions affect media conversions, see the documentation for the Spec type.
func GetThumbnail ¶
GetThumbnail returns a static JPEG image for the first frame of the given video data. If both width and height dimensions are given, the thumbnail will be resized to exactly those pixel values. If either dimension is given, the thumbnail will be resized while retaining aspect ratio. If no value is given (i.e. if both values are zero), then the thumbnail dimensions will follow input video dimensions.
func GetWaveform ¶
GetWaveform returns a list of samples, scaled from 0 to 100, representing linear loudness values.
An error will be returned if the Spec given has no sample-rate or duration corresponding to the data given, as both these values are necessary for deriving the number of samples.
The number of samples returned will be equal to the given maximum number provided, and will be padded with 0 values if necessary.
func SetTempDirectory ¶
SetTempDirectory sets the global temporary directory used internally by media conversion commands.
Types ¶
type AudioCodec ¶
type AudioCodec string
AudioCodec represents the encoding method used for an audio stream.
type MIMEType ¶
type MIMEType string
MIMEType represents a the media type for a data buffer. In general, values given concrete MIMEType identities are meant to be handled as targets for conversion and metadata extraction -- all other formats are handled on a best-case basis.
func (MIMEType) BaseMediaType ¶
BaseMediaType returns the media type without any additional parameters.
type Spec ¶
type Spec struct { // Required parameters. MIME MIMEType // The MIME type for the target media. // Optional parameters. AudioCodec AudioCodec // The codec to use for the audio stream, must be correct for the MIME type given. AudioChannels int // The number of channels for the audio stream, 1 for mono, 2 for stereo. AudioBitRate int // The bit rate for the audio stream, in kBit/second. AudioSampleRate int // The sample-rate frequency for the audio stream, common values are 44100, 48000. VideoCodec VideoCodec // The codec to use for the video stream, must be correct for the MIME type given. VideoPixelFormat string // The pixel format used for video stream, typically 'yub420p' for MP4. VideoFrameRate int // The frame rate for the video stream, in frames/second. VideoWidth int // The width of the video stream, in pixels. VideoHeight int // The height of the video stream, in pixels. VideoFilter string // A complex filter to apply to the video stream. ImageWidth int // The width of the image, in pixels. ImageHeight int // The height of the image, in pixels. ImageQuality int // Image quality for lossy image formats, typically a value from 1 to 100. ImageFrameRate int // The frame-rate for animated images. Duration time.Duration // The duration of the audio or video stream. StripMetadata bool // Whether or not to remove any container-level metadata present in the stream. }
Spec represents the description of a target media file; depending on platform support and media conversion intricacies, source media files can be of any type, even types that aren't represented here. Nevertheless, it is intended that media types and codecs represented here are valid as both input and output formats.
type VideoCodec ¶
type VideoCodec string
VideoCodec represents the encoding method used for a video stream.