protected async override Task <ProcessResult> OnPolling(PollerJobParameters parameters, string workingFolder) { String format = parameters.All.GetOrDefault(JobKeys.ThumbnailFormat) ?? "png"; Int32 secondsOffset = Int32.Parse(parameters.All.GetOrDefault("thumb_seconds_offset") ?? "10"); Logger.DebugFormat("Conversion for jobId {0} in format {1} starting", parameters.JobId, format); String vlcExecutable = Helper.GetExecutableLocation(); if (!File.Exists(vlcExecutable)) { String error = String.Format("Unable to find VLC.exe executable in standard folders. You can specify VLC directory with 'vlc_location' job parameter or with 'vlc_location' app config configuration"); Logger.ErrorFormat(error); Console.WriteLine("Unable to start converter, press a key to close."); Console.ReadKey(); throw new ApplicationException(error); } var worker = new VlcCommandLineThumbnailCreator(vlcExecutable, format, Logger); String networkStream = base.GetBlobUriForJobBlob(parameters.TenantId, parameters.JobId); String thumbNail = worker.CreateThumbnail(networkStream, workingFolder, secondsOffset); if (String.IsNullOrEmpty(thumbNail)) { Logger.WarnFormat("Conversion returned no thumbnail for file {0} - job {1}", parameters.FileName, parameters.JobId); } else { await AddFormatToDocumentFromFile( parameters.TenantId, parameters.JobId, new DocumentFormat(DocumentFormats.RasterImage), thumbNail, new Dictionary <string, object>()); Logger.DebugFormat("Conversion of {0} in format {1} done", parameters.JobId, format); } return(ProcessResult.Ok); }
protected async override Task<ProcessResult> OnPolling(PollerJobParameters parameters, string workingFolder) { String format = parameters.All.GetOrDefault(JobKeys.ThumbnailFormat) ?? "png"; Int32 secondsOffset = Int32.Parse(parameters.All.GetOrDefault("thumb_seconds_offset") ?? "10"); Logger.DebugFormat("Conversion for jobId {0} in format {1} starting", parameters.JobId, format); String vlcExecutable = Helper.GetExecutableLocation(); if (!File.Exists(vlcExecutable)) { String error = String.Format("Unable to find VLC.exe executable in standard folders. You can specify VLC directory with 'vlc_location' job parameter or with 'vlc_location' app config configuration"); Logger.ErrorFormat(error); Console.WriteLine("Unable to start converter, press a key to close."); Console.ReadKey(); throw new ApplicationException(error); } var worker = new VlcCommandLineThumbnailCreator(vlcExecutable, format, Logger); String networkStream = base.GetBlobUriForJob(parameters.TenantId, parameters.JobId); String thumbNail = worker.CreateThumbnail(networkStream, workingFolder, secondsOffset); if (String.IsNullOrEmpty(thumbNail)) { Logger.WarnFormat("Conversion returned no thumbnail for file {0} - job {1}", parameters.FileName, parameters.JobId); } else { await AddFormatToDocumentFromFile( parameters.TenantId, parameters.JobId, new DocumentFormat(DocumentFormats.RasterImage), thumbNail, new Dictionary<string, object>()); Logger.DebugFormat("Conversion of {0} in format {1} done", parameters.JobId, format); } return ProcessResult.Ok; }
public List<PollerTestResult> Execute() { List<PollerTestResult> retValue = new List<PollerTestResult>(); String format ="png"; Int32 secondsOffset = 4; String vlcExecutable = Helper.GetExecutableLocation(); if (vlcExecutable == null) { retValue.Add(new PollerTestResult(false, "Executable location, use app settings vlc_location")); return retValue; } else { retValue.Add(new PollerTestResult(true, "Executable location, ")); } try { var worker = new VlcCommandLineThumbnailCreator(vlcExecutable, format, NullLogger.Instance); var tempFile = Path.Combine(Path.GetTempPath(), "video.mp4"); if (File.Exists(tempFile)) File.Delete(tempFile); File.WriteAllBytes(tempFile, TestFiles.video); var thumb = worker.CreateThumbnail(tempFile, Path.GetTempPath(), 4); retValue.Add(new PollerTestResult( !String.IsNullOrEmpty(tempFile), "video thumb extraction: ")); } catch (Exception ex) { retValue.Add(new PollerTestResult(false, "video thumb extraction: " + ex.Message)); } return retValue; }