Ejemplo n.º 1
0
        public static Multimedia UpdateMultimedia(Multimedia multimedia)
        {
            if (multimedia == null)
            {
                return(null);
            }

            using (MyPhotosContainer context = new MyPhotosContainer())
            {
                IUnitOfWork unitOfWork = new UnitOfWork.UnitOfWork(context);

                Multimedia oldMultimedia = unitOfWork.Multimedia.GetById(multimedia.Id);

                if (oldMultimedia == null)
                {
                    return(null);
                }

                MultimediaFactory.Update(oldMultimedia, multimedia);

                unitOfWork.Save();

                return(oldMultimedia);
            }
        }
Ejemplo n.º 2
0
 public static void Init()
 {
     Log.Information("Initializing GStreamer.");
     SetUpEnvironment();
     MultimediaFactory.InitBackend();
     Log.Information("GStreamer initialized successfully.");
 }
Ejemplo n.º 3
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();
        }
Ejemplo n.º 4
0
 public RenderingJobsManager(RenderingStateBar stateBar)
 {
     jobs                 = new List <Job>();
     pendingJobs          = new List <Job>();
     factory              = new MultimediaFactory();
     this.stateBar        = stateBar;
     stateBar.Cancel     += (sender, e) => CancelCurrentJob();
     stateBar.ManageJobs += (sender, e) => ManageJobs();
 }
Ejemplo n.º 5
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);
            }
        }
Ejemplo n.º 6
0
        public MediaFile DiscoverFile(string filePath, bool takeScreenshot = true)
        {
            long   duration = 0;
            uint   width, height, fps_n, fps_d, par_n, par_d, ret, fps = 0;
            string container, audio_codec, video_codec;
            bool   has_audio, has_video;
            float  par = 0;
            IntPtr container_ptr, audio_codec_ptr, video_codec_ptr;
            IntPtr error = IntPtr.Zero;

            LongoMatch.Core.Common.Image preview = null;
            MultimediaFactory            factory;
            IFramesCapturer thumbnailer;

            ret = lgm_discover_uri(filePath, out duration, out width, out height, out fps_n,
                                   out fps_d, out par_n, out par_d, out container_ptr,
                                   out video_codec_ptr, out audio_codec_ptr, out error);
            if (error != IntPtr.Zero)
            {
                throw new GLib.GException(error);
            }
            if (ret != 0)
            {
                throw new Exception(Catalog.GetString("Could not parse file:") + filePath);
            }

            has_audio   = audio_codec_ptr != IntPtr.Zero;
            has_video   = video_codec_ptr != IntPtr.Zero;
            container   = GLib.Marshaller.PtrToStringGFree(container_ptr);
            audio_codec = GLib.Marshaller.PtrToStringGFree(audio_codec_ptr);
            video_codec = GLib.Marshaller.PtrToStringGFree(video_codec_ptr);
            /* From nanoseconds to milliseconds */
            duration = duration / (1000 * 1000);

            if (has_video)
            {
                fps = fps_n / fps_d;
                par = (float)par_n / par_d;
                if (takeScreenshot)
                {
                    factory     = new MultimediaFactory();
                    thumbnailer = factory.GetFramesCapturer();
                    thumbnailer.Open(filePath);
                    preview = thumbnailer.GetFrame(new Time {
                        TotalSeconds = 2
                    }, false,
                                                   THUMBNAIL_MAX_WIDTH, THUMBNAIL_MAX_HEIGHT);
                    thumbnailer.Dispose();
                }
            }

            return(new LongoMatch.Core.Store.MediaFile(filePath, duration, (ushort)fps, has_audio, has_video,
                                                       container, video_codec, audio_codec, width, height,
                                                       par, preview, null));
        }
Ejemplo n.º 7
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;
        }
Ejemplo n.º 8
0
        private void PlayerInit()
        {
            MultimediaFactory factory;
            Widget            playerWidget;

            factory = new MultimediaFactory();
            player  = factory.GetPlayer(320, 280);

            tickHandler         = new LongoMatch.Video.Common.TickHandler(OnTick);
            player.Tick        += tickHandler;
            player.StateChange += OnStateChanged;
            player.Eos         += OnEndOfStream;
            player.Error       += OnError;
            player.ReadyToSeek += OnReadyToSeek;

            playerWidget = (Widget)player;
            playerWidget.ButtonPressEvent += OnVideoboxButtonPressEvent;
            playerWidget.ScrollEvent      += OnVideoboxScrollEvent;
            playerWidget.Show();
            videobox.Add(playerWidget);
        }
Ejemplo n.º 9
0
        public static MediaFile GetMediaFile(string filePath)
        {
            int               duration, fps = 0, height = 0, width = 0;
            bool              hasVideo, hasAudio;
            string            audioCodec = "", videoCodec = "";
            MultimediaFactory factory;
            IMetadataReader   reader = null;

            try{
                factory = new MultimediaFactory();
                reader  = factory.getMetadataReader();
                reader.Open(filePath);
                duration = (int)reader.GetMetadata(MetadataType.Duration);
                hasVideo = (bool)reader.GetMetadata(MetadataType.HasVideo);
                hasAudio = (bool)reader.GetMetadata(MetadataType.HasAudio);
                if (hasAudio)
                {
                    audioCodec = (string)reader.GetMetadata(MetadataType.AudioEncoderType);
                }
                if (hasVideo)
                {
                    videoCodec = (string)reader.GetMetadata(MetadataType.VideoEncoderType);
                    fps        = (int)reader.GetMetadata(MetadataType.Fps);
                }
                height = (int)reader.GetMetadata(MetadataType.DimensionX);
                width  = (int)reader.GetMetadata(MetadataType.DimensionY);

                return(new MediaFile(filePath, duration * 1000, (ushort)fps,
                                     hasAudio, hasVideo, videoCodec, audioCodec,
                                     (uint)height, (uint)width));
            }
            catch (GLib.GException ex) {
                throw new Exception(Catalog.GetString("Invalid video file:") + "\n" + ex.Message);
            }
            finally {
                reader.Close();
                reader.Dispose();
            }
        }
Ejemplo n.º 10
0
        public static void Main(string[] args)
        {
            /* Init Gtk */
            Application.Init();

            Core.Init();

            /* Init GStreamer */
            GStreamer.Init();
            if (!GStreamer.CheckInstallation())
            {
                return;
            }

            GLib.ExceptionManager.UnhandledException += new GLib.UnhandledExceptionHandler(OnException);
            Version version = Assembly.GetExecutingAssembly().GetName().Version;

            try {
                AddinsManager manager = new AddinsManager(Config.PluginsConfigDir, Config.PluginsDir);
                manager.LoadConfigModifierAddins();
                GUIToolkit         guiToolkit        = new GUIToolkit(version);
                IMultimediaToolkit multimediaToolkit = new MultimediaFactory();
                manager.LoadExportProjectAddins(guiToolkit.MainWindow);
                manager.LoadImportProjectAddins(guiToolkit.MainWindow);
                try {
                    Core.Start(guiToolkit, multimediaToolkit);
                } catch (DBLockedException locked) {
                    string msg = Catalog.GetString("The database seems to be locked by another instance and " +
                                                   "the application will closed.");
                    Log.Exception(locked);
                    return;
                }
                Application.Run();
            } catch (Exception ex) {
                ProcessExecutionError(ex);
            }
        }