我在上传后使用Windows Azure Media Services进行视频处理。我的基本工作流程包括将文件上传到WAMS资产,创建作业,创建2个任务 - 第一个从视频创建缩略图,第二个将其编码为HTML5。目前,一切都很好,但我被迫为各个任务创建2个不同的输出资产容器。作业完成后,我会将文件(缩略图)复制到视频资源,然后删除缩略图资源,以便所有生成的文件都在同一资产中。
这是有效的,但感觉很乱,并且带来一些复制文件的开销,然后删除不必要的资产。有没有办法告诉编码任务使用缩略图任务的输出资产?
答案 0 :(得分:1)
简短的回答是否定的。 这是设计的,我有兴趣知道为什么你的用例要求.jpg与你的视频在同一个容器中。
答案 1 :(得分:1)
请改用以下内容。
按如下方式编辑预设:
<
MediaFile ...
ThumbnailTime =&#34; 00:00:00&#34;
ThumbnailMode =&#34; BestFrame&#34;
ThumbnailJpegCompression =&#34; 95&#34;
ThumbnailCodec =&#34; Jpeg格式&#34;
ThumbnailSize =&#34; 100%,100%&#34;
ThumbnailEmbed =&#34;假&#34;&GT;
上述指示编码器在视频时间轴上选择适当的帧(ThumbnailMode =“BestFrame”),并以与输入视频相同的分辨率创建JPEG图像。您可以进一步调整上述设置 - 有关完整列表,请参阅http://msdn.microsoft.com/en-us/library/dn554337.aspx
使用以下代码段提交编码任务:
string inputPresetFile = @"C:\TEMP\EncodeWithImage.xml";
string presetName = Path.GetFileNameWithoutExtension(inputPresetFile);
IAsset asset = ???; // This is the input Asset for the Task
IJob job = _context.Jobs.Create("Encode Job for " + asset.Name + ", encoded using " + presetName);
Console.WriteLine("Encode Job for " + asset.Name + ", encoded using " + presetName);
// Get a media processor reference, and pass to it the name of the processor to use for the specific task.
IMediaProcessor processor = GetLatestMediaProcessorByName("Windows Azure Media Encoder");
Console.WriteLine("Got MP " + processor.Name + ", ID : " + processor.Id + ", version: " + processor.Version);
// Read the configuration data into a string.
string configuration = File.ReadAllText(inputPresetFile);
// Create a task with the encoding details, using a string preset.
ITask task = job.Tasks.AddNew("Encode Task for " + asset.Name + ", encoded using " + presetName, processor, configuration,
Microsoft.WindowsAzure.MediaServices.Client.TaskOptions.None);
// Specify the input asset to be encoded.
task.InputAssets.Add(asset);
// Add an output asset to contain the results of the job.
task.OutputAssets.AddNew("Output asset for encoding " + asset.Name + " using " + presetName, AssetCreationOptions.None);
// Launch the job.
job.Submit();
答案 2 :(得分:-1)
如果我理解正确你想链接两个任务输出第二个任务输出第一个任务。 如果是这样从github存储库复制/粘贴相应的测试 :https://github.com/WindowsAzure/azure-sdk-for-media-services/blob/dev/test/net/Scenario/JobTests.cs
[TestMethod]
[DeploymentItem(@"Media\Thumbnail.xml", "Media")]
[DeploymentItem(@"Media\SmallWmv.wmv", "Media")]
[Priority(0)]
[TestCategory("DailyBvtRun")]
public void ShouldSubmitAndFinishChainedTasks()
{
IAsset asset = AssetTests.CreateAsset(_mediaContext, _smallWmv, AssetCreationOptions.StorageEncrypted);
IJob job = _mediaContext.Jobs.Create("Test");
IMediaProcessor mediaProcessor = GetMediaProcessor(_mediaContext, WindowsAzureMediaServicesTestConfiguration.MpEncoderName);
ITask task = job.Tasks.AddNew("Task1", mediaProcessor, GetWamePreset(mediaProcessor), TaskOptions.None);
task.InputAssets.Add(asset);
IAsset asset2 = task.OutputAssets.AddNew("Another asset");
string xmlPreset = File.ReadAllText(WindowsAzureMediaServicesTestConfiguration.ThumbnailXml);
ITask task2 = job.Tasks.AddNew("Task2", mediaProcessor, xmlPreset, TaskOptions.None);
task2.InputAssets.Add(asset2);
task2.OutputAssets.AddNew("JobOutput", options: AssetCreationOptions.None);
job.Submit();
WaitForJob(job.Id, JobState.Finished, VerifyAllTasksFinished);
}