stash/pkg/ffmpeg/encoder_transcode.go

51 lines
929 B
Go
Raw Normal View History

2019-02-10 05:30:54 +00:00
package ffmpeg
2019-07-24 22:17:22 +00:00
import (
"io"
"os"
)
2019-02-10 05:30:54 +00:00
type TranscodeOptions struct {
OutputPath string
}
func (e *Encoder) Transcode(probeResult VideoFile, options TranscodeOptions) {
args := []string{
"-i", probeResult.Path,
"-c:v", "libx264",
"-pix_fmt", "yuv420p",
2019-02-10 05:30:54 +00:00
"-profile:v", "high",
"-level", "4.2",
"-preset", "superfast",
"-crf", "23",
"-vf", "scale=iw:-2",
"-c:a", "aac",
"-strict", "-2",
2019-02-10 05:30:54 +00:00
options.OutputPath,
}
_, _ = e.run(probeResult, args)
}
2019-07-24 22:17:22 +00:00
func (e *Encoder) StreamTranscode(probeResult VideoFile, startTime string) (io.ReadCloser, *os.Process, error) {
args := []string{}
if startTime != "" {
args = append(args, "-ss", startTime)
}
args = append(args,
2019-07-24 22:17:22 +00:00
"-i", probeResult.Path,
"-c:v", "libvpx-vp9",
"-vf", "scale=iw:-2",
"-deadline", "realtime",
"-cpu-used", "5",
"-row-mt", "1",
2019-07-24 22:17:22 +00:00
"-crf", "30",
"-b:v", "0",
"-f", "webm",
"pipe:",
)
2019-07-24 22:17:22 +00:00
return e.stream(probeResult, args)
}