Coder Social home page Coder Social logo

zencoder-java's Introduction

zencoder-java

Java library for interacting with the Zencoder API.

Getting Started

Add the library as a dependancy to your project.

If you're using Maven, add this to your pom.xml file:

    <dependency>
          <groupId>com.brightcove.zencoder.api</groupId>
          <artifactId>zencoder-java</artifactId>
          <version>2.0.23</version>
    </dependency>

Import the client and related classes:

import com.brightcove.zencoder.client.ZencoderClient;
import com.brightcove.zencoder.client.ZencoderClientException;
import com.brightcove.zencoder.client.model.*
import com.brightcove.zencoder.client.request.*
import com.brightcove.zencoder.client.response.*;

Instantiate a new client with your API key:

ZencoderClient client = new ZencoderClient("INSERT_API_KEY_HERE");

Usage

Create a new job:

ZencoderCreateJobRequest job = new ZencoderCreateJobRequest();
job.setInput("s3://zencodertesting/test.mov");
List<ZencoderOutput> outputs = new ArrayList<ZencoderOutput>();

ZencoderOutput output1 = new ZencoderOutput();
output1.setFormat(ContainerFormat.MP4);
outputs.add(output1);

ZencoderOutput output2 = new ZencoderOutput();
output2.setFormat(ContainerFormat.WEBM);
outputs.add(output2);

job.setOutputs(outputs);
ZencoderCreateJobResponse response = client.createZencoderJob(job);

Query an existing job:

String jobId = response.getId();
ZencoderJobDetail details = client.getZencoderJob(jobId);
String inputId = details.getInputMediaFile().getId();
String outputId1 = response.getOutputs().get(0).getId();
String outputId2 = response.getOutputs().get(1).getId();

ZencoderInputOutputProgress inputProgress = client.getInputProgress(inputId);
ZencoderInputOutputProgress outputProgress1 = client.getOutputProgress(outputId1);
ZencoderInputOutputProgress outputProgress2 = client.getOutputProgress(outputId2);

Cancel and resubmit an existing job:

client.cancelJob(jobId);
client.resubmitJob(jobId);

Copyright

See LICENSE.txt for details.

zencoder-java's People

Contributors

archeus avatar bckbreeman avatar bcmtolan avatar dependabot[bot] avatar jjballano avatar mmcc avatar schworer avatar skidder avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zencoder-java's Issues

Audio Loudness Level is missing

Based on documentation:
https://zencoder.support.brightcove.com/encoding-settings/general-audio-video/encoding-settings-audio-processing.html#audio_loudness_level

there is no loudness level:

`audio_loudness_level
audio_loudness_level:Float
API Versions: V1, V2

Parent: outputs

Valid Values: A number of decibels, from -60.0 to 60.0

Compatible Job Types: vod

Example: -23

Description:

Adjust the loudness level of the audio. This is measured in LUFS and specified in dB. This is useful to set the output loudness level to conform to a standard (-23dB for EBU R.128)`

ZencoderClient.listJobs can't parse response from server

Today I came across this exception while trying to list the jobs:

com.brightcove.zencoder.client.ZencoderClientException: Unable to deserialize ZencoderCreateJobResponse as JSON
Caused by: org.codehaus.jackson.JsonParseException: Numeric value (3169615172842) out of range of int
 at [Source: java.io.StringReader@640c52ba; line: 1, column: 73227]
    at org.codehaus.jackson.JsonParser._constructError(JsonParser.java:1433)
    at org.codehaus.jackson.impl.JsonParserMinimalBase._reportError(JsonParserMinimalBase.java:521)
    at org.codehaus.jackson.impl.JsonParserBase.convertNumberToInt(JsonParserBase.java:829)
    at org.codehaus.jackson.impl.JsonParserBase.getIntValue(JsonParserBase.java:625)
    at org.codehaus.jackson.map.deser.std.StdDeserializer._parseInteger(StdDeserializer.java:303)
    at org.codehaus.jackson.map.deser.std.StdDeserializer$IntegerDeserializer.deserialize(StdDeserializer.java:819)
    at org.codehaus.jackson.map.deser.std.StdDeserializer$IntegerDeserializer.deserialize(StdDeserializer.java:806)
    at org.codehaus.jackson.map.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:299)
    at org.codehaus.jackson.map.deser.SettableBeanProperty$MethodProperty.deserializeAndSet(SettableBeanProperty.java:414)
    at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:697)
    at org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:580)
    at org.codehaus.jackson.map.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:299)
    at org.codehaus.jackson.map.deser.SettableBeanProperty$MethodProperty.deserializeAndSet(SettableBeanProperty.java:414)
    at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:697)
    at org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:580)
    at org.codehaus.jackson.map.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:299)
    at org.codehaus.jackson.map.deser.SettableBeanProperty$MethodProperty.deserializeAndSet(SettableBeanProperty.java:414)
    at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:697)
    at org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:580)
    at org.codehaus.jackson.map.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:217)
    at org.codehaus.jackson.map.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:194)
    at org.codehaus.jackson.map.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:30)
    at org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:2732)
    at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1877)
    at com.brightcove.zencoder.client.ZencoderClient.listJobs(ZencoderClient.java:218)

