mirror of
https://github.com/u2takey/ffmpeg-go.git
synced 2025-10-05 16:06:52 +08:00
add more examples
This commit is contained in:
@@ -50,10 +50,51 @@ func TestSimpleS3StreamExample(t *testing.T) {
|
||||
assert.Nil(t, err)
|
||||
}
|
||||
|
||||
func TestExampleChangeCodec(t *testing.T) {
|
||||
err := ffmpeg.Input("./sample_data/in1.mp4").
|
||||
Output("./sample_data/out1.mp4", ffmpeg.KwArgs{"c:v": "libx265"}).
|
||||
OverWriteOutput().ErrorToStdOut().Run()
|
||||
assert.Nil(t, err)
|
||||
}
|
||||
|
||||
func TestExampleCutVideo(t *testing.T) {
|
||||
err := ffmpeg.Input("./sample_data/in1.mp4", ffmpeg.KwArgs{"ss": 1}).
|
||||
Output("./sample_data/out1.mp4", ffmpeg.KwArgs{"t": 1}).OverWriteOutput().Run()
|
||||
assert.Nil(t, err)
|
||||
}
|
||||
|
||||
func TestExampleScaleVideo(t *testing.T) {
|
||||
err := ffmpeg.Input("./sample_data/in1.mp4").
|
||||
Output("./sample_data/out1.mp4", ffmpeg.KwArgs{"vf": "scale=w=480:h=240"}).
|
||||
OverWriteOutput().ErrorToStdOut().Run()
|
||||
assert.Nil(t, err)
|
||||
}
|
||||
|
||||
func TestExampleAddWatermark(t *testing.T) {
|
||||
// show watermark with size 64:-1 in the top left corner after seconds 1
|
||||
overlay := ffmpeg.Input("./sample_data/overlay.png").Filter("scale", ffmpeg.Args{"64:-1"})
|
||||
err := ffmpeg.Filter(
|
||||
[]*ffmpeg.Stream{
|
||||
ffmpeg.Input("./sample_data/in1.mp4"),
|
||||
overlay,
|
||||
}, "overlay", ffmpeg.Args{"10:10"}, ffmpeg.KwArgs{"enable": "gte(t,1)"}).
|
||||
Output("./sample_data/out1.mp4").OverWriteOutput().ErrorToStdOut().Run()
|
||||
assert.Nil(t, err)
|
||||
}
|
||||
|
||||
func TestExampleCutVideoForGif(t *testing.T) {
|
||||
err := ffmpeg.Input("./sample_data/in1.mp4", ffmpeg.KwArgs{"ss": "1"}).
|
||||
Output("./sample_data/out1.gif", ffmpeg.KwArgs{"s": "320x240", "pix_fmt": "rgb24", "t": "3", "r": "3"}).
|
||||
OverWriteOutput().ErrorToStdOut().Run()
|
||||
assert.Nil(t, err)
|
||||
}
|
||||
|
||||
func TestExampleMultipleOutput(t *testing.T) {
|
||||
input := ffmpeg.Input("./sample_data/in1.mp4").Split()
|
||||
out1 := input.Get("0").Filter("scale", ffmpeg.Args{"1920:-1"}).Output("./sample_data/1920.mp4", ffmpeg.KwArgs{"b:v": "5000k"})
|
||||
out2 := input.Get("1").Filter("scale", ffmpeg.Args{"1280:-1"}).Output("./sample_data/1280.mp4", ffmpeg.KwArgs{"b:v": "2800k"})
|
||||
out1 := input.Get("0").Filter("scale", ffmpeg.Args{"1920:-1"}).
|
||||
Output("./sample_data/1920.mp4", ffmpeg.KwArgs{"b:v": "5000k"})
|
||||
out2 := input.Get("1").Filter("scale", ffmpeg.Args{"1280:-1"}).
|
||||
Output("./sample_data/1280.mp4", ffmpeg.KwArgs{"b:v": "2800k"})
|
||||
|
||||
err := ffmpeg.MergeOutputs(out1, out2).OverWriteOutput().ErrorToStdOut().Run()
|
||||
assert.Nil(t, err)
|
||||
|
Reference in New Issue
Block a user