示例#1
0
        void RemuxOutputFile(EncodingSettings settings)
        {
            VideoMuxerType muxer;

            /* We need to remux to the original format */
            muxer = settings.EncodingProfile.Muxer;
            if (muxer == VideoMuxerType.Avi || muxer == VideoMuxerType.Mp4)
            {
                string outFile = settings.OutputFile;
                string tmpFile = settings.OutputFile;

                while (System.IO.File.Exists(tmpFile))
                {
                    tmpFile = tmpFile + ".tmp";
                }

                System.IO.File.Move(outFile, tmpFile);
                Remuxer remuxer = new Remuxer(PreviewMediaFile.DiscoverFile(tmpFile),
                                              outFile, muxer);

                /* Remuxing suceed, delete old file */
                if (remuxer.Remux(this.Toplevel as Gtk.Window) == outFile)
                {
                    System.IO.File.Delete(tmpFile);
                }
                else
                {
                    System.IO.File.Delete(outFile);
                    System.IO.File.Move(tmpFile, outFile);
                }
            }
        }
示例#2
0
        private void SaveCaptureProject(Project project)
        {
            MessageDialog md;
            string        filePath = project.Description.File.FilePath;

            Log.Debug("Saving capture project: " + project);
            md = new MessageDialog(mainWindow as Gtk.Window, DialogFlags.Modal,
                                   MessageType.Info, ButtonsType.None,
                                   Catalog.GetString("Loading newly created project..."));
            md.Show();

            /* scan the new file to build a new PreviewMediaFile with all the metadata */
            try {
                Log.Debug("Reloading saved file: " + filePath);
                project.Description.File = PreviewMediaFile.DiscoverFile(filePath);
                Core.DB.AddProject(project);
            } catch (Exception ex) {
                Log.Exception(ex);
                Log.Debug("Backing up project to file");
                string projectFile = filePath + "-" + DateTime.Now;
                projectFile = projectFile.Replace("-", "_").Replace(" ", "_").Replace(":", "_");
                Project.Export(OpenedProject, projectFile);
                MessagePopup.PopupMessage(mainWindow, MessageType.Error,
                                          Catalog.GetString("An error occured saving the project:\n") + ex.Message + "\n\n" +
                                          Catalog.GetString("The video file and a backup of the project has been " +
                                                            "saved. Try to import it later:\n") +
                                          filePath + "\n" + projectFile);
            }
            /* we need to set the opened project to null to avoid calling again CloseOpendProject() */
            /* FIXME: */
            //project = null;
            SetProject(project, ProjectType.FileProject, new CaptureSettings());
            md.Destroy();
        }
示例#3
0
        protected void OnAddbuttonClicked(object sender, System.EventArgs e)
        {
            var           msg   = Catalog.GetString("Add file");
            List <string> paths = FileChooserHelper.OpenFiles(this, msg, null,
                                                              Config.HomeDir, null, null);
            List <string> errors = new List <string>();

            foreach (string path in paths)
            {
                try {
                    MediaFile file = PreviewMediaFile.DiscoverFile(path, false);
                    store.AppendValues(file);
                    Files.Add(file);
                } catch (Exception) {
                    errors.Add(path);
                }
            }
            if (errors.Count != 0)
            {
                string s = Catalog.GetString("Error adding files:");
                foreach (string p in errors)
                {
                    s += '\n' + p;
                }
                GUIToolkit.Instance.ErrorMessage(s);
            }
            CheckStatus();
        }
示例#4
0
 public MediaFile DiscoverFile(string file)
 {
     return(PreviewMediaFile.DiscoverFile(file));
 }
