【问题标题】:Azure encoding job failsAzure 编码作业失败
【发布时间】:2015-04-13 07:35:06
【问题描述】:

我正在通过 rest 将视频上传到我们的 azure 媒体服务器,但编码作业失败,出现以下异常:

    null
ErrorProcessingTask : Azure Media Encoder could not load the preset Preset.xml on source tom2.mp4:File type isn't supported.

我可以看到它声明文件类型不受支持,但如果我手动上传它没有问题。

这就是我发布视频的方式

     var uploadLocatorId = asset["Id"];

            var uploadurl = asset["BaseUri"].ToString() + "/tom2.mp4" + asset["ContentAccessComponent"].ToString();

            var formcontent = new MultipartFormDataContent();

            FileStream stream = File.OpenRead(@"C:\VideoFiles\tom2.mp4");
            byte[] fileBytes = new byte[stream.Length];
            Int32 blobLength = fileBytes.Length;
            stream.Read(fileBytes, 0, fileBytes.Length);
        //    stream.Close();

            var requestContent = new MultipartFormDataContent();
            //    here you can specify boundary if you need---^
            var mp4ieContent = new ByteArrayContent(fileBytes);
            mp4ieContent.Headers.ContentType =
                MediaTypeHeaderValue.Parse("application/octet-stream");
            mp4ieContent.Headers.ContentLength = blobLength;

            var memory = new MemoryStream(fileBytes);
            var streamcontent = new StreamContent(memory);
            formcontent.Add(streamcontent, "tom2", "tom2.mp4");
           // formcontent.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");

            var date = DateTime.UtcNow.ToString("R", System.Globalization.CultureInfo.InvariantCulture);
            var container = AssetID.ToString();
            container = container.Replace("nb:cid:UUID:", "asset-");


            client = new HttpClient();
            client.DefaultRequestHeaders.Add("x-ms-version", "2014-02-14");
            client.DefaultRequestHeaders.Add("x-ms-date", date);
            client.DefaultRequestHeaders.Add("x-ms-blob-type", "BlockBlob");
            client.DefaultRequestHeaders.Accept.Add(type);

            result = await client.PutAsync(uploadurl, formcontent);

该文件存在于 azure 服务器上,但无法播放。

谁能给我指个方向,拜托

【问题讨论】:

    标签: azure azure-media-services


    【解决方案1】:

    following topic 描述了使用 REST 创建资产并将文件上传到 blob 时需要采取的步骤(您可以使用任何方法上传文件)。

    一般步骤是:

    • 创建资产(生成 blob 容器)。
    • 获取 SAS 网址。
    • 创建一个资产文件(与您的物理文件同名,例如 Video.mp4)。
    • 将您的物理文件 (Video.mp4) 上传到 SAS url。有关上传文件的更多信息,请参阅 Upload file to Azure Blob Storage directly from browser

    • 根据需要使用大小和其他信息更新资产文件。

    • 安排编码作业。
    • 通过创建按需定位器来发布资产。

    或者,您可以在上传 Blob 后创建资产文件。然后,您将枚举容器并创建相应的 AssetFiles。

    【讨论】:

      【解决方案2】:

      您的视频资产中似乎缺少一些元数据。以下代码可用于创建资产,并将文件作为特定资产的 AssetFiles 上传。然后在视频资产上运行编码预设。

      https://msdn.microsoft.com/en-us/library/azure/jj129584.aspx

      干杯, 严明飞

      【讨论】:

      • 您好明飞,感谢您的回复。在过去一周左右的时间里,我一直在关注该文档,并且无法使用其余的 api 生成一个工作示例。此外,我还没有找到任何显示使用 rest api 的示例项目。因此,我放弃了这种方法。我输了。
      猜你喜欢
      • 2015-04-11
      • 2021-11-08
      • 2020-01-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-20
      相关资源
      最近更新 更多