最近では、ニュースメディアサービスが作成されたいくつかのプロブラムがあります。私たちは、「Azure Media Encoder」が償却され、現在は「Media Encoder Standard」を使用していることがわかりました。したがって、動画をもう一度アップロードすることはできますが、サムネイルを作成することはできません。あなたは私たちを助けることができますか?アセットからサムネイルを取得するにはどうすればよいですか?あなたはサムネイルの古い非推奨プリセットスキーマを使用しているよう資産からサムネイルを作成する - Azure Media Services
public void CreateThumbnails(string idAssetVideo, int iSegundo, string sPath)
{
if (string.IsNullOrEmpty(idAssetVideo)) throw new Excepcion("El idAssetVideo no puede ser nulo. Póngase en contacto con soporte.");
string sTime = Utilidades.GetDuracionLabelFromSegundos(iSegundo);
IAsset asset = _context.Assets.Where(a => a.Id == idAssetVideo).SingleOrDefault();
if (asset == null) throw new Excepcion("No existe ningún Asset con el Id indicado. Póngase en contacto con soporte.");
// Declare a new job.
IJob job = _context.Jobs.Create("My Thumbnail job");
// Get a media processor reference, and pass to it the name of the
// processor to use for the specific task.
IMediaProcessor processor = UtilsAzure.GetLatestMediaProcessorByName("Media Encoder Standard", _context);
//Configuración para generar el Thumbnail
string configThumbnails = @"<Thumbnail Size='50%,*' Type='Jpeg' Filename='{OriginalFilename}_{Size}_{ThumbnailTime}_{ThumbnailIndex}_{Date}_{Time}.{DefaultExtension}'>
<Time Value='0:0:0' Step='" + sTime + "'/></Thumbnail>";
//string configThumbnails = "<?xml version='1.0' encoding='UTF-8'?><Thumbnail Size='200,*' Type='Jpeg' JpegQuality='90' Filename='" + sTime + ".jpeg'><Time Value='" + sTime + "'/></Thumbnail>";
ITask task = job.Tasks.AddNew("My thumbnail task",
processor,
configThumbnails,
TaskOptions.ProtectedConfiguration);
// 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",
AssetCreationOptions.None);
// Use the following event handler to check job progress.
job.StateChanged += new
EventHandler<JobStateChangedEventArgs>(UtilsAzure.StateChanged);
// Launch the job.
job.Submit();
// Check job execution and wait for job to finish.
Task progressJobTask = job.GetExecutionProgressTask(CancellationToken.None);
progressJobTask.Wait();
// If job state is Error, the event handling
// method for job progress should log errors. Here we check
// for error state and exit if needed.
if (job.State == JobState.Error)
{
throw new Exception("Exiting method due to job error.");
}
List<IAssetFile> lAF = job.OutputMediaAssets[0].AssetFiles.ToList();
//Valido
if (lAF == null || !lAF.Any()) throw new Excepcion("El trabajo azure no devolvió resultados");
if (lAF.Where(x => x.Name.EndsWith(".jpg")).FirstOrDefault() == null) throw new Excepcion("El trabajo azure no contiene ningún archivo con extensión JPG");
if (!Directory.GetParent(sPath).Exists) throw new Excepcion("No existe la carpeta donde guardar el thumbnail de manera provisional");
lAF.Where(x => x.Name.EndsWith(".jpg")).FirstOrDefault().Download(sPath);
}
ありがとうございます!それは作品です!実際には、1つのイメージしか作成する必要はありません。したがって、私たちはXMLを単純化しました。 – user3809539