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 (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (this *Thumbnailer) RenderScaledFfmpeg(absPath string) ([]byte, error) {
|
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(
|
cmd := exec.Command(
|
||||||
"ffmpeg",
|
"ffmpeg",
|
||||||
"-loglevel", "0",
|
"-loglevel", "0",
|
||||||
"-an",
|
"-an",
|
||||||
"-i", absPath,
|
"-i", absPath,
|
||||||
"-vf", "thumbnail,scale=100:100",
|
"-vf", scaleCmd,
|
||||||
"-frames:v", "1",
|
"-frames:v", "1",
|
||||||
"-f", "image2pipe",
|
"-f", "image2pipe",
|
||||||
"-c:v", "png",
|
"-c:v", "png",
|
||||||
|
Loading…
Reference in New Issue
Block a user