/// <summary>
        /// Generates frames based on moderated json source.
        /// </summary>
        /// <param name="moderatedJsonstring">moderatedJsonstring</param>
        /// <param name="resultEventDetailsList">resultEventDetailsList</param>

        private void PopulateFrameEvents(string moderatedJsonstring, List <ProcessedFrameDetails> resultEventDetailsList, UploadAssetResult uploadResult)
        {
            var jsonModerateObject = JsonConvert.DeserializeObject <VideoModerationResult>(moderatedJsonstring);

            if (jsonModerateObject != null)
            {
                var timeScale  = Convert.ToInt32(jsonModerateObject.TimeScale);
                int frameCount = 0;
                foreach (var item in jsonModerateObject.Fragments)
                {
                    if (item.Events != null)
                    {
                        foreach (var frameEventDetailList in item.Events)
                        {
                            foreach (FrameEventDetails frameEventDetails in frameEventDetailList)
                            {
                                var eventDetailsObj = new ProcessedFrameDetails
                                {
                                    ReviewRecommended = frameEventDetails.ReviewRecommended,
                                    TimeStamp         = (frameEventDetails.TimeStamp * 1000 / timeScale),
                                    IsAdultContent    = double.Parse(frameEventDetails.AdultScore) > _amsConfig.AdultFrameThreshold ? true : false,
                                    AdultScore        = frameEventDetails.AdultScore,
                                    IsRacyContent     = double.Parse(frameEventDetails.RacyScore) > _amsConfig.RacyFrameThreshold ? true : false,
                                    RacyScore         = frameEventDetails.RacyScore,
                                    TimeScale         = timeScale,
                                };
                                frameCount++;
                                eventDetailsObj.FrameName = "_" + frameCount + ".jpg";
                                resultEventDetailsList.Add(eventDetailsObj);
                            }
                        }
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// Populates a Video frame object
        /// </summary>
        /// <param name="frameEvent">FrameEventBlobEntity</param>
        /// <returns>Video Frame Object</returns>
        private VideoFrame PopulateVideoFrame(ProcessedFrameDetails frameEvent, UploadAssetResult uploadResult)
        {
            VideoFrame frameobj = new VideoFrame()
            {
                FrameImage         = frameEvent.FrameName,
                Timestamp          = Convert.ToString(frameEvent.TimeStamp),
                ReviewerResultTags = new List <ReviewResultTag>(),
                Metadata           = new List <Metadata>()
                {
                    new Metadata()
                    {
                        Key = "Review Recommended", Value = frameEvent.ReviewRecommended.ToString()
                    },
                    new Metadata()
                    {
                        Key = "Adult Score", Value = frameEvent.AdultScore
                    },
                    new Metadata()
                    {
                        Key = "a", Value = frameEvent.IsAdultContent.ToString()
                    },
                    new Metadata()
                    {
                        Key = "Racy Score", Value = frameEvent.RacyScore
                    },
                    new Metadata()
                    {
                        Key = "r", Value = frameEvent.IsRacyContent.ToString()
                    },
                    new Metadata()
                    {
                        Key = "ExternalId", Value = frameEvent.FrameName
                    },
                    new Metadata()
                    {
                        Key = "at", Value = frameEvent.IsAdultTextContent.ToString()
                    },
                    new Metadata()
                    {
                        Key = "rt", Value = frameEvent.IsRacyTextContent.ToString()
                    },
                    new Metadata()
                    {
                        Key = "ot", Value = frameEvent.IsOffensiveTextContent.ToString()
                    }
                },
            };

            return(frameobj);
        }