Example #1
0
        public static VideoTime FromJsonFile(string jsonPath)
        {
            string    json = File.ReadAllText(jsonPath);
            VideoTime obj  = JsonConvert.DeserializeObject <VideoTime>(json);

            return(obj);
        }
Example #2
0
        public bool LoadVideoJson()
        {
            try
            {
                string localJson = Storage.DownloadVideo(_videoJsonUrl);

                Logger.Log($"Found override json: {_videoJsonUrl}");
                VideoTime obj = FromJsonFile(localJson);
                this.Start    = obj.Start;
                this.Duration = obj.Duration;
            }
            catch (System.Net.WebException)
            {
                Logger.Log("No json override found for " + _videoJsonUrl);
                return(false);
            }

            return(true);
        }
Example #3
0
        /// <summary>
        /// Downloads video, extracts metadata, trims video to just the course pass, removes audio,
        /// generates thumbnail, uploads metadata, thumbnail, final video, deletes ingest video.
        /// </summary>
        /// <returns>Url of processed video.</returns>
        public async Task ProcessAsync()
        {
            try
            {
                var download     = DownloadVideoAsync();
                var timeOverride = GetPassOverrideAsync();

                await Task.WhenAll(download, timeOverride);

                _localVideoPath = download.Result;
                _timeOverrides  = timeOverride.Result;

                _videoTasks = new VideoTasks(_localVideoPath);

                var        getCreationTime = GetCreationTimeAsync();
                CoursePass pass            = await CreateCoursePassAsync();

                do
                {
                    var createThumbnail = CreateThumbnailAsync(pass);
                    var uploadThumbnail = UploadThumbnailAsync(createThumbnail, getCreationTime);
                    var trimAndSilence  = TrimAndSilenceAsync(pass);
                    var uploadVideo     = UploadVideoAsync(trimAndSilence, getCreationTime);
                    var uploadHotVideo  = UploadGoogleVideoAsync(trimAndSilence, getCreationTime);

                    await FitCenterLineAsync(pass);
                    await CreateAndUploadMetadataAsync(
                        pass,
                        uploadThumbnail,
                        uploadVideo,
                        uploadHotVideo
                        );
                } while ((pass = HasAnotherPass(in pass)) != null);

                DeleteIngestVideo();
            }
            catch (System.AggregateException aggEx)
            {
                throw new ApplicationException($"Unable to process {_sourceVideoUrl}.  Failed at: \n" +
                                               aggEx.GetBaseException().Message);
            }
        }
Example #4
0
        /// <summary>
        /// Download and process JSON CoursePass override if it exists.
        /// </summary>
        private async Task <VideoTime> GetPassOverrideAsync()
        {
            VideoTime overrides = null;

            try
            {
                await Task.Run(() => {
                    string jsonOverrideUrl = VideoTime.GetVideoJsonUrl(_sourceVideoUrl);
                    string jsonPath        = Cloud.Storage.DownloadVideo(jsonOverrideUrl);
                    if (jsonPath != null)
                    {
                        overrides = VideoTime.FromJsonFile(jsonPath);
                        Logger.Log($"Video overrides found start, duration: {overrides.Start}, {overrides.Duration}");
                    }
                });
            }
            catch (System.Net.WebException)
            {
                Logger.Log("No json override found for " + _sourceVideoUrl);
            }

            return(overrides);
        }