发布时间:2024-12-22 22:39:04
import (
"os/exec"
"log"
"github.com/disintegration/imaging"
)
func captureVideoFrame(videoPath string, framePath string, timeOffset float64) error {
cmd := exec.Command("ffmpeg", "-ss", strconv.FormatFloat(timeOffset, 'f', -1, 64), "-i", videoPath, "-vframes", "1", "-q:v", "2", framePath)
err := cmd.Run()
if err != nil {
log.Println("Error capturing video frame:", err)
return err
}
return nil
}
func processFrame(framePath string, outputPath string) error {
img, err := imaging.Open(framePath)
if err != nil {
log.Println("Error opening image:", err)
return err
}
// 在这里进行对图像的任何处理
err = imaging.Save(img, outputPath)
if err != nil {
log.Println("Error saving image:", err)
return err
}
return nil
}