Documentation
¶
Overview ¶
Package ffmpeg is subflux's one ffmpeg and ffprobe runner. Every call has a deadline and a stdout cap, keeps only a bounded tail of stderr, kills its child when the call ends early, and hands the child the video as an open file, never as a path.
Index ¶
- Variables
- type Runner
- func (r Runner) ExtractSubtitle(ctx context.Context, video *os.File, index int, keepASS bool) ([]byte, error)
- func (r Runner) PCM(ctx context.Context, video *os.File, maxFrames int, frame func([]int16) error) error
- func (r Runner) Preview(ctx context.Context, video *os.File, from time.Duration) (io.ReadCloser, error)
- func (r Runner) Probe(ctx context.Context, video *os.File) ([]Stream, error)
- type Stream
Constants ¶
This section is empty.
Variables ¶
var ( ErrUnavailable = errors.New("ffmpeg: not available") // ErrOutputCap means the child wrote past its call's cap and was stopped there. ErrOutputCap = errors.New("ffmpeg: output over its cap") )
Functions ¶
This section is empty.
Types ¶
type Runner ¶
type Runner struct{ FFmpeg, FFprobe string }
Runner runs ffmpeg and ffprobe. Its zero value runs them from PATH; FFmpeg and FFprobe name other binaries.
func (Runner) ExtractSubtitle ¶
func (r Runner) ExtractSubtitle(ctx context.Context, video *os.File, index int, keepASS bool) ([]byte, error)
ExtractSubtitle returns stream index of video as an ASS document when keepASS is set (the stream is copied, so it must be ASS or SSA), else converted to SRT; over maxExtractBytes is ErrOutputCap.
func (Runner) PCM ¶
func (r Runner) PCM(ctx context.Context, video *os.File, maxFrames int, frame func([]int16) error) error
PCM decodes video's first audio stream to 8 kHz mono and calls frame with each 80-sample (10 ms) frame in order; the slice is reused, so frame must not keep it. It returns frame's first error, or nil once the stream ends or maxFrames frames (at most 500,000) were passed, the child then killed. A trailing part frame is dropped.
func (Runner) Preview ¶
func (r Runner) Preview(ctx context.Context, video *os.File, from time.Duration) (io.ReadCloser, error)
Preview streams a fragmented MP4 of video from from: 360p H.264 ultrafast with AAC stereo, at most timing.PreviewSpan long, its timestamps starting at 0. The stream ends at maxPreviewBytes or previewTimeout; a read returns the child's failure, if any, in place of io.EOF. Close kills the child and is safe while a Read is blocked.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package ffmpegtest lets a test binary stand in for ffmpeg and ffprobe.
|
Package ffmpegtest lets a test binary stand in for ffmpeg and ffprobe. |