Azure媒体服务 - 3gp文件返回错误“不支持文件类型或编解码器”。

时间:2013-07-31 03:19:27

标签: c# azure video-encoding azure-media-services

尝试在Azure Media Services中上传,转换/编码和准备.3gp视频文件时,我们收到错误File type or codec not supported.基于this information,导入时应支持3gp。如何正确导入3gp并将其转换为MP4?

以下是我们的内部日志所说的内容:

The job stopped due to cancellation or an error.
Job ID: nb:jid:UUID:6dc360df-de54-eb45-ae0d-bdc3d2c810fe
Job Name: Encoding and Packaging for dedf426e0b5b41199e8a111f27744890
Job State: Error
Error Details:  
Task Id: nb:tid:UUID:12424cbb-0013-4685-8e6b-b224d99db186
    Error Code: UserInput
    Error Message: File type or codec not supported.

我们的代码:

/// <summary>
/// This method performs all processing necessary to the media in question. This method will wait while processing is completed.
/// </summary>
/// <param name="fileName">Unique file name with extension</param>
/// <returns>IsSuccess</returns>
public bool ProcessMedia(string fileName)
{
    var mediaCloud = GetCloudMediaContext();

    string assetName = GetAssetNameFromFileName(fileName);

    var asset = mediaCloud.Assets.Where(a => a.Name == assetName).SingleOrDefault();
    IJob job = mediaCloud.Jobs.Create("Encoding and Packaging for " + asset.Name);
    var encoder = GetMediaProcessor(_mediaProcessorNameMap[MediaProcessors.WindowsAzureMediaEncoder]);

    /* Firing off a chain of encoding jobs
     * 1) Original Encoding -> MP4 (Direct download stream)
     * 2) MP4 -> IIS Smooth Streaming (Microsoft Silverlight)
     * 3) IIS -> HLS (Apple and IOS) */

    //MP4
    var mp4Task = job.Tasks.AddNew(String.Format("MP4 Encoding for {0}", asset.Name), encoder, "H264 Broadband 720p", TaskOptions.None);
    mp4Task.InputAssets.Add(asset);
    var mp4Asset = mp4Task.OutputAssets.AddNew(String.Format(MP4_ASSET_NAME_FORMAT, asset.Name), AssetCreationOptions.None);

    //Generate thumbnails from MP4
    foreach (ThumbnailTypes thumbnailType in Enum.GetValues(typeof(ThumbnailTypes)))
    {
        var thumbnailTask = job.Tasks.AddNew(String.Format("Thumbnail Generation for {0}", asset.Name), encoder, 
            String.Format(TASK_THUMBNAIL_GENERATION_FORMAT, thumbnailType, ImageProcessor.ThumbnailSizes[thumbnailType].Height), 
            TaskOptions.None);
        thumbnailTask.InputAssets.Add(mp4Asset);
        var thumnailAsset = thumbnailTask.OutputAssets.AddNew(String.Format(THUMBNAIL_ASSET_NAME_FORMAT, thumbnailType, asset.Name), AssetCreationOptions.None);
    }

    //IIS
    var encodingTask = job.Tasks.AddNew(String.Format("IIS Encoding for {0}", asset.Name), encoder, "H264 Smooth Streaming 720p", TaskOptions.None);
    encodingTask.InputAssets.Add(mp4Asset);
    var ssOutput = encodingTask.OutputAssets.AddNew(String.Format(IIS_ASSET_NAME_FORMAT, asset.Name), AssetCreationOptions.None);

    //HLS
    var packager = GetMediaProcessor(_mediaProcessorNameMap[MediaProcessors.WindowsAzureMediaPackager]);
    var conversionTask = job.Tasks.AddNew(String.Format("HLS Packaging for {0}", asset.Name), packager, TASK_MSMOOTH_TO_HLS, TaskOptions.None);
    conversionTask.InputAssets.Add(ssOutput);
    conversionTask.OutputAssets.AddNew(String.Format(HLS_ASSET_NAME_FORMAT, asset.Name), AssetCreationOptions.None);

    if (job.Tasks.Count() == 0) //no processing was required
        return true;

    job.StateChanged += new EventHandler<JobStateChangedEventArgs>(StateChanged);

    job.Submit();

    // Check job execution and wait for job to finish. 
    Task progressJobTask = job.GetExecutionProgressTask(CancellationToken.None);
    progressJobTask.Wait();

    return job.State == JobState.Finished;
}

1 个答案:

答案 0 :(得分:1)

您应该查看Azure Media Encoder formats and codecs,而不是Microsoft Expression Encoder支持的文件格式。

上述文档指出支持.3GPP.3GPP2作为文件格式。视频编解码器非常有限:H.264MPEG-1MPEG-2MPEG-4VC-1Windows Media VideoDV

基于3GPP数据here。似乎文件格式本身支持多个视频和音频编解码器。 Azure Media Encoder仅支持其中的少数几个。请使用某些第三方工具(例如VLC)仔细检查Audio and Video codecs文件的3GP,并确保它们位于Azure Media Encoder支持的列表中。请注意,文件扩展名未定义用于对该文件中的媒体进行编码的编解码器。