video: add extra ffmpeg magic for aspect-scaling

This commit is contained in:
mappu 2016-12-05 19:01:00 +13:00
parent 08f0c94131
commit b5fe725836

View File

@ -2,18 +2,25 @@ package thumbnail
import (
"bytes"
"fmt"
"io"
"os/exec"
)
func (this *Thumbnailer) RenderScaledFfmpeg(absPath string) ([]byte, error) {
scaleCmd := fmt.Sprintf(
`thumbnail,scale='if(gt(a,%d/%d),%d,-1)':'if(gt(a,%d/%d),-1,%d)'`,
this.Height, this.Width, this.Height,
this.Height, this.Width, this.Width,
)
cmd := exec.Command(
"ffmpeg",
"-loglevel", "0",
"-an",
"-i", absPath,
"-vf", "thumbnail,scale=100:100",
"-vf", scaleCmd,
"-frames:v", "1",
"-f", "image2pipe",
"-c:v", "png",