Exemplo n.º 1
0
        public static int GetVideoActualEndFrame(UserInformation userInfo, ProcessedVideoInformation videoInfo, string processID)
        {
            /*
             * How it works
             *
             * Count the number of images in the folder
             */

            return(Directory.GetFiles(videoInfo.target, "*.jpg").Length);
        }
Exemplo n.º 2
0
        public static Result WriteVideoActualEndFrame(UserInformation userInfo, ProcessedVideoInformation processedVideoInfo, string processID)
        {
            #region Preparation
            Result result           = new Result();
            string sourceFileName   = Path.GetFileNameWithoutExtension(processedVideoInfo.source.Replace("\"", string.Empty));
            string targetFolderName = processedVideoInfo.target.Replace("\"", string.Empty);
            #endregion Preapration

            #region Path recreation
            //if (processedVideoInfo.target.EndsWith("\\"))
            //{
            //    targetFolderName += processedVideoInfo.target.Replace("\"", string.Empty) + sourceFileName;
            //}
            //else
            //{
            //    targetFolderName += processedVideoInfo.target.Replace("\"", string.Empty) + "\\" + sourceFileName;
            //}
            #endregion Path recreation

            int totalFile = Directory.GetFiles(targetFolderName, "*.jpg").Length;

            #region Updater
            string SQLCommand = "USE MediaPlayerDatabase;";
            SQLCommand += "UPDATE ProcessedVideoInfo SET VideoActualEndFrame=" + totalFile.ToString() + " WHERE ProcessID=" + processID + ";";
            if (Peralatan.UbahDataDatabase(SQLCommand, ConfigurationManager.AppSettings["DatabaseConnectionString"]))
            {
                result.result = FunctionStatus.Success;
            }
            else
            {
                result.result       = FunctionStatus.Fail;
                result.HasError     = true;
                result.ErrorMessage = Peralatan.PesanKesalahan;
            }
            #endregion Updater

            return(result);
        }
Exemplo n.º 3
0
        public static Result VideoStatusUpdater(UserInformation userInfo, ProcessedVideoInformation videoInfo, string processID, VideoProcessStatus status)
        {
            Result result           = new Result();
            string connectionString = ConfigurationManager.AppSettings["DatabaseConnectionString"];

            byte[] videoSourceInBytes = Encoding.UTF8.GetBytes(videoInfo.source);

            string SQLCommand = "USE MediaPlayerDatabase;";

            SQLCommand += "UPDATE ProcessedVideoInfo SET VideoStatus=" + ((int)status).ToString();
            SQLCommand += " WHERE UserID=" + userInfo.UserID + " AND ProcessID= " + processID + ";";

            if (Peralatan.UbahDataDatabase(SQLCommand, connectionString))
            {
                result.result = FunctionStatus.Success;
            }
            else
            {
                result.result       = FunctionStatus.Fail;
                result.ErrorMessage = Peralatan.PesanKesalahan;
            }
            return(result);
        }
