title: How to open&save a video file in python?
body: <p>I've just started to make a ubuntu application using PyGtk. My very first object is to open, convert and then save a video file. Ignoring convert phase, I'm going to implant open-save functions. But at the moment when I open a video file, and save it, I get non-video file with 11B size. I've just google this and found <a href="http://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_setup/py_intro/py_intro.html#intro" rel="nofollow">OpenCV</a> for python. But I'm not sure if it's the best way to do it. I also think I'm going to use ffmpeg libraries to do some manipulates on video files. Is it what I want or there might be other built-in libraries?</p>
  
  <p>By the way, here's my code to open and save the file :</p>
  
  <pre><code>    def on_openFile_clicked(self, widget):
          filename=None
          dialog = Gtk.FileChooserDialog("Please choose a file", self,
              Gtk.FileChooserAction.OPEN,
              (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
               Gtk.STOCK_OPEN, Gtk.ResponseType.OK))
  
          response = dialog.run()
          self.add_filters(dialog)
  
          if response == Gtk.ResponseType.OK:
              filename = dialog.get_filename()
          elif response == Gtk.ResponseType.CANCEL:
              print 'Cancel Clicked'
          dialog.destroy()
  
          print "File Choosen: ", filename
  
      def add_filters(self, dialog):
  
          filter_py = Gtk.FileFilter()
          filter_py.set_name("Video Files")
          filter_py.add_mime_type("video/mp4")
          filter_py.add_mime_type("video/x-flv")
          dialog.add_filter(filter_py)
  
          filter_any = Gtk.FileFilter()
          filter_any.set_name("Any files")
          filter_any.add_pattern("*")
          dialog.add_filter(filter_any)
  
      def on_saveFile_clicked(self, widget):
          filename=None
          dialog = Gtk.FileChooserDialog("Please choose a file", self,
              Gtk.FileChooserAction.SAVE,
              (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
               Gtk.STOCK_SAVE, Gtk.ResponseType.OK))
  
          response = dialog.run()
          self.add_filters(dialog)
  
          if response == Gtk.ResponseType.OK:
              filename = dialog.get_filename()
          elif response == Gtk.ResponseType.CANCEL:
              print 'Cancel Clicked'
          dialog.destroy()
  
          if filename != None:
              save_file=open(filename, 'w')
              save_file.write("Sample Data")
              save_file.close()
          print "File Saved: ", filename
  </code></pre>