Пример #1
0
        private static VideoInfoModel GetVideoInfo(string videoPath)
        {
            var model = new VideoInfoModel();

            using (var videoFrameReader = new VideoFrameReader(videoPath))
            {
                model.Properties.Add("Duration", videoFrameReader.Duration.ToString());
                model.Properties.Add("Width", videoFrameReader.Width.ToString());
                model.Properties.Add("Height", videoFrameReader.Height.ToString());
                model.Properties.Add("CodecName", videoFrameReader.CodecName);
                model.Properties.Add("CodecDescription", videoFrameReader.CodecDescription);
                model.Properties.Add("CodecTag", videoFrameReader.CodecTag);
                model.Properties.Add("BitRate", videoFrameReader.BitRate.ToString());
                model.Properties.Add("FrameRate", videoFrameReader.FrameRate.ToString(CultureInfo.InvariantCulture));

                foreach (var entry in videoFrameReader.Metadata)
                {
                    model.Metadata.Add(entry.Key, entry.Value);
                }

                if (model.Metadata.Count == 0)
                {
                    model.Metadata.Add("", "");
                }
            }

            return(model);
        }
Пример #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var videoPath         = exampleFileSelector.SelectedFile;
            var fileInfo          = new FileInfo(videoPath);
            var thumbnailCacheKey = new DiskCacheKey(new DiskCacheSourceKey(fileInfo.Name, fileInfo.Length, fileInfo.LastWriteTimeUtc), "jpg");

            ThumbnailUrl = ExamplesCoreConfiguration.GetDownloadUrl(
                ThumbnailCache.GetOrAdd(
                    thumbnailCacheKey,
                    thumbnailPath => GetAndSaveThumbnail(videoPath, thumbnailPath)
                    ).FilePath,
                thumbnailCacheKey.FullValue
                );

            VideoInfo = GetVideoInfo(videoPath);
        }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var videoPath         = exampleFileSelector.SelectedFile;
            var fileInfo          = new FileInfo(videoPath);
            var thumbnailCacheKey = new FileCacheKey(new FileCacheSourceKey(fileInfo.Name, fileInfo.Length, fileInfo.LastWriteTimeUtc), "jpg");
            var cacheItem         = ThumbnailCache.GetOrAdd(
                thumbnailCacheKey,
                thumbnailStream => GetAndSaveThumbnail(videoPath, thumbnailStream)
                );

            ThumbnailUrl = ExamplesConfiguration.GetDownloadUrl(
                Hosting.ResolvePhysicalPath(ThumbnailCachePath.Append(cacheItem.RelativeName)),
                thumbnailCacheKey.FullValue
                );

            VideoInfo = GetVideoInfo(videoPath);
        }