Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        private void StartNewEncode(string[] filePathes)
        {
            int count       = 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
                {
                    var            mediaInfo    = new MediaInfoWrapper();
                    var            metadataInfo = new VideoMetadataInfo(mediaInfo);
                    VideoMediaInfo metadata     = metadataInfo.GetMetadata(filePath);
                    var            encoder      = new Encoder();

                    WriteFileInfo("N O T H I N G", metadata);

                    decodeSw.Restart();
                    encoder.EncodeVideo(metadata, filePath, _destinationPath);
                    allSw.Stop();
                    decodeSw.Stop();
                    WriteFinishProcess(decodeSw.Elapsed, allSw.Elapsed, 0);
                    count++;
                }
                catch (MediaFormatException ex)
                {
                    string errorMessage = String.Format("Error File:\t\t{0}.\nError Param:\t\t{1}", filePath, ex.Message);
                    Trace.WriteLine(String.Format("\n{0}", 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));
                }
            }

            WriteFinishInfo(0, count, errorVideos);
        }
Ejemplo n.º 3
0
        private void StartEncode(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.GetStringForEncoder();

                    WriteFileInfo(ffmpegString, metadata);

                    decodeSw.Start();
                    var result = ffmpeg.StartEncodeProcess();
                    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));
                }
            }
        }
Ejemplo n.º 4
0
        private void StartEncode(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.GetStringForEncoder();

                    WriteFileInfo(ffmpegString, metadata);

                    decodeSw.Start();
                    var result = ffmpeg.StartEncodeProcess();
                    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));
                }
            }
        }
Ejemplo n.º 5
0
        private void StartEncode(MetadataServiceConfigurator serviceConfigurator, string[] filePathes, string prefix = "")
        {
            int    count         = 0;
            int    excelStrCount = 2;
            double avgEncodeFps  = 0;
            var    errorVideos   = new List <string>();
            var    allSw         = new Stopwatch();
            var    decodeSw      = new Stopwatch();
            Excel  excel         = CreateExcel();

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

                try
                {
                    string         destinationFileName = GetDestinationFileName(filePath, prefix);
                    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.GetStringForEncoder();

                    WriteFileInfo(ffmpegString, metadata);

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

                    if (ffmpeg.EncodeFps > 0)
                    {
                        SetExcelLine(excel, metadata, filePath, excelStrCount, ffmpeg.EncodeFps);
                        excelStrCount++;
                    }

                    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));
                }
            }

            excel.SaveDocument(String.Format(@"{0}\{1}_{2}.xlsx", _destinationPath, serviceConfigurator.Container, DateTime.Now.ToString("u").Replace(":", "-")));
            excel.CloseDocument();

            avgEncodeFps = avgEncodeFps / count;
            WriteFinishInfo(avgEncodeFps, count, errorVideos);
        }
 public void Initialize()
 {
     _mockMediaInfo = new Mock <IMediaInfo>();
     _metadataInfo  = new VideoMetadataInfo(_mockMediaInfo.Object);
 }
Ejemplo n.º 7
0
 public void Initialize()
 {
     _mockMediaInfo=new Mock<IMediaInfo>();
     _metadataInfo=new VideoMetadataInfo(_mockMediaInfo.Object);
 }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 9
0
        private void StartEncode(MetadataServiceConfigurator serviceConfigurator, string[] filePathes, string prefix = "")
        {
            int count = 0;
            int excelStrCount = 2;
            double avgEncodeFps = 0;
            var errorVideos = new List<string>();
            var allSw = new Stopwatch();
            var decodeSw = new Stopwatch();
            Excel excel = CreateExcel();

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

                try
                {
                    string destinationFileName = GetDestinationFileName(filePath, prefix);
                    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.GetStringForEncoder();

                    WriteFileInfo(ffmpegString, metadata);

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

                    if (ffmpeg.EncodeFps > 0)
                    {
                        SetExcelLine(excel, metadata, filePath, excelStrCount, ffmpeg.EncodeFps);
                        excelStrCount++;
                    }

                    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));
                }
            }

            excel.SaveDocument(String.Format(@"{0}\{1}_{2}.xlsx", _destinationPath, serviceConfigurator.Container, DateTime.Now.ToString("u").Replace(":", "-")));
            excel.CloseDocument();

            avgEncodeFps = avgEncodeFps/count;
            WriteFinishInfo(avgEncodeFps, count, errorVideos);
        }
Ejemplo n.º 10
0
        private void StartNewEncode(string[] filePathes)
        {
            int count = 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
                {
                    var mediaInfo = new MediaInfoWrapper();
                    var metadataInfo = new VideoMetadataInfo(mediaInfo);
                    VideoMediaInfo metadata = metadataInfo.GetMetadata(filePath);
                    var encoder = new Encoder();

                    WriteFileInfo("N O T H I N G", metadata);

                    decodeSw.Restart();
                    encoder.EncodeVideo(metadata, filePath, _destinationPath);
                    allSw.Stop();
                    decodeSw.Stop();
                    WriteFinishProcess(decodeSw.Elapsed, allSw.Elapsed, 0);
                    count++;
                }
                catch (MediaFormatException ex)
                {
                    string errorMessage = String.Format("Error File:\t\t{0}.\nError Param:\t\t{1}", filePath, ex.Message);
                    Trace.WriteLine(String.Format("\n{0}", 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));
                }
            }

            WriteFinishInfo(0, count, errorVideos);
        }