FEAT: Media Convert + s3 Integration
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/aws/aws-sdk-go-v2/aws"
|
||||
"github.com/aws/aws-sdk-go-v2/service/mediaconvert"
|
||||
"github.com/aws/aws-sdk-go-v2/service/mediaconvert/types"
|
||||
)
|
||||
|
||||
var MediaConvertClient MediaConvert
|
||||
|
||||
type MediaConvert interface {
|
||||
QueueEncodingJob(ctx context.Context, key string) (string, error)
|
||||
}
|
||||
|
||||
type MediaConvertConcrete struct {
|
||||
MediaConvertClient *mediaconvert.Client
|
||||
Role string
|
||||
InputBucket string
|
||||
OutputBucket string
|
||||
}
|
||||
|
||||
func (svc MediaConvertConcrete) QueueEncodingJob(ctx context.Context, key string) (string, error) {
|
||||
input := fmt.Sprintf("s3://%s/%s", svc.InputBucket, key)
|
||||
destination := fmt.Sprintf("s3://%s/%s", svc.OutputBucket, key)
|
||||
|
||||
job, err := svc.MediaConvertClient.CreateJob(ctx, &mediaconvert.CreateJobInput{
|
||||
Role: &svc.Role,
|
||||
Settings: &types.JobSettings{
|
||||
Inputs: []types.Input{
|
||||
{
|
||||
FileInput: &input,
|
||||
AudioSelectors: map[string]types.AudioSelector{
|
||||
"Audio Selector 1": {
|
||||
DefaultSelection: types.AudioDefaultSelectionDefault,
|
||||
},
|
||||
},
|
||||
VideoSelector: &types.VideoSelector{},
|
||||
},
|
||||
},
|
||||
OutputGroups: []types.OutputGroup{
|
||||
{
|
||||
Name: aws.String("File Group"),
|
||||
OutputGroupSettings: &types.OutputGroupSettings{
|
||||
Type: types.OutputGroupTypeFileGroupSettings,
|
||||
FileGroupSettings: &types.FileGroupSettings{
|
||||
Destination: &destination,
|
||||
},
|
||||
},
|
||||
Outputs: []types.Output{
|
||||
{
|
||||
ContainerSettings: &types.ContainerSettings{
|
||||
Container: types.ContainerTypeMp4,
|
||||
},
|
||||
VideoDescription: &types.VideoDescription{
|
||||
CodecSettings: &types.VideoCodecSettings{
|
||||
Codec: types.VideoCodecH264,
|
||||
H264Settings: &types.H264Settings{
|
||||
RateControlMode: types.H264RateControlModeQvbr,
|
||||
},
|
||||
},
|
||||
},
|
||||
AudioDescriptions: []types.AudioDescription{
|
||||
{
|
||||
CodecSettings: &types.AudioCodecSettings{
|
||||
Codec: types.AudioCodecAac,
|
||||
AacSettings: &types.AacSettings{
|
||||
Bitrate: aws.Int32(96000),
|
||||
CodingMode: types.AacCodingModeCodingMode20,
|
||||
SampleRate: aws.Int32(48000),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return aws.ToString(job.Job.Id), nil
|
||||
}
|
||||
Reference in New Issue
Block a user