Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions examples/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package examples
import (
"testing"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/credentials"
"github.com/disintegration/imaging"
"github.com/stretchr/testify/assert"
ffmpeg "github.com/u2takey/ffmpeg-go"
Expand Down Expand Up @@ -50,9 +50,9 @@ func TestSimpleS3StreamExample(t *testing.T) {
err := ffmpeg.Input("./sample_data/in1.mp4", nil).
Output("s3://data-1251825869/test_out.ts", ffmpeg.KwArgs{
"aws_config": &aws.Config{
Credentials: credentials.NewStaticCredentials("xx", "yyy", ""),
Credentials: credentials.NewStaticCredentialsProvider("xx", "yyy", ""),
//Endpoint: aws.String("xx"),
Region: aws.String("yyy"),
Region: "yyy",
},
// outputS3 use stream output, so you can only use supported format
// if you want mp4 format for example, you can output it to a file, and then call s3 sdk to do upload
Expand Down
23 changes: 16 additions & 7 deletions ffmpeg.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import (
"os"
"strings"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3/s3manager"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/feature/s3/manager"
"github.com/aws/aws-sdk-go-v2/service/s3"
)

// Input file URL (ffmpeg “-i“ option)
Expand Down Expand Up @@ -146,14 +147,22 @@ func (s *Stream) outputS3Stream(fileName string, kwargs ...KwArgs) *Stream {
done <- struct{}{}
}()

sess, err := session.NewSession(awsConfig)
uploader := s3manager.NewUploader(sess)
_, err = uploader.Upload(&s3manager.UploadInput{
sess, err := config.LoadDefaultConfig(context.TODO())
if err != nil {
log.Println("load aws config fail", err)
return
}
sess.ConfigSources = append(sess.ConfigSources, awsConfig)
client := s3.NewFromConfig(sess, func(o *s3.Options) {
o.BaseEndpoint = awsConfig.BaseEndpoint
})

uploader := manager.NewUploader(client)
_, err = uploader.Upload(context.Background(), &s3.PutObjectInput{
Bucket: &bucket,
Key: &key,
Body: r,
})
//fmt.Println(ioutil.ReadAll(r))
if err != nil {
log.Println("upload fail", err)
}
Expand Down
23 changes: 23 additions & 0 deletions ffmpeg_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"syscall"
"testing"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/credentials"
"github.com/stretchr/testify/assert"
)

Expand All @@ -27,3 +29,24 @@ func TestGlobalCommandOptions(t *testing.T) {
assert.Equal(t, 0, cmd.SysProcAttr.Pgid)
assert.True(t, cmd.SysProcAttr.Setpgid)
}

func TestSimpleS3StreamExample(t *testing.T) {
err := Input("./examples/sample_data/head-pose-face-detection-male-short.mp4").
Output("s3://{testing_bucket}/data-1251825869/test_out.ts", KwArgs{
"aws_config": &aws.Config{
Credentials: credentials.NewStaticCredentialsProvider(
"",
"",
""),
Region: "us-east-1",
BaseEndpoint: aws.String(""),
},
// outputS3 use stream output, so you can only use supported format
// if you want mp4 format for example, you can output it to a file, and then call s3 sdk to do upload
"format": "mpegts",
}).
OverWriteOutput().
Run()

assert.Nil(t, err)
}
33 changes: 29 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,36 @@
module github.com/u2takey/ffmpeg-go

go 1.16
go 1.23

require (
github.com/aws/aws-sdk-go v1.38.20
github.com/aws/aws-sdk-go-v2 v1.36.6
github.com/aws/aws-sdk-go-v2/config v1.29.18
github.com/aws/aws-sdk-go-v2/credentials v1.17.71
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.85
github.com/aws/aws-sdk-go-v2/service/s3 v1.84.1
github.com/disintegration/imaging v1.6.2
github.com/stretchr/testify v1.5.1
github.com/stretchr/testify v1.10.0
github.com/u2takey/go-utils v0.3.1
gocv.io/x/gocv v0.25.0
gocv.io/x/gocv v0.41.0
)

require (
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.11 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.33 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.37 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.37 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.37 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.4 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.7.5 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.18 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.18 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.25.6 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.4 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.34.1 // indirect
github.com/aws/smithy-go v1.22.4 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
2 changes: 1 addition & 1 deletion run.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func (s *Stream) Compile(options ...CompilationOption) *exec.Cmd {
for _, option := range GlobalCommandOptions {
option(cmd)
}
if LogCompiledCommand {
if LogCompiledCommand {
log.Printf("compiled command: ffmpeg %s\n", strings.Join(args, " "))
}
return cmd
Expand Down