Exemplo n.º 1
0
        /*
         * public static void ExportToCSV(Project project) {
         *      FileChooserDialog fChooser;
         *      FileFilter filter;
         *      string outputFile;
         *      CSVExport export;
         *
         *      fChooser = new FileChooserDialog(Catalog.GetString("Select Export File"),
         *                                       window,
         *                                       FileChooserAction.Save,
         *                                       "gtk-cancel",ResponseType.Cancel,
         *                                       "gtk-save",ResponseType.Accept);
         *      fChooser.SetCurrentFolder(MainClass.HomeDir());
         *      fChooser.DoOverwriteConfirmation = true;
         *      filter = new FileFilter();
         *      filter.Name = "CSV File";
         *      filter.AddPattern("*.csv");
         *      fChooser.AddFilter(filter);
         *      if(fChooser.Run() == (int)ResponseType.Accept) {
         *              outputFile=fChooser.Filename;
         *              outputFile = System.IO.Path.ChangeExtension(outputFile,"csv");
         *              export = new CSVExport(project, outputFile);
         *              export.WriteToFile();
         *      }
         *      fChooser.Destroy();
         * }*/

        private void CreateThumbnails(Project project)
        {
            MultimediaFactory factory;
            IFramesCapturer   capturer;
            BusyDialog        dialog;

            dialog = new BusyDialog();
            dialog.TransientFor = mainWindow;
            dialog.Message      = Catalog.GetString("Creating video thumbnails. This can take a while.");
            dialog.Show();
            dialog.Pulse();

            /* Create all the thumbnails */
            factory  = new MultimediaFactory();
            capturer = factory.getFramesCapturer();
            capturer.Open(project.Description.File.FilePath);
            foreach (Play play in project.AllPlays())
            {
                try {
                    capturer.SeekTime(play.Start.MSeconds + ((play.Stop - play.Start).MSeconds / 2),
                                      true);
                    play.Miniature = capturer.GetCurrentFrame(Constants.THUMBNAIL_MAX_WIDTH,
                                                              Constants.THUMBNAIL_MAX_HEIGHT);
                    dialog.Pulse();
                } catch (Exception ex) {
                    Log.Exception(ex);
                }
            }
            capturer.Dispose();
            dialog.Destroy();
        }
Exemplo n.º 2
0
        public new static PreviewMediaFile GetMediaFile(string filePath)
        {
            int               duration = 0;
            bool              hasVideo;
            bool              hasAudio;
            string            AudioEncoderType = "";
            string            VideoEncoderType = "";
            int               fps     = 0;
            int               height  = 0;
            int               width   = 0;
            Pixbuf            preview = null;
            MultimediaFactory factory;
            IMetadataReader   reader;
            IFramesCapturer   thumbnailer;

            try{
                factory = new MultimediaFactory();
                reader  = factory.getMetadataReader();
                reader.Open(filePath);
                hasVideo = (bool)reader.GetMetadata(MetadataType.HasVideo);
                hasAudio = (bool)reader.GetMetadata(MetadataType.HasAudio);
                if (hasAudio)
                {
                    AudioEncoderType = (string)reader.GetMetadata(MetadataType.AudioEncoderType);
                }
                if (hasVideo)
                {
                    VideoEncoderType = (string)reader.GetMetadata(MetadataType.VideoEncoderType);
                    fps         = (int)reader.GetMetadata(MetadataType.Fps);
                    thumbnailer = factory.getFramesCapturer();
                    thumbnailer.Open(filePath);
                    thumbnailer.SeekTime(1000, false);
                    preview  = thumbnailer.GetCurrentFrame(THUMBNAIL_MAX_WIDTH, THUMBNAIL_MAX_HEIGHT);
                    duration = (int)((thumbnailer as GstPlayer).StreamLength / 1000);                                           /* On Windows some formats report a 0 duration, try a last time with the reader */
                    if (duration == 0)
                    {
                        duration = (int)reader.GetMetadata(MetadataType.Duration);
                    }
                    thumbnailer.Dispose();
                }
                height = (int)reader.GetMetadata(MetadataType.DimensionX);
                width  = (int)reader.GetMetadata(MetadataType.DimensionY);
                reader.Close();
                reader.Dispose();

                return(new PreviewMediaFile(filePath, duration * 1000,
                                            (ushort)fps, hasAudio,
                                            hasVideo, VideoEncoderType,
                                            AudioEncoderType, (uint)height,
                                            (uint)width, preview));
            }
            catch (GLib.GException ex) {
                throw new Exception(Catalog.GetString("Invalid video file:") + "\n" + ex.Message);
            }
        }
Exemplo n.º 3
0
        public FramesSeriesCapturer(string videoFile, long start, long stop, uint interval, string outputDir)
        {
            MultimediaFactory mf = new MultimediaFactory();

            this.capturer = mf.getFramesCapturer();
            this.capturer.Open(videoFile);
            this.start       = start;
            this.stop        = stop;
            this.interval    = interval;
            this.outputDir   = outputDir;
            this.seriesName  = System.IO.Path.GetFileName(outputDir);
            this.totalFrames = (int)Math.Floor((double)((stop - start) / interval)) + 1;
        }