コード例 #1
0
        public override VideoSummary ExtractSummary(string filePath, int thumbsToGet, Size maxSize)
        {
            VideoSummary summary = new VideoSummary(filePath);

            OpenVideoResult res       = LoadFile(filePath, false);
            FrameDimension  dimension = new FrameDimension(gif.FrameDimensionsList[0]);

            if (res == OpenVideoResult.Success)
            {
                summary.IsImage = count == 1;
                summary.DurationMilliseconds = (int)((double)count * videoInfo.FrameIntervalMilliseconds);
                summary.Framerate            = videoInfo.FramesPerSeconds;

                if (thumbsToGet > 0)
                {
                    int step = (int)Math.Ceiling(count / (double)thumbsToGet);
                    for (int i = 0; i < count; i += step)
                    {
                        summary.Thumbs.Add(GetFrameAt(dimension, i));
                    }
                }

                summary.ImageSize = videoInfo.OriginalSize;
            }

            if (loaded)
            {
                Close();
            }

            gif.Dispose();
            return(summary);
        }
コード例 #2
0
ファイル: VideoReaderBitmap.cs プロジェクト: weblate/Kinovea
        public override VideoSummary ExtractSummary(string filePath, int thumbs, Size maxSize)
        {
            OpenVideoResult res     = Open(filePath);
            VideoSummary    summary = new VideoSummary(filePath);

            if (res != OpenVideoResult.Success || generator == null)
            {
                return(summary);
            }

            SystemBitmap bmp  = generator.Generate(0);
            Size         size = bmp.Size;

            summary.ImageSize = size;

            // TODO: compute the correct ratio stretched size. Currently this uses the maxSize.width
            // which is not the actual final width of the thumbnail if the ratio is more vertical than 4:3.
            int height = (int)(size.Height / ((float)size.Width / maxSize.Width));

            SystemBitmap thumb = new SystemBitmap(maxSize.Width, height);
            Graphics     g     = Graphics.FromImage(thumb);

            g.DrawImage(bmp, 0, 0, maxSize.Width, height);
            g.Dispose();
            Close();

            summary.Thumbs.Add(thumb);

            summary.IsImage = true;
            summary.DurationMilliseconds = 0;

            return(summary);
        }
コード例 #3
0
        public override VideoSummary ExtractSummary(string filePath, int thumbs, Size maxSize)
        {
            VideoSummary    summary = new VideoSummary(filePath);
            OpenVideoResult res     = Open(filePath);

            if (res != OpenVideoResult.Success || generator == null)
            {
                return(summary);
            }

            Bitmap bmp  = generator.Generate(0, maxSize);
            Size   size = bmp.Size;

            summary.ImageSize = size;

            int      height = (int)(size.Height / ((float)size.Width / maxSize.Width));
            Bitmap   thumb  = new Bitmap(maxSize.Width, height);
            Graphics g      = Graphics.FromImage(thumb);

            g.DrawImage(bmp, 0, 0, maxSize.Width, height);
            g.Dispose();
            Close();

            summary.Thumbs.Add(thumb);
            summary.DurationMilliseconds = (int)((videoInfo.DurationTimeStamps - videoInfo.AverageTimeStampsPerFrame) * videoInfo.FrameIntervalMilliseconds);
            summary.Framerate            = videoInfo.FramesPerSeconds;
            summary.IsImage = false;

            return(summary);
        }
コード例 #4
0
ファイル: VideoReaderSVG.cs プロジェクト: weblate/Kinovea
        public override VideoSummary ExtractSummary(string filePath, int thumbs, Size maxSize)
        {
            VideoSummary    summary = new VideoSummary(filePath);
            OpenVideoResult res     = Open(filePath);

            if (res != OpenVideoResult.Success || generator == null)
            {
                return(summary);
            }

            Bitmap   bmp   = generator.Generate(0, maxSize);
            Bitmap   thumb = new Bitmap(bmp.Width, bmp.Height);
            Graphics g     = Graphics.FromImage(thumb);

            g.DrawImage(bmp, 0, 0, bmp.Width, bmp.Height);
            g.Dispose();
            Close();

            summary.Thumbs.Add(thumb);
            summary.IsImage              = true;
            summary.ImageSize            = Size.Empty;
            summary.DurationMilliseconds = 0;

            return(summary);
        }
コード例 #5
0
ファイル: VideoFile.cs プロジェクト: Geta/vippy
 public VideoFile(VirtualPathProvider provider, Video vippyVideo)
     : base(provider.RootDirectory, provider, CreateVideoPath(provider, vippyVideo), true)
 {
     _provider = provider;
     _vippyVideo = vippyVideo;
     _videoSummary = new VideoSummary(this, vippyVideo);
 }
コード例 #6
0
ファイル: SummaryLoader.cs プロジェクト: jfpk/kinoveaIDS
        private void bgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            // Note: having one background worker per file and running them all in parallel was tested
            // but it does more harm than good.
            BackgroundWorker bgWorker  = sender as BackgroundWorker;
            List <string>    filenames = e.Argument as List <string>;

            if (filenames.Count < 1 || bgWorker == null)
            {
                e.Result = null;
                return;
            }

            for (int i = 0; i < filenames.Count; i++)
            {
                if (bgWorker.CancellationPending)
                {
                    break;
                }

                string       filename = filenames[i];
                VideoSummary summary  = null;

                try
                {
                    if (string.IsNullOrEmpty(filename))
                    {
                        continue;
                    }

                    string      extension = Path.GetExtension(filename);
                    VideoReader reader    = VideoTypeManager.GetVideoReader(extension);

                    int numberOfThumbnails = 5;

                    if (reader != null)
                    {
                        summary = reader.ExtractSummary(filename, numberOfThumbnails, maxImageSize);
                    }
                }
                catch (Exception exp)
                {
                    log.ErrorFormat("Error while extracting video summary for {0}.", filename);
                    log.Error(exp);
                }

                if (summary == null)
                {
                    summary = new VideoSummary(filename);
                }

                bgWorker.ReportProgress(i, summary);
            }
        }
