コード例 #1
0
        public async Task TestExtract()
        {
            const string url = "https://www.facebook.com/EretzNehederet.Keshet/videos/1254084181637623";

            var videoExtractor = new VideoExtractor(new VideoExtractorConfig
            {
                FormatRequest = "best"
            });
            var video = await videoExtractor.ExtractVideo(url);

            Assert.IsNotNull(video);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: AntonyCorbett/VidMetaData
        private static void ProcessVideoFiles(MainApp app, string folder, bool includeSubFolders, bool useParallelProcessing)
        {
            var extractor = new VideoExtractor();
            var result    = app.Execute(extractor, folder, includeSubFolders, useParallelProcessing);

            if (result.count > 0)
            {
                Console.WriteLine();
                Console.WriteLine($"{result.count} video files. Output = {result.outputPath}");
                Console.WriteLine();
            }
        }
        public MMetadataResponse CreateExtractor(int mediaType, string path)
        {
            var result = new MMetadataResponse();

            if (string.IsNullOrEmpty(path))
            {
                result.IsSuccess = false;
                result.Message   = "檔案路徑不得為空";
                return(result);
            }

            if (mediaType < 0)
            {
                result.IsSuccess = false;
                result.Message   = "MediaSourceType錯誤";
                return(result);
            }

            IMediaExtractor mediaExtractor = null;

            try
            {
                switch (mediaType)
                {
                case 0:
                    break;

                case 1:
                    mediaExtractor = new ImageExtractor(mediaType, path);
                    break;

                case 2:
                    mediaExtractor = new AudioExtractor(mediaType, path);
                    break;

                case 3:
                    mediaExtractor = new VideoExtractor(mediaType, path);
                    break;

                default:
                    return(null);
                }

                if (mediaExtractor == null || mediaExtractor.MediaInformation == null)
                {
                    result.IsSuccess = false;
                    result.Message   = "IMediaExtractor不得為空或解析失敗";
                    return(result);
                }

                var dicMediaInformation = Utility.ParseObj(mediaExtractor.MediaInformation);
                result.MediaExtractor      = mediaExtractor;
                result.DicMediaInformation = dicMediaInformation;
                result.IsSuccess           = true;
                result.Message             = "MediaMetadataExtractor套件解析成功";
            }
            catch (Exception ex)
            {
                result.IsSuccess = false;
                result.Message   = "MediaMetadataExtractor套件解析錯誤" + "\r\n" + ex.Message;
            }

            return(result);
        }