Esempio n. 1
0
 def set_uri(self, uri):
     """Set the URI of the file to play."""
     self.ready = False
     self._playbin.props.uri = uri
     self.subtitle_text = ""
     try:
         # Find out the exact framerate to be able
         # to convert between position types.
         from gi.repository import GstPbutils
         discoverer = GstPbutils.Discoverer()
         self._info = discoverer.discover_uri(uri)
         streams = self._info.get_stream_list()
         stream_types = [x.get_stream_type_nick() for x in streams]
         if "video" not in stream_types:
             raise Exception(_("No video streams found"))
         stream = self._info.get_video_streams()[0]
         num = float(stream.get_framerate_num())
         denom = float(stream.get_framerate_denom())
         self.calc = aeidon.Calculator(num/denom)
         self.ready = True
     except Exception as error:
         title = _("Failed to initialize playback")
         dialog = gaupol.ErrorDialog(None, title, str(error))
         dialog.add_button(_("_OK"), Gtk.ResponseType.OK)
         dialog.set_default_response(Gtk.ResponseType.OK)
         gaupol.util.flash_dialog(dialog)
     else:
         # Make stream tags available from _playbin
         self._playbin.set_state(Gst.State.PAUSED)
         self._playbin.get_state(Gst.CLOCK_TIME_NONE)
Esempio n. 2
0
 def set_uri(self, uri):
     """Set the URI of the file to play."""
     self.ready = False
     self._playbin.props.uri = uri
     # XXX: On Windows, we'd need HWND instead of XID,
     # but there seems to be no clear way to do this.
     # http://stackoverflow.com/q/23021327/653825
     self._xid = self.widget.get_window().get_xid()
     self.subtitle_text = ""
     try:
         # Find out the exact framerate to be able
         # to convert between position types.
         from gi.repository import GstPbutils
         discoverer = GstPbutils.Discoverer()
         self._info = discoverer.discover_uri(uri)
         stream = self._info.get_video_streams()[0]
         num = float(stream.get_framerate_num())
         denom = float(stream.get_framerate_denom())
         self.calc = aeidon.Calculator(num / denom)
         self.ready = True
     except Exception as error:
         title = _("Failed to initialize playback")
         dialog = gaupol.ErrorDialog(None, title, str(error))
         dialog.add_button(_("_OK"), Gtk.ResponseType.OK)
         dialog.set_default_response(Gtk.ResponseType.OK)
         gaupol.util.flash_dialog(dialog)
Esempio n. 3
0
 def __init__(self, edit_mode):
     """Initialize a :class:`View` instance."""
     GObject.GObject.__init__(self)
     self._active_col_name = ""
     self._calc = aeidon.Calculator()
     self.columns = aeidon.Enumeration()
     self._selection_changed_handlers = {}
     self._init_signal_handlers()
     self._init_props(edit_mode)
Esempio n. 4
0
 def __init__(self, mode=None, framerate=None):
     """Initialize a :class:`Subtitle` instance."""
     self._start = None
     self._end = None
     self._main_text = ""
     self._tran_text = ""
     self._mode = mode or aeidon.modes.TIME
     self._framerate = framerate or aeidon.framerates.FPS_23_976
     self.calc = aeidon.Calculator(self._framerate)
     self.start = "00:00:00.000"
     self.end = "00:00:00.000"
Esempio n. 5
0
 def set_framerate(self, framerate, register=-1):
     """Set the value of framerate."""
     orig_framerate = self.framerate
     self.framerate = framerate
     self.calc = aeidon.Calculator(framerate)
     for subtitle in self.subtitles:
         subtitle.framerate = framerate
     action = aeidon.RevertableAction(register=register)
     action.docs = tuple(aeidon.documents)
     action.description = _("Setting framerate")
     action.revert_function = self.set_framerate
     action.revert_args = (orig_framerate, )
     self.register_action(action)
Esempio n. 6
0
 def __init__(self):
     """Initialize a :class:`VideoPlayer` instance."""
     aeidon.Observable.__init__(self)
     self.calc = aeidon.Calculator()
     self._in_default_segment = True
     self._info = None
     self._playbin = None
     self._prev_state = None
     self.ready = False
     self.subtitle_text_raw = ""
     self._text_overlay = None
     self._time_overlay = None
     self.widget = None
     self._init_widget()
     self._init_text_overlay()
     self._init_time_overlay()
     self._init_pipeline()
     self._init_bus()
