2
votes

Trying to stitch videos using Azure Media Encoder Standard.

Using this piece of code in Java (com.microsoft.azure:azure-media:0.9.7) to create a job for Azure MES:

Job.Creator jobCreator = Job.create()
    .setName(outputAssetName)
    .addInputMediaAsset("nb:cid:UUID:ID1")
    .addInputMediaAsset("nb:cid:UUID:ID2")
    .setPriority(2)
    .addTaskCreator(task);

When submitting the job, this results in the following error:

Nov 08, 2017 6:30:03 PM com.microsoft.windowsazure.services.media.implementation.MediaExceptionProcessor processCatch
WARNING: com.sun.jersey.api.client.UniformInterfaceException: Client response status: 400
         com.sun.jersey.api.client.UniformInterfaceException: Client response status: 400
at com.microsoft.windowsazure.services.media.implementation.MediaBatchOperations.parseBatchResult(MediaBatchOperations.java:368)
at com.microsoft.windowsazure.services.media.models.Job$Creator.processResponse(Job.java:190)
at com.microsoft.windowsazure.services.media.entityoperations.EntityRestProxy.create(EntityRestProxy.java:138)
at com.microsoft.windowsazure.services.media.implementation.MediaExceptionProcessor.create(MediaExceptionProcessor.java:140)
...
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.lang.Thread.run(Thread.java:748)

With a single InputMediaAsset this works fine.

Two questions:

  1. Do you know the solution of how to submit more than one asset using Java?
  2. If not, is there a way to get a more informative error message than just 400 out of Azure MES?

EDIT

Task config:

{
  "Version": 1.0,
  "Codecs": [
    {
      "Type": "CopyVideo"
    },
    {
      "Type": "CopyAudio"
    }
  ],
  "Outputs": [
    {
      "FileName": "{Basename}_stitch.mp4",
      "Format": {
        "Type": "MP4Format"
      }
    }
  ],
  "Sources": [
    {
      "AssetID": "nb:cid:UUID:ID1",
      "StartTime": "00:00:00",
      "Duration": "00:00:05"
    },
    {
      "AssetID": "nb:cid:UUID:ID2",
      "StartTime": "00:00:00",
      "Duration": "00:00:05"
    }
  ]
}

I dug deeper to see if I can at least get a better error message, and I got this:

HTTP/1.1 400 Bad Request
Content-ID: 2
X-Content-Type-Options: nosniff
Cache-Control: no-cache
DataServiceVersion: 1.0;
Content-Type: application/xml;charset=utf-8

<?xml version="1.0" encoding="utf-8"?><m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><m:code /><m:message xml:lang="en-US">Input asset not used - nb:cid:UUID:ID2</m:message></m:error>

It is telling me that the second input asset is not used, even though I specify it in the task config - and the task config comes from Azure Media Services Explorer and works there.

1

1 Answers

0
votes

In your Java code, you should be making a call to create a Task before invoking the Job.Creator. Something like the following:

 Task.CreateBatchOperation task = Task.create(mediaProcessor.getId(), taskXml).setConfiguration(taskConfiguration).setName("Stitching Task");

In the above, the taskXml object should have references to both input Assets. The default Java sample code, such as the one here, will only have a reference to a single JobInputAsset element. Since you are using two (or more) input Assets, you will have to expand taskXml to include the additional JobInputAsset elements.