mirror of
https://github.com/xnd5101/ffmpeg-go
synced 2025-09-27 09:12:05 +08:00
24 lines
475 B
Go
24 lines
475 B
Go
package examples
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
"io"
|
|
"os"
|
|
|
|
ffmpeg "github.com/u2takey/ffmpeg-go"
|
|
)
|
|
|
|
func ExampleReadFrameAsJpeg(inFileName string, frameNum int) io.Reader {
|
|
buf := bytes.NewBuffer(nil)
|
|
err := ffmpeg.Input(inFileName).
|
|
Filter("select", ffmpeg.Args{fmt.Sprintf("gte(n,%d)", frameNum)}).
|
|
Output("pipe:", ffmpeg.KwArgs{"vframes": 1, "format": "image2", "vcodec": "mjpeg"}).
|
|
WithOutput(buf, os.Stdout).
|
|
Run()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return buf
|
|
}
|