video: add extra ffmpeg magic for aspect-scaling
This commit is contained in:
parent
08f0c94131
commit
b5fe725836
9
video.go
9
video.go
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user