add example; add escape

move sample data
This commit is contained in:
wanglei.w
2020-11-11 22:38:49 +08:00
parent b260b92d8a
commit 5a1890c3e8
18 changed files with 134 additions and 65 deletions

View 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
}