Either the server is returning garbage or the code running on the server was changed and the SDK is out of sync.

Client throwing jackson error

When i use the client to trigger a transcsoding job for avi or flv format.
The client is unable to process the job status response. It is throwing the below error.

The below mentioned enums does not have the complete list.
com/brightcove/zencoder/client/model/AudioCodec.java
com/brightcove/zencoder/client/model/VideoCodec.java
com/brightcove/zencoder/client/model/ContainerFormat.java

Caused by: org.codehaus.jackson.map.JsonMappingException: Can not construct instance of com.brightcove.zencoder.client.model.VideoCodec from String value 'flv1': value not one of declared Enum instance names
at [Source: java.io.StringReader@5f51cbeb; line: 1, column: 2846](through reference chain: com.brightcove.zencoder.client.response.ZencoderJobDetailResponse["job"]->com.brightcove.zencoder.client.response.ZencoderJobDetail["input_media_file"]->com.brightcove.zencoder.client.response.ZencoderMediaFile["video_codec"])

Setting Access Control on ZencoderOutput causes 422

ZencoderOutput.setAccessControl is expecting a single S3AccessControl while the API is expecting multiple.

S3AccessControl acl = new S3AccessControl();
acl.setPermission(S3PermissionType.FULL_CONTROL);
acl.setGrantee(canonicalUserId);

ZencoderOutput output = new ZencoderOutput();
output.setAccessControl(acl);

creates this json

"access_control": {
    "grantee": "...",
    "permission": "FULL_CONTROL"
}

while the api expects

"access_control": [{
    "grantee": "...",
    "permission": "FULL_CONTROL"
}]

Thumbnail.java is using a List<S3AccessControl> so changing the type is probably all that needs to be done.

problem with accented chars in filenames

I had a issue sending zencoder requests using your java client when filenames contained accented characters (French names for example).
I had the following response :
{"errors":["Invalid JSON string. Please correct your syntax and try again. Try a JSON validator like http://www.jsonlint.com/ if you aren't sure what is wrong."],"request_body":null}

The only thing I did to solve this issue was adding the following string to the Content-Type header in ZencoderClient.java (L104) :
"; charset=utf-8"
The resulting line is :
headers.add("Content-Type", "application/json; charset=utf-8");

Thought you might be interested.

Maven Central

Can you add this library to maven central? I need to add it to my gradle(/maven) build file, and it won't work unless it is hosted on central.

Cancel job is broken

When calling ZencoderClient.cancelJob(jobId), the job is not canceled but resubmitted.

In ZencoderClient.cancelJob(jobId):
String url = api_url + "/jobs/" + id + "/resubmit.json";

Should be:
String url = api_url + "/jobs/" + id + "/cancel.json";

Client throwing jackson error

Hi,

I am facing couple of issue,

  1. The client is not available in the maven repository. I had to download the source and compile the jar myself.

  2. Setting group label for thumbnail group is mandatory but the client is not able to parse the response. I am getting the below error.

 at [Source: java.io.StringReader@1b688556; line: 1, column: 3921](through reference chain: com.brightcove.zencoder.client.response.ZencoderJobDetailResponse["job"]->com.brightcove.zencoder.client.response.ZencoderJobDetail["thumbnails"]->com.brightcove.zencoder.client.model.Thumbnail["group_label"])

SegmentedStream does not contain a `source` attribute

The SegmentedStream class does not have a source attribute, even though one exists in the JSON - as seen here.

I've worked around this for now by extending the SegmentedStream class, and adding a source attribute - which does work. I can submit a pull request for a fixed SegmentedStream if that would be helpful.

Thanks.

listJobs doesn't work with a read-only API key

Hello,

If I use a read-only API key with listJobs() it doesn't work. This is very unfortunate because it forces me to use a full access key in a context where I'm only doing read-only operations. This violates the principle of least privilege and is a security issue. Please fix this!

com.brightcove.zencoder.client.ZencoderClientException: {"errors":["api_key is read only"]}
at com.brightcove.zencoder.client.ZencoderClient.listJobs(ZencoderClient.java:212)

Thanks!

Florin

SegmentingType problems

