Example #1
0
        private void StartScreenshot(MetadataServiceConfigurator serviceConfigurator, string[] filePathes)
        {
            int    count        = 0;
            double avgEncodeFps = 0;
            var    errorVideos  = new List <string>();
            var    allSw        = new Stopwatch();
            var    decodeSw     = new Stopwatch();

            foreach (string filePath in filePathes)
            {
                allSw.Restart();
                Trace.WriteLine(String.Format("\n-------------Start decode file: {0}-------------\n", filePath));

                try
                {
                    string         destinationFileName = GetDestinationFileName(filePath);
                    var            mediaInfo           = new MediaInfoWrapper();
                    var            metadataInfo        = new VideoMetadataInfo(mediaInfo);
                    VideoMediaInfo metadata            = metadataInfo.GetMetadata(filePath);
                    var            metadataService     = new MetadataService(serviceConfigurator, metadata);
                    var            stringBuilder       = new FfmpegService(metadataService, filePath, _destinationPath, destinationFileName);
                    var            ffmpeg       = new Ffmpeg(stringBuilder);
                    string         ffmpegString = stringBuilder.GetStringForScreenshot();

                    WriteFileInfo(ffmpegString, metadata);

                    decodeSw.Restart();
                    ffmpeg.StartScreenshotProcess();
                    allSw.Stop();
                    decodeSw.Stop();
                    WriteFinishProcess(decodeSw.Elapsed, allSw.Elapsed, ffmpeg.EncodeFps);

                    avgEncodeFps += ffmpeg.EncodeFps;
                    count++;
                }
                catch (MediaFormatException ex)
                {
                    string errorMessage = String.Format("Error File:\t\t{0}.\nError Param:\t\t{1}", filePath, ex.Message);
                    Trace.WriteLine(errorMessage);
                    errorVideos.Add(errorMessage);
                }
                catch (ExternalProcessException ex)
                {
                    string errorMessage = String.Format("Error File:\t\t{0}.\nFfmpeg return:\t\t{1}\n{2}", filePath, ex.Result, ex.Arguments);
                    Trace.WriteLine(errorMessage);
                    errorVideos.Add(errorMessage);
                }
                finally
                {
                    Trace.WriteLine(String.Format("\n-------------Finish decode file: {0}-------------\n", filePath));
                }
            }

            avgEncodeFps = avgEncodeFps / count;
            WriteFinishInfo(avgEncodeFps, count, errorVideos);
        }
Example #2
0
        private void StartScreenshot(MetadataServiceConfigurator serviceConfigurator, string[] filePathes)
        {
            var allSw    = new Stopwatch();
            var decodeSw = new Stopwatch();

            foreach (var filePath in filePathes)
            {
                allSw.Start();
                Trace.WriteLine(String.Format("\n-------------Start decode file: {0}-------------\n", filePath));

                try
                {
                    var destinationFilePath = GetDestinationFilePath(filePath);
                    var mediaInfo           = new MediaInfoWrapper();
                    var metadataInfo        = new VideoMetadataInfo(mediaInfo);
                    var metadata            = metadataInfo.GetMetadata(filePath);
                    var metadataService     = new MetadataService(serviceConfigurator, metadata);
                    var stringBuilder       = new FfmpegStringBuilder(metadataService, destinationFilePath);
                    var ffmpeg       = new Ffmpeg(stringBuilder);
                    var ffmpegString = stringBuilder.GetStringForScreenshot();

                    WriteFileInfo(ffmpegString, metadata);

                    decodeSw.Start();
                    var result = ffmpeg.StartScreenshotProcess();
                    allSw.Stop();
                    decodeSw.Stop();
                    WriteFinishProcess(decodeSw.Elapsed, allSw.Elapsed, result);
                }
                catch (MediaFormatException ex)
                {
                    Trace.WriteLine(String.Format("Error File: {0}. Error Param: {1}", ex.VideoUri, ex.InvalidParameter));
                }
                finally
                {
                    Trace.WriteLine(String.Format("\n-------------Finish decode file: {0}-------------\n", filePath));
                }
            }
        }
