mirror of
https://github.com/u2takey/ffmpeg-go.git
synced 2025-09-27 12:22:08 +08:00
Merge pull request #109 from stombeur/master
add example reading frame with ss
This commit is contained in:
@@ -30,6 +30,18 @@ func TestExampleReadFrameAsJpeg(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestExampleReadTimePositionAsJpeg(t *testing.T) {
|
||||||
|
reader := ExampleReadTimePositionAsJpeg("./sample_data/in1.mp4", 4)
|
||||||
|
img, err := imaging.Decode(reader)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
err = imaging.Save(img, "./sample_data/out2.jpeg")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestExampleShowProgress(t *testing.T) {
|
func TestExampleShowProgress(t *testing.T) {
|
||||||
ExampleShowProgress("./sample_data/in1.mp4", "./sample_data/out2.mp4")
|
ExampleShowProgress("./sample_data/in1.mp4", "./sample_data/out2.mp4")
|
||||||
}
|
}
|
||||||
|
21
examples/readTimePositionAsJpeg.go
Normal file
21
examples/readTimePositionAsJpeg.go
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
package examples
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"io"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
ffmpeg "github.com/u2takey/ffmpeg-go"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ExampleReadTimePositionAsJpeg(inFileName string, seconds int) io.Reader {
|
||||||
|
buf := bytes.NewBuffer(nil)
|
||||||
|
err := ffmpeg.Input(inFileName, ffmpeg.KwArgs{"ss": seconds}).
|
||||||
|
Output("pipe:", ffmpeg.KwArgs{"vframes": 1, "format": "image2", "vcodec": "mjpeg"}).
|
||||||
|
WithOutput(buf, os.Stdout).
|
||||||
|
Run()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
return buf
|
||||||
|
}
|
Binary file not shown.
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
BIN
examples/sample_data/out2.jpeg
Normal file
BIN
examples/sample_data/out2.jpeg
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
Reference in New Issue
Block a user