Ejemplo n.º 1
0
        static void GetFrames(bool multiThread = false, int numberOfThread = 2)
        {
            try
            {
                // Main process of extracting frames and audio
                //List<object> processedVideoInfo = processor.GetAndSaveFrames(input, output, startSecond, endSecond, withAudio, printInformation, writeLogs, logLocation, videoWidth, videoHeight);

                #region Information construction
                VideoProcessor.VideoInfo videoInfo = new VideoProcessor.VideoInfo
                {
                    SourceFile            = videoInformation.source,
                    TargetFolder          = videoInformation.target,
                    requestDeleteOriginal = videoInformation.deleteOriginal,
                    //height = videoHeight,
                    //width = videoWidth,
                    printInformation = true
                };
                if (videoInformation.fpsOverride != -1 || videoInformation.fpsOverride != 0)
                {
                    videoInfo.overrideFrameRate = true;
                    videoInfo.frameRate         = 24;
                }
                VideoProcessor.ApplicationSettings settings = new VideoProcessor.ApplicationSettings
                {
                    useCustomApplication = false,
                };
                #endregion Information preparation

                try
                {
                    VideoProcessor.VideoLog log = processor.ExtractVideo(videoInfo, settings);
                }
                catch (Exception err)
                {
                    throw;
                }

                //if ((int)processedVideoInfo[0] != -1)
                //{
                //    logs.totalProcessingDuration = (TimeSpan)processedVideoInfo[1];
                //    if ((bool)processedVideoInfo[2])
                //    {
                //        logs.audioProcessingDuration = (TimeSpan)processedVideoInfo[3];
                //    }
                //    logs.videoProcessingDuration = (TimeSpan)processedVideoInfo[4];
                //}
            }
            catch (Exception err)
            {
                throw;
            }
        }
Ejemplo n.º 2
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);
        }