|
|
@ -33,7 +33,7 @@ func VideoSize(filename string) (image.Rectangle, error) { |
|
|
|
func VideoEncode(filename string, size image.Rectangle, thumbDir string) error { |
|
|
|
func VideoEncode(filename string, size image.Rectangle, thumbDir string) error { |
|
|
|
dest := thumbFilename(thumbDir, size, path.Base(filename)) |
|
|
|
dest := thumbFilename(thumbDir, size, path.Base(filename)) |
|
|
|
os.MkdirAll(filepath.Dir(dest), 0755) |
|
|
|
os.MkdirAll(filepath.Dir(dest), 0755) |
|
|
|
cmd := exec.Command("ffmpeg", "-i", filename, "-vf", fmt.Sprintf("scale=%d:%d", size.Dx(), size.Dy()), dest) |
|
|
|
cmd := exec.Command("ffmpeg", "-i", filename, "-vf", fmt.Sprintf("scale=%d:%d", size.Dx(), size.Dy()), "-strict", "-2", dest) |
|
|
|
if out, err := cmd.CombinedOutput(); err != nil { |
|
|
|
if out, err := cmd.CombinedOutput(); err != nil { |
|
|
|
os.Remove(dest) |
|
|
|
os.Remove(dest) |
|
|
|
return fmt.Errorf("could not thumb video: %s", string(out)) |
|
|
|
return fmt.Errorf("could not thumb video: %s", string(out)) |
|
|
|