コード例 #7
0
ファイル: ThumbnailFile.cs プロジェクト: jfpk/kinoveaIDS
        public void Populate(VideoSummary summary)
        {
            m_Loaded = true;

            if (summary == null || summary.Thumbs == null || summary.Thumbs.Count < 1)
            {
                DisplayAsError();
            }
            else
            {
                m_Bitmaps = summary.Thumbs;
                if (m_Bitmaps != null && m_Bitmaps.Count > 0)
                {
                    currentThumbnailIndex = 0;
                    currentThumbnail      = m_Bitmaps[currentThumbnailIndex];
                }

                if (summary.IsImage)
                {
                    m_bIsImage = true;
                    details.Details[FileProperty.Duration] = "0";
                }
                else
                {
                    details.Details[FileProperty.Duration]  = TimeHelper.MillisecondsToTimecode((double)summary.DurationMilliseconds, false, true);
                    details.Details[FileProperty.Framerate] = string.Format("{0:0.##} fps", summary.Framerate);
                }

                if (summary.ImageSize == Size.Empty)
                {
                    details.Details[FileProperty.Size] = "";
                }
                else
                {
                    details.Details[FileProperty.Size] = string.Format("{0}×{1}", summary.ImageSize.Width, summary.ImageSize.Height);
                }

                hasKva = summary.HasKva;
                if (hasKva)
                {
                    details.Details[FileProperty.HasKva] = "kva";
                }

                details.Details[FileProperty.CreationTime] = string.Format("{0:g}", summary.Creation);

                SetSize(this.Width, this.Height);
            }
        }
コード例 #8
0
        public SubtitleInfo PostVideo(AmaraSubtitleJob vj)
        {
            VideoSummary vs = null;

            if (vj.VideoUrl.Contains("youtube") || vj.VideoUrl.Contains("vimeo") || vj.VideoUrl.Contains("dailymotion"))
            {
                vs = new VideoSummary()
                {
                    VideoUrl = vj.VideoUrl//"http://www.youtube.com/watch?v=cJs7obmEABE"//"https://www.youtube.com/watch?v=RdKAVE0frIM&ab_channel=BBC"
                };
            }
            else
            {
                if (vj.VideoUrl.Contains("localhost"))
                {
                    vj.VideoUrl = "http://2.109.50.18:5150/dist/test.webm";
                }
                vs = new VideoSummary()
                {
                    VideoUrl = vj.VideoUrl,
                    //Title = vj.FileName,
                    //Description = "a video uploaded by RoboBraille",
                    //Duration = 80,
                    //PrimaryAudioLanguageCode = vj.SubtitleLangauge,
                    //Thumbnail = "http://www.robobraille.org/sites/default/files/webrobo_logo.jpg",
                    //Metadata = new Dictionary<string, string>() { {"location","dk"} },
                    //Team = "RoboBraille",
                    //Project = "P4All"
                };
            }
            SubtitleInfo si = vcc.RequestVideoSubtitle(vs, vj.SubtitleLangauge, vj.SubtitleFormat);

            if (File.Exists(distFile))
            {
                File.Delete(distFile);
            }
            return(si);
        }
コード例 #9
0
        private static void TestPostVideo()
        {
            VideoSummary vs = new VideoSummary()
            {
                VideoUrl = "http://www.youtube.com/watch?v=cJs7obmEABE"//"https://www.youtube.com/watch?v=RdKAVE0frIM&ab_channel=BBC"
            };
            string       subLang   = "dk";
            string       subFormat = "txt";
            SubtitleInfo si        = vcc.RequestVideoSubtitle(vs, subLang, subFormat);

            switch (si.Status)
            {
            case VideoSubtitleStatus.Complete:
                break;

            case VideoSubtitleStatus.SubtitleRequested:
                Console.WriteLine("Video exists, but subtitle does not, request for subtitle is made.");
                break;

            case VideoSubtitleStatus.Error:
                Console.WriteLine("Error happened!");
                break;

            case VideoSubtitleStatus.Exists:
                byte[] res = vcc.GetVideoSubtitle(si.VideoId, subLang, subFormat).SubtitleData;
                Console.WriteLine("Result: " + Encoding.Default.GetString(res));
                break;

            case VideoSubtitleStatus.NotComplete: break;

            case VideoSubtitleStatus.Submitted:
                Console.WriteLine("Video with id {1} has been submitted for manual subtitling. You'll get notified when it's ready by pigeon!", si.VideoId);
                break;

            default: break;
            }
        }
コード例 #10
0
 public SummaryLoadedEventArgs(VideoSummary summary, int progress)
 {
     this.Summary  = summary;
     this.Progress = progress;
 }
コード例 #11
0
ファイル: VideoFile.cs プロジェクト: Geta/vippy
 public VideoFile(VirtualPathProvider provider, string filename)
     : base(provider.RootDirectory, provider, CreateVideoPathFromFileName(provider, filename), true)
 {
     _provider = provider;
     _videoSummary = new VideoSummary(this, filename);
 }