mirror of
https://github.com/xnd5101/ffmpeg-go
synced 2025-10-05 12:16:49 +08:00
demo save
This commit is contained in:
23
examples/readFrameAsJpeg.go
Normal file
23
examples/readFrameAsJpeg.go
Normal file
@@ -0,0 +1,23 @@
|
||||
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
|
||||
}
|
Reference in New Issue
Block a user