Example #3
0
        private void StartScreenshot(MetadataServiceConfigurator serviceConfigurator, string[] filePathes)
        {
            var allSw = new Stopwatch();
            var decodeSw = new Stopwatch();
            foreach (var filePath in filePathes)
            {
                allSw.Start();
                Trace.WriteLine(String.Format("\n-------------Start decode file: {0}-------------\n", filePath));

                try
                {
                    var destinationFilePath = GetDestinationFilePath(filePath);
                    var mediaInfo = new MediaInfoWrapper();
                    var metadataInfo = new VideoMetadataInfo(mediaInfo);
                    var metadata = metadataInfo.GetMetadata(filePath);
                    var metadataService = new MetadataService(serviceConfigurator, metadata);
                    var stringBuilder = new FfmpegStringBuilder(metadataService, destinationFilePath);
                    var ffmpeg = new Ffmpeg(stringBuilder);
                    var ffmpegString = stringBuilder.GetStringForScreenshot();

                    WriteFileInfo(ffmpegString, metadata);

                    decodeSw.Start();
                    var result = ffmpeg.StartScreenshotProcess();
                    allSw.Stop();
                    decodeSw.Stop();
                    WriteFinishProcess(decodeSw.Elapsed, allSw.Elapsed, result);
                }
                catch (MediaFormatException ex)
                {
                    Trace.WriteLine(String.Format("Error File: {0}. Error Param: {1}", ex.VideoUri, ex.InvalidParameter));
                }
                finally
                {
                    Trace.WriteLine(String.Format("\n-------------Finish decode file: {0}-------------\n", filePath));
                }
            }
        }
Example #4
0
        private void StartScreenshot(MetadataServiceConfigurator serviceConfigurator, string[] filePathes)
        {
            int count = 0;
            double avgEncodeFps = 0;
            var errorVideos = new List<string>();
            var allSw = new Stopwatch();
            var decodeSw = new Stopwatch();
            foreach (string filePath in filePathes)
            {
                allSw.Restart();
                Trace.WriteLine(String.Format("\n-------------Start decode file: {0}-------------\n", filePath));

                try
                {
                    string destinationFileName = GetDestinationFileName(filePath);
                    var mediaInfo = new MediaInfoWrapper();
                    var metadataInfo = new VideoMetadataInfo(mediaInfo);
                    VideoMediaInfo metadata = metadataInfo.GetMetadata(filePath);
                    var metadataService = new MetadataService(serviceConfigurator, metadata);
                    var stringBuilder = new FfmpegService(metadataService, filePath, _destinationPath, destinationFileName);
                    var ffmpeg = new Ffmpeg(stringBuilder);
                    string ffmpegString = stringBuilder.GetStringForScreenshot();

                    WriteFileInfo(ffmpegString, metadata);

                    decodeSw.Restart();
                    ffmpeg.StartScreenshotProcess();
                    allSw.Stop();
                    decodeSw.Stop();
                    WriteFinishProcess(decodeSw.Elapsed, allSw.Elapsed, ffmpeg.EncodeFps);

                    avgEncodeFps += ffmpeg.EncodeFps;
                    count++;
                }
                catch (MediaFormatException ex)
                {
                    string errorMessage = String.Format("Error File:\t\t{0}.\nError Param:\t\t{1}", filePath, ex.Message);
                    Trace.WriteLine(errorMessage);
                    errorVideos.Add(errorMessage);
                }
                catch (ExternalProcessException ex)
                {
                    string errorMessage = String.Format("Error File:\t\t{0}.\nFfmpeg return:\t\t{1}\n{2}", filePath, ex.Result, ex.Arguments);
                    Trace.WriteLine(errorMessage);
                    errorVideos.Add(errorMessage);
                }
                finally
                {
                    Trace.WriteLine(String.Format("\n-------------Finish decode file: {0}-------------\n", filePath));
                }
            }

            avgEncodeFps = avgEncodeFps/count;
            WriteFinishInfo(avgEncodeFps, count, errorVideos);
        }