示例#5
0
        protected virtual void OnOpenbuttonClicked(object sender, System.EventArgs e)
        {
            if (useType == ProjectType.CaptureProject || useType == ProjectType.URICaptureProject)
            {
                string filename;

                filename = FileChooserHelper.SaveFile(this, Catalog.GetString("Output file"),
                                                      "Capture.mp4", Config.VideosDir, "MP4",
                                                      new string[] { "*.mp4" });
                if (filename != null)
                {
                    fileEntry.Text = System.IO.Path.ChangeExtension(filename, "mp4");
                }
            }
            else
            {
                MessageDialog md = null;
                string        folder, filename;

                folder   = System.Environment.GetFolderPath(Environment.SpecialFolder.Personal);
                filename = FileChooserHelper.OpenFile(this, Catalog.GetString("Open file"),
                                                      null, folder, null, null);
                if (filename == null)
                {
                    return;
                }

                try {
                    md = new MessageDialog((Gtk.Window) this.Toplevel,
                                           DialogFlags.Modal,
                                           MessageType.Info,
                                           Gtk.ButtonsType.None,
                                           Catalog.GetString("Analyzing video file:") + "\n" + filename);
                    md.Icon = Stetic.IconLoader.LoadIcon(this, "longomatch", Gtk.IconSize.Dialog);
                    md.Show();

                    mFile = PreviewMediaFile.DiscoverFile(filename);
                    if (!mFile.HasVideo || mFile.VideoCodec == "")
                    {
                        throw new Exception(Catalog.GetString("This file doesn't contain a video stream."));
                    }
                    if (mFile.HasVideo && mFile.Length == 0)
                    {
                        throw new Exception(Catalog.GetString("This file contains a video stream but its length is 0."));
                    }
                    if (GStreamer.FileNeedsRemux(mFile))
                    {
                        string q = Catalog.GetString("The file you are trying to load is not properly supported. " +
                                                     "Would you like to convert it into a more suitable format?");
                        if (MessagesHelpers.QuestionMessage(this, q))
                        {
                            var remux       = new Remuxer(mFile);
                            var newFilename = remux.Remux(this.Toplevel as Gtk.Window);
                            if (newFilename != null)
                            {
                                mFile = PreviewMediaFile.DiscoverFile(newFilename);
                            }
                        }
                    }
                    fileEntry.Text = mFile.FilePath;
                }
                catch (Exception ex) {
                    MessagesHelpers.ErrorMessage(this, ex.Message);
                }
                finally {
                    md.Destroy();
                }
            }
        }
        protected virtual void OnOpenbuttonClicked(object sender, System.EventArgs e)
        {
            FileChooserDialog fChooser = null;

            if (useType == ProjectType.CaptureProject)
            {
                fChooser = new FileChooserDialog(Catalog.GetString("Output file"),
                                                 (Gtk.Window) this.Toplevel,
                                                 FileChooserAction.Save,
                                                 "gtk-cancel", ResponseType.Cancel,
                                                 "gtk-save", ResponseType.Accept);
                fChooser.SetCurrentFolder(Config.VideosDir());
                fChooser.DoOverwriteConfirmation = true;
                if (fChooser.Run() == (int)ResponseType.Accept)
                {
                    fileEntry.Text = fChooser.Filename;
                }
                fChooser.Destroy();
            }
            else
            {
                fChooser = new FileChooserDialog(Catalog.GetString("Open file..."),
                                                 (Gtk.Window) this.Toplevel,
                                                 FileChooserAction.Open,
                                                 "gtk-cancel", ResponseType.Cancel,
                                                 "gtk-open", ResponseType.Accept);

                fChooser.SetCurrentFolder(System.Environment.GetFolderPath(Environment.SpecialFolder.Personal));

                if (fChooser.Run() == (int)ResponseType.Accept)
                {
                    MessageDialog md       = null;
                    string        filename = fChooser.Filename;
                    fChooser.Destroy();

                    if (MpegRemuxer.FileIsMpeg(filename) &&
                        MpegRemuxer.AskForConversion(this.Toplevel as Gtk.Window))
                    {
                        var remux       = new MpegRemuxer(filename);
                        var newFilename = remux.Remux(this.Toplevel as Gtk.Window);
                        if (newFilename != null)
                        {
                            filename = newFilename;
                        }
                    }

                    try {
                        md = new MessageDialog((Gtk.Window) this.Toplevel,
                                               DialogFlags.Modal,
                                               MessageType.Info,
                                               Gtk.ButtonsType.None,
                                               Catalog.GetString("Analyzing video file:") + "\n" + filename);
                        md.Icon = Stetic.IconLoader.LoadIcon(this, "longomatch", Gtk.IconSize.Dialog);
                        md.Show();
                        mFile = PreviewMediaFile.DiscoverFile(filename);
                        if (!mFile.HasVideo || mFile.VideoCodec == "")
                        {
                            throw new Exception(Catalog.GetString("This file doesn't contain a video stream."));
                        }
                        if (mFile.HasVideo && mFile.Length == 0)
                        {
                            throw new Exception(Catalog.GetString("This file contains a video stream but its length is 0."));
                        }


                        fileEntry.Text = filename;
                    }
                    catch (Exception ex) {
                        MessagePopup.PopupMessage(this, MessageType.Error,
                                                  ex.Message);
                    }
                    finally {
                        md.Destroy();
                    }
                }
                fChooser.Destroy();
            }
        }