繁体   English   中英

Azure媒体服务-使用v3编码4K UHD视频

[英]Azure Media Services - encoding 4K UHD video with v3

我制作了一个库,使用v3 API(.NET Core)在Azure中对视频进行编码。 我成功地进行了高达FHD的编码。 但是后来我尝试对4k UHD视频进行编码(基于如何使用自定义TransformH264 Multiple Bitrate 4K文章进行编码 )。 因此,这是我创建此Transform的代码:

        private static async Task<Transform> Ensure4kTransformExistsAsync(IAzureMediaServicesClient client,
        string resourceGroupName,
        string accountName)
    {
        H264Layer CreateH264Layer(int bitrate, int width, int height)
        {
            return new H264Layer(
                profile: H264VideoProfile.Auto,
                level: "auto",
                bitrate: bitrate, // Note that the units is in bits per second
                maxBitrate: bitrate,
                //bufferWindow: TimeSpan.FromSeconds(5),    // this is the default
                width: width.ToString(),
                height: height.ToString(),
                bFrames: 3,
                referenceFrames: 3,
                adaptiveBFrame: true,
                frameRate: "0/1"
            );
        }

        // Does a Transform already exist with the desired name? Assume that an existing Transform with the desired name
        // also uses the same recipe or Preset for processing content.
        Transform transform = await client.Transforms.GetAsync(resourceGroupName, accountName, TRANSFORM_NAME_H264_MULTIPLE_4K_S);

        if (transform != null) return transform;

        // Create a new Transform Outputs array - this defines the set of outputs for the Transform
        TransformOutput[] outputs =
        {
            // Create a new TransformOutput with a custom Standard Encoder Preset
            new TransformOutput(
                new StandardEncoderPreset(
                    codecs: new Codec[]
                    {
                        // Add an AAC Audio layer for the audio encoding
                        new AacAudio(
                            channels: 2,
                            samplingRate: 48000,
                            bitrate: 128000,
                            profile: AacAudioProfile.AacLc
                        ),
                        // Next, add a H264Video for the video encoding
                        new H264Video(
                            // Set the GOP interval to 2 seconds for both H264Layers
                            keyFrameInterval: TimeSpan.FromSeconds(2),
                            // Add H264Layers
                            layers: new[]
                            {
                                CreateH264Layer(20000000, 4096, 2304),
                                CreateH264Layer(18000000, 3840, 2160),
                                CreateH264Layer(16000000, 3840, 2160),
                                CreateH264Layer(14000000, 3840, 2160),
                                CreateH264Layer(12000000, 2560, 1440),
                                CreateH264Layer(10000000, 2560, 1440),
                                CreateH264Layer(8000000, 2560, 1440),
                                CreateH264Layer(6000000, 1920, 1080),
                                CreateH264Layer(4700000, 1920, 1080),
                                CreateH264Layer(3400000, 1280, 720),
                                CreateH264Layer(2250000, 960, 540),
                                CreateH264Layer(1000000, 640, 360)
                            }
                        ),
                        // Also generate a set of PNG thumbnails
                        new PngImage(
                            start: "25%",
                            step: "25%",
                            range: "80%",
                            layers: new[]
                            {
                                new PngLayer(
                                    "50%",
                                    "50%"
                                )
                            }
                        )
                    },
                    // Specify the format for the output files - one for video+audio, and another for the thumbnails
                    formats: new Format[]
                    {
                        // Mux the H.264 video and AAC audio into MP4 files, using basename, label, bitrate and extension macros
                        // Note that since you have multiple H264Layers defined above, you have to use a macro that produces unique names per H264Layer
                        // Either {Label} or {Bitrate} should suffice

                        new Mp4Format(
                            "Video-{Basename}-{Label}-{Bitrate}{Extension}"
                        ),
                        new PngFormat(
                            "Thumbnail-{Basename}-{Index}{Extension}"
                        )
                    }
                ),
                OnErrorType.StopProcessingJob,
                Priority.Normal
            )
        };

        const string DESCRIPTION = "Multiple 4k";
        // Create the custom Transform with the outputs defined above
        transform = await client.Transforms.CreateOrUpdateAsync(resourceGroupName, accountName, TRANSFORM_NAME_H264_MULTIPLE_4K_S,
            outputs,
            DESCRIPTION);

        return transform;
    }

但是作业最终出现以下错误:

作业因错误而终止:致命服务错误,请联系支持。 发生了错误。 阶段:ProcessSubtaskRequest。 代码:System.Net.WebException。

我确实使用了S3 Media Reserved Unit进行编码。 那么,有什么办法可以使它起作用?

将解决方案回发到此线程以确保完整性

  1. 示例代码(RunAsync()方法)中存在一个错误,该错误导致Jobs使用了错误的输出资产。 该错误现已修复。
  2. 错误处理中有一个相关的错误正在解决

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM