Skip to content

Commit

Permalink
Create video-clip.go
Browse files Browse the repository at this point in the history
  • Loading branch information
arthemium authored Oct 12, 2023
1 parent 71a39de commit 3db867b
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions examples/video-clip.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/ First install the go client with "go get github.com/apivideo/api.video-go-client"
// Documentation: https://github.com/apivideo/api.video-go-client/blob/main/docs/VideosApi.md#create

package main

import (
"context"
"fmt"
"os"
apivideosdk "github.com/apivideo/api.video-go-client"
)
// upload a video with a clip
func main() {
client := apivideosdk.ClientBuilder("YOUR_API_KEY").Build()
// if you rather like to use the sandbox environment:
// client := apivideosdk.SandboxClientBuilder("YOUR_SANDBOX_API_KEY").Build()
video clip := apivideosdk.VideoClip{}
videoClip.SetStartTimecode("00:00:20")
videoClip.SetEndTimecode("00:00:22")
videoCreationPayload := apivideosdk.VideoCreationPayload{}
videoCreationPayload.SetTitle("my title")
videoCreationPayload.SetClip(videoClip)
res, err := client.Videos.Create(videoCreationPayload)
videoId := res.videoId
uploadRes, err := apiVideoClient.Videos.UploadFile(videoId, videoFile)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `Videos.Create``: %v\
", err)
}
// response from `Create`: Video
fmt.Fprintf(os.Stdout, "Response from `Videos.Create`: %v\
", res)
}

0 comments on commit 3db867b

Please sign in to comment.