コード例 #1
0
ファイル: Video.cs プロジェクト: GNOME/mistelix
        public string Convert(Project project)
        {
            bool rslt;
            string of = GetOutputFile (project.Details.Type);
            string outfile =  project.FileToFullPath (of);

            Logger.Debug ("Video.Convert. File {0} to {1}", filename, outfile);
            // TODO: If rslt != 0 throw an exception
            rslt =  Backends.GStreamer.Video.Convert (filename, outfile, (uint) project.Details.FramesPerSecond);
            return outfile;
        }
コード例 #2
0
ファイル: SlideShow.cs プロジェクト: GNOME/mistelix
        public string Generate(Project project, ProgressEventHandler progress)
        {
            int total_frames = 0;
            int frames_sec = project.Details.FramesPerSecond;
            ProgressEventArgs args = new ProgressEventArgs ();

            for (int i = 0; i < images.Count - 1; i++)
            {
                total_frames += (frames_sec * images[i].ShowTime) + (images[i].TransitionTime * frames_sec);
                ((SlideImage) images[i]).Project = project;
            }

            ((SlideImage) images[images.Count - 1]).Project = project;
            total_frames += frames_sec * images[images.Count - 1].ShowTime;
            args.Total = images.Count;

            Logger.Debug ("SlideShow.Generate. Generating MPEG for " + images.Count + " images " + "total frames " + total_frames + " at " + filename);

            string outfile;

            if (filename == null)
                outfile = GetOutputFile (project.Details.Type);
            else
                outfile = filename;

            Backends.GStreamer.SlideShow.CreateStream (project.FileToFullPath (outfile), project.Details.Type,
                (uint) project.Details.Width, (uint) project.Details.Height, (uint) frames_sec, (uint) total_frames);

            if (AudioFile != null) {
                Logger.Debug ("SlideShow.Generate. Audiofile {0}", AudioFile);
                Backends.GStreamer.SlideShow.AddAudio (AudioFile);
            }

            Transition transition;
            Logger.Debug ("SlideShow.Generate. Images.Count {0}", images.Count);

            // We need to make sure that source and target slides are loaded. Here we make sure that source is loaded
            ((SlideImage) images[0]).LoadSlide ();

            for (int i = 0;  i < images.Count - 1; i++) {

                if (progress != null) {
                    args.Progress = args.Progress + 1;
                    progress (this, args);
                }

                Logger.Debug ("SlideShow.Generate. Send Fixed image {0}, time {1} (frames)", i, (uint) (frames_sec * images[i].ShowTime));
                transition = TransitionManager.CreateFromName (images[i].Transition);
                Backends.GStreamer.SlideShow.AddImageFixed (((SlideImage)images[i]), (uint) (frames_sec * images[i].ShowTime));

                // Transition between two images
                Logger.Debug ("SlideShow.Generate. Generate transition for frames_sec {0} and time {1}", frames_sec, images[i].TransitionTime);

                // We need to make sure that source and target slides are loaded. Here we make sure that target is loaded
                ((SlideImage) images[i + 1]).LoadSlide (); // Here we do target

                transition.Source = (SlideImage) images[i];
                transition.Target = (SlideImage) images[i + 1];
                transition.Frames = frames_sec * images[i].TransitionTime;
                foreach (SlideImage img in transition)
                    Backends.GStreamer.SlideShow.AddImage (img);

                Logger.Debug ("Sending subimage completed");
                ((SlideImage) images[i]).ReleasePixels ();
            }

            Logger.Debug ("SlideShow.Generate. Send fixed image time {0} (frames)", (uint) (frames_sec * images[images.Count -1].ShowTime));
            Backends.GStreamer.SlideShow.AddImageFixed (((SlideImage)images[images.Count - 1]), (uint) (frames_sec * images[images.Count -1].ShowTime));
            ((SlideImage) images[images.Count - 1]).ReleasePixels ();

            if (progress != null) {
                args.Progress = args.Progress + 1;
                progress (this, args);
            }

            // This a blocking call. It does not return until the pipeline sends an EOS
            Backends.GStreamer.SlideShow.Close ();
            Logger.Debug ("SlideShow.Generate. Finished generation");
            return project.FileToFullPath (outfile);
        }