Giter Club home page Giter Club logo

openshot-sdk-go's Introduction

GoDoc Build Status codecov Go Report Card License: MIT

OpenShot SDK for Go

Hello! This sdk provides an easy-to-use go interface for the OpenShot Cloud API.

Installation

go get github.com/Bimde/openshot-sdk-go/openshot

How to Use

Add import "github.com/Bimde/openshot-sdk-go/openshot" to your file.

Create a new OpenShot client: client := openshot.New(baseUrl, username, password)

Create a project: project := client.CreateProject(&openshot.Project{Name: "My Project"})

Start adding files, clips, animations, transitions and creating exports of your work!

Look at our GoDoc for a complete overview of the functionality available thus far.

Complete Example

This example shows how to create a project, add a video from an S3 bucket, create a clip with it, change it's x position, and create an export with a different aspect ratio than the input clips.

package main

import (
	"github.com/Bimde/openshot-sdk-go/openshot"
)

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
}

This sdk was purpose-built for this project, it's a great place to look for example usages. In particular, check out this package. The tests in this SDK are also quite thorough and can be used as examples.

openshot-sdk-go's People

Contributors

bimde avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

openshot-sdk-go's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.