golang 使用ffmpeg获取video的任意帧

来源:互联网 发布:oracle filter 优化 编辑:程序博客网 时间:2024/05/18 09:41

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}