golang 使用ffmpeg获取video的任意帧

xiaoxiao2021-02-28  93

golang 使用ffmpeg获取video的任意帧

func GetFrame(index int) *bytes.Buffer { filename := "test.mp4" width := 2752 height := 2208 // cmd := exec.Command("ffmpeg", "-i", filename, "-vframes", strconv.Itoa(index), "-s", fmt.Sprintf("%dx%d", width, height), "-f", "singlejpeg", "-") cmd := exec.Command("ffmpeg", "-i", filename, "-vframes", "1", "-s", fmt.Sprintf("%dx%d", width, height), "-f", "singlejpeg", "-") buf := new(bytes.Buffer) cmd.Stdout = buf if cmd.Run() != nil { panic("could not generate frame") } return buf }
转载请注明原文地址: https://www.6miu.com/read-50575.html

最新回复(0)