-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample.go
67 lines (55 loc) · 2.41 KB
/
sample.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package main
import (
"github.com/Bimde/openshot-sdk-go/openshot"
)
const (
username = "demo-cloud"
password = "demo-password"
openshotURL = "http://cloud.openshot.org/"
)
func main() {
// Create an OpenShot client with the server location and credentials to login
client := openshot.New(openshotURL, username, password)
// Create a project with as many customized properties as desired
// More information at: http://cloud.openshot.org/doc/api_endpoints.html?highlight=location_x#projects
project, err := client.CreateProject(&openshot.Project{Name: "My Project"})
if err != nil {
// deal with error
}
// Create a file using a video stored in s3 bucket "mybucket" located at "path/to/file/file_name.mp4" in the bucket
// More information at: http://cloud.openshot.org/doc/api_endpoints.html?highlight=location_x#files
file, err := client.CreateFile(project, openshot.CreateFileStruct(openshot.CreateFileS3InfoStruct("file_name.mp4", "path/to/file/", "mybucket")))
if err != nil {
// deal with error
}
// Create a clip using your new file as it's source
// More information at: http://cloud.openshot.org/doc/api_endpoints.html?highlight=location_x#clips
clip, err := client.CreateClip(project, openshot.CreateClipStruct(file, project))
if err != nil {
// deal with error
}
// Modify clip's x location
const frame = 120
const xLocation = 0.5 // Read http://cloud.openshot.org/doc/api_endpoints.html?highlight=location_x#clips for properties and descriptions
client.AddPropertyPoint(clip, "location_x", frame, xLocation)
// Remember to call update since adding property points doesn't add them on the server
// (for efficiency's sake, since many people want to add hundreds of property points!)
clip, err = client.UpdateClip(clip)
if err != nil {
// deal with error
}
// Create an export
export := openshot.CreateDefaultExportStruct(project)
export.JSON["width"] = 720 // Read http://cloud.openshot.org/doc/api_endpoints.html#exports for available properties
export, err = client.CreateExport(project, export)
if err != nil {
// deal with error
}
// Wait until export is ready, either by polling `client.GetExport` or by using a webhook to trigger a seperate handler.
// More on that here: http://cloud.openshot.org/doc/api_endpoints.html?highlight=location_x#id36
export, err = client.GetExport(export.ID)
if err != nil {
// deal with error
}
// Exported video link available at export.Output
}