public static string GetMediaProcessorName(MediaProcessor mediaProcessor) { string processorName = Regex.Replace(mediaProcessor.ToString(), Constants.CapitalSpacingExpression, Constants.CapitalSpacingReplacement); processorName = processorName.Replace("_", " "); return(processorName); }
private static MediaProcessor[] GetMediaProcessors(IMediaProcessor[] processors, bool presetsView) { List <MediaProcessor> mediaProcessors = new List <MediaProcessor>(); string[] processorIds = GetProcessorIds(presetsView); foreach (string processorId in processorIds) { if (!processorId.StartsWith(Constant.Media.ProcessorId.Prefix, StringComparison.OrdinalIgnoreCase)) { MediaProcessor mediaProcessor = (MediaProcessor)Enum.Parse(typeof(MediaProcessor), processorId); mediaProcessors.Add(mediaProcessor); } else { foreach (IMediaProcessor processor in processors) { if (string.Equals(processorId, processor.Id, StringComparison.OrdinalIgnoreCase)) { MediaProcessor?mediaProcessor = GetMediaProcessor(processor.Id); if (mediaProcessor.HasValue) { mediaProcessors.Add(mediaProcessor.Value); } } } } } return(mediaProcessors.ToArray()); }
public frmHome() { InitializeComponent(); this.cbxOutputType.Items.AddRange(OutputStringTypes.GetImageTypes()); this.cbxVideoOutputType.Items.AddRange(OutputStringTypes.GetVideoTypes()); this.cbxResizeType.SelectedIndex = 0; this.cbxOutputType.SelectedIndex = 0; this.txtResize.Text = this.comboTxtDefaults[this.cbxResizeType.SelectedIndex].ToString(); this.cbxVideoOutputType.SelectedIndex = 0; this.cbxVideoResizeType.SelectedIndex = 0; this.lblDragFiles.DragEnter += new DragEventHandler(lblDragFiles_DragEnter); this.lblDragFiles.DragDrop += new DragEventHandler(lblDragFiles_DragDrop); this.lblDragTrimVideo.DragEnter += new DragEventHandler(lblDragTrimVideo_DragEnter); this.lblDragTrimVideo.DragDrop += new DragEventHandler(lblDragTrimVideo_DragDrop); string[] imageExt = MediaProcessor.GetAllAllowedImageExtensions(); string[] videoExt = MediaProcessor.GetAllAllowedVideoExtensions(); string allTooltip = ""; string videoTooltip = ""; for (int ii = 0; ii < imageExt.Length; ii++) { allTooltip += (imageExt[ii] + " "); } allTooltip += "\r\n"; for (int ii = 0; ii < videoExt.Length; ii++) { allTooltip += (videoExt[ii] + " "); videoTooltip += (videoExt[ii] + " "); } this.toolTip1.SetToolTip(this.lblDragFiles, allTooltip); this.toolTip1.SetToolTip(this.lblDragTrimVideo, videoTooltip); }
internal static SelectListItem[] GetProcessorPresets(MediaProcessor mediaProcessor, string accountId, bool includeLadder) { List <SelectListItem> processorPresets = new List <SelectListItem>(); NameValueCollection presets = Processor.GetProcessorPresets(mediaProcessor, accountId); if (includeLadder) { SelectListItem processorPreset = new SelectListItem() { Text = Constant.Media.ProcessorConfig.StreamingLadderPresetName, Value = Constant.Media.ProcessorConfig.StreamingLadderPresetValue, Selected = true }; processorPresets.Add(processorPreset); processorPreset = new SelectListItem() { Text = Constant.Media.ProcessorConfig.DownloadLadderPresetName, Value = Constant.Media.ProcessorConfig.DownloadLadderPresetValue }; processorPresets.Add(processorPreset); } foreach (string presetName in presets.Keys) { SelectListItem processorPreset = new SelectListItem() { Text = presetName, Value = presets[presetName] }; processorPresets.Add(processorPreset); } processorPresets.Sort(OrderByName); return(processorPresets.ToArray()); }
private static int OrderByProcessor(MediaInsight leftItem, MediaInsight rightItem) { MediaProcessor leftProcessor = Processor.GetMediaProcessor(leftItem.ProcessorId).Value; MediaProcessor rightProcessor = Processor.GetMediaProcessor(rightItem.ProcessorId).Value; return(leftProcessor.CompareTo(rightProcessor)); }
public JsonResult configs(MediaProcessor mediaProcessor) { string authToken = homeController.GetAuthToken(this.Request, this.Response); User authUser = new User(authToken); SelectListItem[] presets = GetProcessorPresets(mediaProcessor, authUser.MediaAccount.Id, false); return(Json(presets)); }
public static string GetProcessorId(MediaProcessor mediaProcessor, string processorConfig) { string processorId = null; switch (mediaProcessor) { case MediaProcessor.EncoderStandard: processorId = Constant.Media.ProcessorId.EncoderStandard; break; case MediaProcessor.EncoderPremium: processorId = Constant.Media.ProcessorId.EncoderPremium; break; case MediaProcessor.VideoIndexer: processorId = Constant.Media.ProcessorId.VideoIndexer; break; case MediaProcessor.VideoAnnotation: processorId = Constant.Media.ProcessorId.VideoAnnotation; break; case MediaProcessor.VideoSummarization: processorId = Constant.Media.ProcessorId.VideoSummarization; break; case MediaProcessor.FaceDetection: processorId = Constant.Media.ProcessorId.FaceRedaction; if (!string.IsNullOrEmpty(processorConfig)) { JToken processorOptions = JObject.Parse(processorConfig)["Options"]; string processorMode = processorOptions["Mode"].ToString(); if (processorMode == "PerFaceEmotion" || processorMode == "AggregateEmotion") { processorId = Constant.Media.ProcessorId.FaceDetection; } } break; case MediaProcessor.SpeechAnalyzer: processorId = Constant.Media.ProcessorId.SpeechAnalyzer; break; case MediaProcessor.MotionDetection: processorId = Constant.Media.ProcessorId.MotionDetection; break; case MediaProcessor.ContentModeration: processorId = Constant.Media.ProcessorId.ContentModeration; break; case MediaProcessor.CharacterRecognition: processorId = Constant.Media.ProcessorId.CharacterRecognition; break; } return(processorId); }
private static void PublishAnalytics(IJob job, IAsset asset, JobPublish jobPublish) { string processorId1 = Constants.Media.ProcessorId.FaceDetection; string processorId2 = Constants.Media.ProcessorId.FaceRedaction; string processorId3 = Constants.Media.ProcessorId.MotionDetection; string processorId4 = Constants.Media.ProcessorId.VideoAnnotation; string processorId5 = Constants.Media.ProcessorId.CharacterRecognition; string processorId6 = Constants.Media.ProcessorId.ContentModeration; string[] processorIds = new string[] { processorId1, processorId2, processorId3, processorId4, processorId5, processorId6 }; ITask[] jobTasks = GetJobTasks(job, processorIds); if (jobTasks.Length > 0) { BlobClient blobClient = GetBlobClient(jobPublish); using (DatabaseClient databaseClient = new DatabaseClient(true)) { string collectionId = Constants.Database.DocumentCollection.Metadata; foreach (ITask jobTask in jobTasks) { IAsset outputAsset = jobTask.OutputAssets[0]; string fileExtension = Constants.Media.FileExtension.Json; string[] fileNames = GetFileNames(outputAsset, fileExtension); if (fileNames.Length > 0 && asset != null) { string sourceContainerName = outputAsset.Uri.Segments[1]; string sourceFileName = fileNames[0]; CloudBlockBlob sourceBlob = blobClient.GetBlob(sourceContainerName, string.Empty, sourceFileName, false); string jsonData = string.Empty; using (Stream sourceStream = sourceBlob.OpenRead()) { StreamReader streamReader = new StreamReader(sourceStream); jsonData = streamReader.ReadToEnd(); } if (!string.IsNullOrEmpty(jsonData)) { string documentId = databaseClient.CreateDocument(collectionId, jsonData); MediaProcessor mediaProcessor = Processors.GetMediaProcessorType(jobTask.MediaProcessorId); string processorName = Processors.GetMediaProcessorName(mediaProcessor); processorName = processorName.Replace(' ', Constants.NamedItemSeparator); string destinationFileName = string.Concat(documentId, Constants.NamedItemsSeparator, processorName, fileExtension); blobClient.CopyFile(outputAsset, asset, sourceFileName, destinationFileName, false); } } if (jobTask.Configuration.Contains("mode") && jobTask.Configuration.Contains("analyze")) { IAsset inputAsset = jobTask.InputAssets[0]; string primaryFileName = GetPrimaryFile(inputAsset); blobClient.CopyFile(inputAsset, outputAsset, primaryFileName, primaryFileName, true); } } } } }
private void initProcessor(Form parent) { _voiceOutput = new VoiceMediaOutput(); _voiceOutput.Init(this, _conf); FaceMediaOutput face = new FaceMediaOutput(); face.Init(this, _conf); face.FaceEvent += new FaceEventHandler(OnFaceEvent); List <MediaOutput> outs = new List <MediaOutput>(); outs.Add(_voiceOutput); outs.Add(face); _processor = new MediaProcessor(_profile, outs, _conf); _processor.Processed += new Action(_processor_Processed); }
public MediaProcessor[] Initialize(string authToken) { MediaClient mediaClient = new MediaClient(authToken); IMediaProcessor[] mediaProcessors = mediaClient.GetEntities(MediaEntity.Processor) as IMediaProcessor[]; List <MediaProcessor> mediaProcessorList = new List <MediaProcessor>(); foreach (IMediaProcessor mediaProcessor in mediaProcessors) { MediaProcessor processorType = Processors.GetMediaProcessorType(mediaProcessor.Id); mediaProcessorList.Add(processorType); } MediaProcessor[] mediaProcessorTypes = mediaProcessorList.ToArray(); SetValue <MediaProcessor[]>(Constants.Cache.ItemKey.MediaProcessors, mediaProcessorTypes); return(mediaProcessorTypes); }
public CommandHandler(CommandService commands, DiscordSocketClient client, IMessageTriggerService msgTrgSrvs, MediaProcessor mediaProcessor, MessageTriggers messageTriggers, ModLogic modLogic, PunishLogic punishLogic, NotifyLogic notifyLogic, EventLogic eventLogic, CustomCommandLogic customCommandLogic, IActivityLogService activityLogService) { _commands = commands; _client = client; _msgTrgSrvs = msgTrgSrvs; _modLogic = modLogic; _punishLogic = punishLogic; _notifyLogic = notifyLogic; _eventLogic = eventLogic; _customCommandLogic = customCommandLogic; _mediaProcessor = mediaProcessor; _messageTriggers = messageTriggers; _tokenSource = new CancellationTokenSource(); _activityLogService = activityLogService; }
public JsonResult metadata(MediaProcessor mediaProcessor, string documentId, double timeSeconds) { JObject metadata; string collectionId = Constant.Database.Collection.ContentInsight; string procedureId = Constant.Database.Procedure.MetadataFragment; using (DocumentClient documentClient = new DocumentClient()) { if (mediaProcessor == MediaProcessor.VideoIndexer) { metadata = documentClient.GetDocument(collectionId, documentId); } else { metadata = documentClient.GetDocument(collectionId, procedureId, documentId, timeSeconds); } } return(Json(metadata)); }
public static NameValueCollection GetProcessorPresets(MediaProcessor mediaProcessor, string accountId) { NameValueCollection processorPresets = new NameValueCollection(); DocumentClient documentClient = new DocumentClient(); string collectionId = Constant.Database.Collection.ProcessorConfig; string accountPresetId = string.Concat(accountId, Constant.TextDelimiter.Identifier, mediaProcessor.ToString()); JObject[] presets = documentClient.GetDocuments(collectionId); foreach (JObject preset in presets) { string presetId = preset["id"].ToString(); string presetProcessor = preset["MediaProcessor"].ToString(); string[] presetIdInfo = presetId.Split(Constant.TextDelimiter.Identifier); bool customPreset = presetIdInfo.Length == 3 ? true : false; if ((!customPreset && presetProcessor.StartsWith(mediaProcessor.ToString(), StringComparison.OrdinalIgnoreCase)) || (customPreset && presetId.StartsWith(accountPresetId, StringComparison.Ordinal))) { string presetName = preset["PresetName"].ToString(); processorPresets.Add(presetName, presetId); } } return(processorPresets); }
private void DisplayImage() { this.currentImage?.Dispose(); string filename = this.filenames[this.currentIndex]; this.currentImage = Image.FromFile(filename); this.pictureMain.SizeMode = PictureBoxSizeMode.Zoom; this.pictureMain.Image = this.currentImage; this.Text = frmImageCrop.formTitle + "(" + (this.currentIndex + 1).ToString() + " of " + this.filenames.Count.ToString() + ")"; Rectangle cropBoundary = MediaProcessor.GetCropBoundaryForImage(filename, this.currentImage, this.cropBoundaries, this.defaultCropRatio); if (!this.cropBoundaries.ContainsKey(filename)) { this.cropBoundaries.Add(filename, cropBoundary); } else { this.cropBoundaries[filename] = cropBoundary; } this.currentRectangle = cropBoundary; }
public void Run(Item processor, Item itemToProcess, Item fieldMapping) { ImportConfig config = new ImportConfig(fieldMapping.Parent.Parent, fieldMapping.Database, ""); Uri baseUri = new Uri(config.BaseUrl); BaseMapping baseMap = new BaseMapping(fieldMapping); MediaProcessor mediaProcessor = new MediaProcessor(processor); HtmlDocument document = new HtmlDocument(); string content = itemToProcess.Fields[baseMap.NewItemField].Value; document.LoadHtml(content); using (new SecurityModel.SecurityDisabler()) { foreach (var mediaType in mediaProcessor.MediaTypes) { var nodes = document.DocumentNode.SelectNodes(string.Format("//{0}/@{1}", mediaType.Identifier, mediaType.Attribute)); if (nodes == null) { continue; } //select nodes in html where path ends with extension listed in config List <HtmlNode> targetedNodes = nodes.Where(n => n.Attributes[mediaType.Attribute].Value.Trim().ToLower() .EndsWith(mediaType.Extension.Trim().ToLower())).ToList(); if (targetedNodes == null) { targetedNodes = nodes.Where(n => n.Attributes[mediaType.Attribute].Value.Trim().ToLower() .Contains(mediaType.Extension.Trim().ToLower())).ToList(); } else { targetedNodes.AddRange(nodes.Where(n => n.Attributes[mediaType.Attribute].Value.Trim().ToLower() .Contains(mediaType.Extension.Trim().ToLower())).ToList()); } foreach (var child in targetedNodes) { try { //Make sure the selected tags have media items to import, with existing parameters to follow string source = child.Attributes[mediaType.Attribute].Value; string mediaExtension = Path.GetExtension(source); if (string.IsNullOrEmpty(source)) { continue; } Uri mediaSource = new Uri(source, UriKind.RelativeOrAbsolute); if (mediaSource.IsAbsoluteUri) { if ((mediaSource.Host != baseUri.Host)) { continue; } } else { //This is for internal/relative path images mediaSource = new Uri(baseUri, source); } string destination = mediaProcessor.RetrieveDestination(processor, mediaProcessor.RootDestination, source, mediaSource, baseUri); Item importedMediaItem = MediaUpload.UploadMedia(mediaSource.ToString(), destination, itemToProcess); if (importedMediaItem != null) { var mediaUrl = "-/media/" + importedMediaItem.ID.ToShortID().ToString() + ".ashx"; //Swap the old link with the new link to our media library HtmlNode newChild = child.Clone(); newChild.Attributes[mediaType.Attribute].Value = mediaUrl; content = content.Replace(child.OuterHtml, newChild.OuterHtml); itemToProcess.Editing.BeginEdit(); itemToProcess.Fields[baseMap.NewItemField].Value = content; itemToProcess.Editing.EndEdit(); ImportReporter.Write(itemToProcess, Level.Info, string.Format("Link updated for: {0}", importedMediaItem.Name), baseMap.NewItemField, "Media Importer"); } } catch (Exception ex) { ImportReporter.Write(itemToProcess, Level.Error, string.Format("There was an error importing media from {0}. Error: {1}.", string.Concat(baseUri, child.Attributes[mediaType.Attribute].Value), ex.Message), baseMap.NewItemField, "Media Import"); //Error importing media and/or updating links to media } } } } }
public static MediaProcessor GetMediaProcessorType(string processorId) { MediaProcessor mediaProcessor = MediaProcessor.None; switch (processorId) { case Constants.Media.ProcessorId.EncoderStandard: mediaProcessor = MediaProcessor.EncoderStandard; break; case Constants.Media.ProcessorId.EncoderPremium: mediaProcessor = MediaProcessor.EncoderPremium; break; case Constants.Media.ProcessorId.EncoderUltra: mediaProcessor = MediaProcessor.EncoderUltra; break; case Constants.Media.ProcessorId.IndexerV1: mediaProcessor = MediaProcessor.Indexer_v1; break; case Constants.Media.ProcessorId.IndexerV2: mediaProcessor = MediaProcessor.Indexer_v2; break; case Constants.Media.ProcessorId.FaceDetection: mediaProcessor = MediaProcessor.FaceDetection; break; case Constants.Media.ProcessorId.FaceRedaction: mediaProcessor = MediaProcessor.FaceRedaction; break; case Constants.Media.ProcessorId.MotionDetection: mediaProcessor = MediaProcessor.MotionDetection; break; case Constants.Media.ProcessorId.MotionHyperlapse: mediaProcessor = MediaProcessor.MotionHyperlapse; break; case Constants.Media.ProcessorId.MotionStabilization: mediaProcessor = MediaProcessor.MotionStabilization; break; case Constants.Media.ProcessorId.VideoAnnotation: mediaProcessor = MediaProcessor.VideoAnnotation; break; case Constants.Media.ProcessorId.VideoSummarization: mediaProcessor = MediaProcessor.VideoSummarization; break; case Constants.Media.ProcessorId.CharacterRecognition: mediaProcessor = MediaProcessor.CharacterRecognition; break; case Constants.Media.ProcessorId.ContentModeration: mediaProcessor = MediaProcessor.ContentModeration; break; } return(mediaProcessor); }
private static string UpsertDocument(DocumentClient documentClient, JObject document, MediaProcessor processor, IAsset asset, string fileName) { string documentId = string.Empty; if (ValidDocument(asset, fileName)) { string collectionId = Constant.Database.Collection.ContentInsight; documentId = documentClient.UpsertDocument(collectionId, document); asset.AlternateId = string.Concat(processor.ToString(), Constant.TextDelimiter.Identifier, documentId); asset.Update(); } return(documentId); }
public static string GetMediaProcessorId(MediaProcessor mediaProcessor) { string processorId = null; switch (mediaProcessor) { case MediaProcessor.EncoderStandard: processorId = Constants.Media.ProcessorId.EncoderStandard; break; case MediaProcessor.EncoderPremium: processorId = Constants.Media.ProcessorId.EncoderPremium; break; case MediaProcessor.EncoderUltra: processorId = Constants.Media.ProcessorId.EncoderUltra; break; case MediaProcessor.Indexer_v1: processorId = Constants.Media.ProcessorId.IndexerV1; break; case MediaProcessor.Indexer_v2: processorId = Constants.Media.ProcessorId.IndexerV2; break; case MediaProcessor.FaceDetection: processorId = Constants.Media.ProcessorId.FaceDetection; break; case MediaProcessor.FaceRedaction: processorId = Constants.Media.ProcessorId.FaceRedaction; break; case MediaProcessor.MotionDetection: processorId = Constants.Media.ProcessorId.MotionDetection; break; case MediaProcessor.MotionHyperlapse: processorId = Constants.Media.ProcessorId.MotionHyperlapse; break; case MediaProcessor.MotionStabilization: processorId = Constants.Media.ProcessorId.MotionStabilization; break; case MediaProcessor.VideoAnnotation: processorId = Constants.Media.ProcessorId.VideoAnnotation; break; case MediaProcessor.VideoSummarization: processorId = Constants.Media.ProcessorId.VideoSummarization; break; case MediaProcessor.CharacterRecognition: processorId = Constants.Media.ProcessorId.CharacterRecognition; break; case MediaProcessor.ContentModeration: processorId = Constants.Media.ProcessorId.ContentModeration; break; } return(processorId); }
public static string GetProcessorName(MediaProcessor mediaProcessor) { return(Processor.GetProcessorName(mediaProcessor)); }
public static string GetProcessorName(MediaProcessor mediaProcessor) { string processorName = mediaProcessor.ToString(); return(Regex.Replace(processorName, Constant.TextFormatter.SpacePattern, Constant.TextFormatter.SpaceReplacement)); }
override public void Init(Profile profile, Form parent) { base.Init(profile, parent); InitializeComponent(); initColors(); _conf = new Configer(); //_processor = new MediaProcessor(_parent, _profile); //_processor.Processed += new Action(SetPlayIcon); _processors = new List <MediaProcessor>(); _musicLines = new List <MusicLine>(); for (int i = 0; i < Rows; i++) { BoomDataGrid.Rows.Add(); // init media processors VoiceMediaOutput voice = new VoiceMediaOutput(); voice.Init(this, new Configer()); List <MediaOutput> outs = new List <MediaOutput>(); outs.Add(voice); List <string> types = Profile.DefaultSpecfifcTypes.ToList(); types.AddRange(this.GetSpecificSoundTypes()); MediaProcessor proc = new MediaProcessor(profile, types.ToArray(), outs, _conf); TextBox tb = new TextBox(); tb.BorderStyle = BorderStyle.FixedSingle; tb.Parent = this; tb.Top = (i + 1) * 22 + 6; tb.Width = MusicComboBox.Width; tb.Left = MusicComboBox.Left; tb.Click += new EventHandler(tb_Click); tb.TextChanged += new EventHandler(tb_TextChanged); tb.DoubleClick += new EventHandler(tb_DoubleClick); tb.Tag = i; MusicLine ml = new MusicLine(tb, proc); _musicLines.Add(ml); _processors.Add(proc); } Label l = new Label(); l.Text = "Звуки Звуки Звуки Звуки Звуки"; l.Parent = this; l.Top = (Rows + 1) * 22 + 6; l.Left = MusicComboBox.Left + 10; l.Width = MusicComboBox.Width; l.BorderStyle = BorderStyle.None; l.BackColor = Color.FromArgb(255, 255, 192); BoomDataGrid.Height = Rows * 25 + 10; this.Height = Rows * 25 + 12; for (int i = 0; i < Columns; i++) { int n = BoomDataGrid.Columns.Count; DataGridViewTextBoxColumn C1 = new DataGridViewTextBoxColumn(); C1.Name = n.ToString(); //C1.State == n.ToString(); //C1.FlatStyle = FlatStyle.System; C1.ReadOnly = true; C1.CellTemplate.Style.BackColor = Color.White; C1.Width = 25; BoomDataGrid.Columns.Add(C1);//"Frame" + n.ToString(), n.ToString()); // BoomDataGrid.Columns[n].Width = 25; for (int j = 0; j < Rows; j++) { BoomDataGrid[i, j].Tag = 0; BoomDataGrid[i, j].Style.SelectionBackColor = Color.White; //(DataGridViewButton)BoomDataGrid[i, j].Clik } } //MusicComboBox.Items.AddRange(_profile.GetSpecificSoundsByType("музыка")); }
public MusicLine(TextBox t, MediaProcessor p) { text = t; processor = p; }
static void Main(string[] args) { MediaProcessor mediaProcessor = new MediaProcessor(); mediaProcessor.Process(args); }