C# Azure媒体服务作业长期处于处理状态
我正在开发C#.NET5WebAPI。我需要为视频创建缩略图,我是使用Azure媒体服务创建的,但当我提交作业时,它处于状态处理状态的时间很长。我需要升级我的服务计划还是有其他解决方案? 这是我的代码: 首先,我创建转换C# Azure媒体服务作业长期处于处理状态,c#,azure-media-services,.net-5,video-thumbnails,C#,Azure Media Services,.net 5,Video Thumbnails,我正在开发C#.NET5WebAPI。我需要为视频创建缩略图,我是使用Azure媒体服务创建的,但当我提交作业时,它处于状态处理状态的时间很长。我需要升级我的服务计划还是有其他解决方案? 这是我的代码: 首先,我创建转换 TransformOutput[] outputs = new TransformOutput[] { // Create a new TransformOutput with a custom Standard Encoder
TransformOutput[] outputs = new TransformOutput[]
{
// Create a new TransformOutput with a custom Standard Encoder Preset
// This demonstrates how to create custom codec and layer output settings
new TransformOutput(
new StandardEncoderPreset(
codecs: new Codec[]
{
// Generate a set of PNG thumbnails
new PngImage(
start: "5%",
step: "100%",
range: "1",
layers: new PngLayer[]{
new PngLayer(
width: "50%",
height: "50%"
)
}
)
},
new PngFormat(
filenamePattern: "videothumb-{Index}{Extension}"
)
}
),
onError: OnErrorType.StopProcessingJob,
relativePriority: Priority.Normal
)
};
// Create the custom Transform with the outputs defined above
transform = client.Transforms.CreateOrUpdate(resourceGroupName, accountName, transformName, outputs, description);
然后我创建并提交我的作业
string uniqueness = Guid.NewGuid().ToString().Substring(0, 13);
string jobName = "job-" + uniqueness;
string inputAssetName = "input-" + uniqueness;
string outputAssetName = "output-" + uniqueness;
// The input to the Job is a HTTPS URL pointing to an MP4 file
var input = new JobInputHttp(
files: new List<String> { blobUrl }
);
Asset outputAsset = CreateOutputAsset(client, config.ResourceGroup, config.AccountName, outputAssetName);
string thumbContainerName = $"asset-{outputAsset.AssetId}";
Job job = SubmitJob(client, config.ResourceGroup, config.AccountName, transformName, jobName, input, outputAsset.Name);
DateTime startedTime = DateTime.Now;
job = WaitForJobToFinish(client, config.ResourceGroup, config.AccountName, transformName, jobName);
TimeSpan elapsed = DateTime.Now - startedTime;
string university=Guid.NewGuid().ToString().Substring(0,13);
字符串jobName=“作业-”+唯一性;
字符串inputAssetName=“输入-”+唯一性;
字符串outputAssetName=“output-”+唯一性;
//作业的输入是指向MP4文件的HTTPS URL
var输入=新作业输入权限TTP(
文件:新列表{blobUrl}
);
资产outputAsset=CreateOutputAsset(客户端,config.ResourceGroup,config.AccountName,outputAssetName);
字符串thumbContainerName=$“资产-{outputAsset.AssetId}”;
Job Job=SubmitJob(客户机,config.ResourceGroup,config.AccountName,transformName,jobName,input,outputAsset.Name);
DateTime startedTime=DateTime.Now;
job=WaitForJobToFinish(客户端,config.ResourceGroup,config.AccountName,transformName,jobName);
TimeSpan Passed=DateTime.Now-startedTime;
经过的时间介于15到25秒之间
当我转到Azure portal时,我可以看到我的作业长时间处于处理状态。我要处理的视频持续4秒。AMS当前未针对处理短视频或仅从视频中提取缩略图进行优化。您看到的已用时间是预期的。如果您只需要从非常短的视频中提取缩略图,从速度的角度来看,最好直接使用FFmpeg等媒体管道来实现这一点。您在AMS中看到的大部分运行时间很可能是由于设置VM以处理视频所花费的时间。AMS当前未针对处理短视频或仅从视频中提取缩略图进行优化。您看到的已用时间是预期的。如果您只需要从非常短的视频中提取缩略图,从速度的角度来看,最好直接使用FFmpeg等媒体管道来实现这一点。对于AMS,您看到的大部分运行时间很可能是由于设置VM以处理视频所花费的时间。对于需要超快速返回的基于FFMPEG的简单函数,您可以使用类似我们提供的示例的Azure函数。
对于需要超快速返回的基于FFMPEG的简单函数,您可以使用我们提供的示例中的Azure函数。
嘿,我做到了。非常感谢很高兴听到!欢迎稍后在这里与其他人分享您的解决方案。嘿,我做到了。非常感谢很高兴听到!请稍后在这里与其他人分享您的解决方案。