Exemplo n.º 4
0
        public static LogInformation GenerateLog(ProcessedVideoInformation videoInfo, VideoInformation processedVideoInformation, ProcessingInformation processingInfo, UserInformation userInfo, Requester requester)
        {
            #region Preparation
            DatabaseConfiguration configuration            = LoadDatabaseConfiguration();
            LogInformation        logInformation           = new LogInformation();
            FFmpegConfiguration   applicationConfiguration = LoadApplicationConfiguration();
            #endregion Preparation

            #region FFmpeg's log
            if (applicationConfiguration.useCustomFFmpeg)
            {
                logInformation.FFmpegLocation = applicationConfiguration.FFmpegLocation;
            }
            else
            {
                logInformation.FFmpegLocation = string.Empty;
            }
            #endregion FFmpeg's log

            #region FFProbe's log
            if (applicationConfiguration.useCustomFFProbe)
            {
                logInformation.FFProbeLocation = applicationConfiguration.FFProbeLocation;
            }
            else
            {
                logInformation.FFProbeLocation = string.Empty;
            }
            #endregion FFProbe's log

            #region Request time
            logInformation.requestTime  = processingInfo.processingStartTime;
            logInformation.finishedTime = processingInfo.processingEndTime;
            #endregion Request time

            #region UserID
            string userID = string.Empty;
            if (Peralatan.PeriksaDataDatabase(userInfo.UserSessionID, "SessionID", configuration.databaseName, configuration.userTableName, configuration.databaseConnectionString))
            {
                userID = Peralatan.MintaDataDatabase(configuration.databaseName, "UserID", configuration.userTableName, "SessionID", userInfo.UserSessionID, configuration.databaseConnectionString);
            }
            logInformation.userID = userID;
            #endregion UserID

            #region Processed video location
            logInformation.processedVideoLocation = videoInfo.target;
            #endregion Processed video location

            #region Delete original file
            logInformation.isDeleteWhenCompleteRequested = videoInfo.deleteOriginal;
            #endregion Delete original file

            #region Processing duration
            logInformation.totalProcessingDuration = processingInfo.totalVideoDuration;
            logInformation.audioProcessingDuration = processingInfo.processedAudioDuration;
            logInformation.videoProcessingDuration = processingInfo.processedVideoDuration;
            #endregion Processing duration

            #region Video information
            logInformation.originalVideoWidth  = processedVideoInformation.videoHeight;
            logInformation.originalVideoHeight = processedVideoInformation.videoHeight;
            logInformation.videoDuration       = processedVideoInformation.videoDuration;
            logInformation.scaledVideoWidth    = videoInfo.width;
            logInformation.scaledVideoHeight   = videoInfo.height;

            #endregion Video information
            return(logInformation);
        }
Exemplo n.º 5
0
        static Result ExtractFrames(ProcessedVideoInformation informations)
        {
            #region Information preparation
            Result result = new Result();

            #region Video basic info
            VideoProcessor.VideoInfo videoInfo = new VideoProcessor.VideoInfo
            {
                SourceFile            = videoInformation.source,
                TargetFolder          = videoInformation.target,
                requestDeleteOriginal = videoInformation.deleteOriginal,
                height           = videoInformation.height,
                width            = videoInformation.width,
                withAudio        = videoInformation.withAudio,
                printInformation = true
            };
            #endregion Video basic info

            #region Video FPS overriding
            if (videoInformation.fpsOverride > 0)
            {
                videoInfo.overrideFrameRate = true;
                videoInfo.frameRate         = videoInformation.fpsOverride;
            }
            else
            {
                videoInfo.overrideFrameRate = false;
            }
            #endregion Video FPS overriding

            VideoProcessor.ApplicationSettings settings = new VideoProcessor.ApplicationSettings();
            if (ConfigurationManager.AppSettings["UseCustomApplication"] == "true")
            {
                settings.useCustomApplication = true;
                settings.FFmpegPath           = ConfigurationManager.AppSettings["FFmpegLocation"];
                settings.FFProbePath          = ConfigurationManager.AppSettings["FFProbeLocation"];
            }
            else
            {
                settings.useCustomApplication = false;
            }
            #endregion Information preparation

            try
            {
                if (applicationConfiguration.displayInformations)
                {
                    Console.WriteLine("Will now processing the video with this information");
                    Console.WriteLine("Source: " + videoInformation.source);
                    Console.WriteLine("Target: " + videoInformation.target);
                    Console.WriteLine("With audio: " + videoInformation.withAudio);
                    Console.WriteLine("Width: " + videoInformation.width);
                    Console.WriteLine("Height: " + videoInformation.height);
                    Console.WriteLine("FPS: " + videoInformation.fpsOverride);
                }
                VideoProcessor.VideoLog log = processor.ExtractVideo(videoInfo, settings);
                processingInformation.processedVideoDuration = log.resultVideoProcessDuration;
                processingInformation.processedAudioDuration = log.resultAudioProcessDuration;
                processingInformation.totalVideoDuration     = log.resultTotalProcessDuration;

                result.result   = FunctionStatus.Success;
                result.HasError = false;
                result.AdditionalInfomration = log;
            }
            catch (Exception err)
            {
                if (debug)
                {
                    Console.WriteLine("An error just occured.");
                    Console.WriteLine("The error is:");
                    Console.WriteLine(err.Message);
                    Console.WriteLine();
                    Console.WriteLine(err.StackTrace);
                    Console.ReadLine();
                }
                result.result         = FunctionStatus.Fail;
                result.HasError       = true;
                result.ErrorMessage   = err.Message;
                result.ErrorException = err;
            }
            return(result);
        }