There are two different issues when creating a ZencoderOutput, as it relates to the SegmentingType.

  1. The SegmentingType only includes an enum value for hls and mms, but there is no dash, which is available in the prepare_for_segmenting JSON attribute for an output.
  2. When creating a ZencoderOutput object, I should be able to specify multiple output types, either as a comma separated string (as shown here), or as an array (as shown here). Perhaps an addPrepareForSegmenting() method should be added, instead of just setPrepareForSegmenting().

Thank you.

IllegalArgumentException: Unrecognized Type: [null]

Two things that I want to mention

  1. After a small struggle I have found something related to HttpRequest
  • My request should be POST but RestTemplate is creating it as GET not sure why.
    capture
    1. Facing IllegalArgumentException because mediaType and ctx in TypeFactory are null not sure how.
      capture1
      TRACE
      java.lang.IllegalArgumentException: Unrecognized Type: [null]
      at com.fasterxml.jackson.databind.type.TypeFactory._fromAny(TypeFactory.java:1109)
      at com.fasterxml.jackson.databind.type.TypeFactory.constructType(TypeFactory.java:566)
      at com.fasterxml.jackson.databind.type.TypeFactory.constructType(TypeFactory.java:602)
      at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.getJavaType(AbstractJackson2HttpMessageConverter.java:281)
      at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.canRead(AbstractJackson2HttpMessageConverter.java:138)
      at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.canRead(AbstractJackson2HttpMessageConverter.java:133)
      at org.springframework.web.client.RestTemplate$AcceptHeaderRequestCallback.doWithRequest(RestTemplate.java:672)
      at org.springframework.web.client.RestTemplate$HttpEntityRequestCallback.doWithRequest(RestTemplate.java:738)
      at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:558)
      at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:529)
      at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:448)
      at com.brightcove.zencoder.client.ZencoderClient.createZencoderJob(ZencoderClient.java:142)
      at com.tchadv.messaging.services.ZencoderService.test(ZencoderService.java:36)
      at com.tchadv.messaging.controllers.MessageController.index(MessageController.java:67)
      at router.Routes$$anonfun$routes$1$$anonfun$applyOrElse$1$$anonfun$apply$1.apply(Routes.scala:190)
      at router.Routes$$anonfun$routes$1$$anonfun$applyOrElse$1$$anonfun$apply$1.apply(Routes.scala:190)
      at play.core.routing.HandlerInvokerFactory$$anon$4.resultCall(HandlerInvoker.scala:157)
      at play.core.routing.HandlerInvokerFactory$$anon$4.resultCall(HandlerInvoker.scala:156)
      at play.core.routing.HandlerInvokerFactory$JavaActionInvokerFactory$$anon$14$$anon$3$$anon$1.invocation(HandlerInvoker.scala:136)
      at play.core.j.JavaAction$$anon$1.call(JavaAction.scala:73)
      at play.http.HttpRequestHandler$1.call(HttpRequestHandler.java:54)
      at play.core.j.JavaAction$$anonfun$7.apply(JavaAction.scala:108)
      at play.core.j.JavaAction$$anonfun$7.apply(JavaAction.scala:108)
      at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
      at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
      at play.core.j.HttpExecutionContext$$anon$2.run(HttpExecutionContext.scala:56)
      at play.api.libs.iteratee.Execution$trampoline$.execute(Execution.scala:70)
      at play.core.j.HttpExecutionContext.execute(HttpExecutionContext.scala:48)
      at scala.concurrent.impl.Future$.apply(Future.scala:31)
      at scala.concurrent.Future$.apply(Future.scala:492)
      at play.core.j.JavaAction.apply(JavaAction.scala:108)
      at play.api.mvc.Action$$anonfun$apply$2$$anonfun$apply$5$$anonfun$apply$6.apply(Action.scala:112)
      at play.api.mvc.Action$$anonfun$apply$2$$anonfun$apply$5$$anonfun$apply$6.apply(Action.scala:112)
      at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
      at play.api.mvc.Action$$anonfun$apply$2$$anonfun$apply$5.apply(Action.scala:111)
      at play.api.mvc.Action$$anonfun$apply$2$$anonfun$apply$5.apply(Action.scala:110)
      at scala.Option.map(Option.scala:146)
      at play.api.mvc.Action$$anonfun$apply$2.apply(Action.scala:110)
      at play.api.mvc.Action$$anonfun$apply$2.apply(Action.scala:103)
      at scala.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:251)
      at scala.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:249)
      at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32)
      at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:55)
      at akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply$mcV$sp(BatchingExecutor.scala:91)
      at akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply(BatchingExecutor.scala:91)
      at akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply(BatchingExecutor.scala:91)
      at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:72)
      at akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:90)
      at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:39)
      at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:405)
      at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
      at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
      at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
      at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

Is there any thing addition to make the request work?

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.