Esempio n. 7
0
 def __init__(self, framerate=None, undo_limit=None):
     """Initialize a :class:`Project` object."""
     aeidon.Observable.__init__(self)
     framerate = framerate or aeidon.framerates.FPS_23_976
     self._delegations = {}
     self.calc = aeidon.Calculator(framerate)
     self.clipboard = aeidon.Clipboard()
     self.framerate = framerate
     self.main_changed = 0
     self.main_file = None
     self.redoables = []
     self.subtitles = []
     self.tran_changed = None
     self.tran_file = None
     self.undo_limit = undo_limit
     self.undoables = []
     self.video_path = None
     self._init_delegations()
Esempio n. 8
0
 def set_uri(self, uri):
     """Set the URI of the file to play."""
     self.ready = False
     self._playbin.props.uri = uri
     self.subtitle_text = ""
     try:
         # Find out the exact framerate to be able
         # to convert between position types.
         from gi.repository import GstPbutils
         discoverer = GstPbutils.Discoverer()
         self._info = discoverer.discover_uri(uri)
         stream = self._info.get_video_streams()[0]
         num = float(stream.get_framerate_num())
         denom = float(stream.get_framerate_denom())
         self.calc = aeidon.Calculator(num / denom)
         self.ready = True
     except Exception as error:
         title = _("Failed to initialize playback")
         dialog = gaupol.ErrorDialog(None, title, str(error))
         dialog.add_button(_("_OK"), Gtk.ResponseType.OK)
         dialog.set_default_response(Gtk.ResponseType.OK)
         gaupol.util.flash_dialog(dialog)
Esempio n. 9
0
    def set_uri(self, uri):
        """
        Set the URI of the file to play.

        You should have a window visible before calling `set_uri`.
        """
        self._playbin.props.uri = uri
        self._xid = self.widget.props.window.get_xid()
        self.subtitle_text = ""
        try:
            # Find out the exact framerate to be able
            # to convert between position types.
            discoverer = GstPbutils.Discoverer()
            self._info = discoverer.discover_uri(uri)
            stream = self._info.get_video_streams()[0]
            num = float(stream.get_framerate_num())
            denom = float(stream.get_framerate_denom())
            self.calc = aeidon.Calculator(num / denom)
        except Exception:
            # If any of this fails, playback probably fails
            # as well and we'll show an error dialog then.
            pass
Esempio n. 10
0
 def test_frame_to_seconds(self):
     calc = aeidon.Calculator(aeidon.framerates.FPS_25_000)
     assert calc.frame_to_seconds(127) == 5.08
Esempio n. 11
0
 def test___new____float(self):
     a = aeidon.Calculator(48.0)
     b = aeidon.Calculator(96.0)
     assert a is not b
Esempio n. 12
0
 def test___new__(self):
     a = aeidon.Calculator(aeidon.framerates.FPS_23_976)
     b = aeidon.Calculator(aeidon.framerates.FPS_23_976)
     assert a is b
Esempio n. 13
0
 def setup_method(self, method):
     self.framerate = aeidon.framerates.FPS_23_976
     self.calc = aeidon.Calculator(self.framerate)
Esempio n. 14
0
 def test_to_time(self):
     self.calc = aeidon.Calculator(aeidon.framerates.FPS_25_000)
     assert self.calc.to_time("00:00:01.000") == "00:00:01.000"
     assert self.calc.to_time(25) == "00:00:01.000"
     assert self.calc.to_time(1.0) == "00:00:01.000"
Esempio n. 15
0
 def test_to_seconds(self):
     self.calc = aeidon.Calculator(aeidon.framerates.FPS_25_000)
     assert self.calc.to_seconds("00:00:01.000") == 1.0
     assert self.calc.to_seconds(25) == 1.0
     assert self.calc.to_seconds(1.0) == 1.0
Esempio n. 16
0
 def test___new__(self):
     for framerate in aeidon.framerates:
         a = aeidon.Calculator(framerate)
         b = aeidon.Calculator(framerate)
         assert a is b
Esempio n. 17
0
 def test_to_time(self):
     self.calc = aeidon.Calculator(aeidon.framerates.FPS_25_000)
     time = "00:00:01.000"
     assert self.calc.to_time(aeidon.as_time(time)) == time
     assert self.calc.to_time(aeidon.as_frame(25)) == time
     assert self.calc.to_time(aeidon.as_seconds(1.0)) == time
Esempio n. 18
0
 def framerate(self, value):
     """Set framerate from `value`."""
     self._framerate = value
     self.calc = aeidon.Calculator(value)