Beispiel #1
0
 def test_setTime(self):
     fto = FrameTime(25, time="0:00:00.000")
     time = "1:01:01.234"
     fto.__setTime__(time)
     full_seconds = 3661.234
     frames = full_seconds * 25
     self.compare(fto, 25, frames, full_seconds, 1, 1, 1, 234)
Beispiel #2
0
 def _moviePositionChanged(self, frame):
     if not self._slider.isSliderDown():
         self._movieFrame = frame
         if frame % self._modulo == 0:
             self._slider.setValue(self._movieFrame)
             fps = self._player.videoData.fps
             ft = FrameTime(fps, frames=frame)
             self._timeLabel.setText(ft.toStr())
Beispiel #3
0
 def offset(self, seconds):
     data = self.data
     fps = data.subtitles.fps
     if fps is None:
         log.error(_("No FPS for '%s' (empty subtitles)." % self.filePath))
         return
     ft = FrameTime(data.subtitles.fps, seconds=seconds)
     data.subtitles.offset(ft)
     command = ChangeData(self.filePath, data,
                          _("Offset by: %s") % ft.toStr())
     self._subtitleData.execute(command)
Beispiel #4
0
 def _sliderActionHandle(self, action):
     if action == QAbstractSlider.SliderPageStepAdd:
         self._player.seek(1.0)
     elif action == QAbstractSlider.SliderPageStepSub:
         self._player.seek(-1.0)
     elif action == QAbstractSlider.SliderSingleStepAdd:
         self.forward()
     elif action == QAbstractSlider.SliderSingleStepSub:
         self.rewind()
     elif action == QAbstractSlider.SliderMove:
         position = self._slider.sliderPosition()
         self._changePosition(position)
         if self._slider.isSliderDown() and self._player.videoData.fps is not None:
             fps = self._player.videoData.fps
             ft = FrameTime(fps, frames=position)
             self._timeLabel.setText(ft.toStr())
Beispiel #5
0
    def offsetSelectedFiles(self, seconds):
        if seconds == 0:
            return

        items = self.__fileList.selectedItems()
        for item in items:
            filePath = item.text(0)
            data = self._subtitleData.data(filePath)
            fps = data.subtitles.fps
            if fps is None:
                log.error(_("No FPS for '%s' (empty subtitles)." % filePath))
                continue
            ft = FrameTime(fps, seconds=seconds)
            data.subtitles.offset(ft)
            command = ChangeData(filePath, data,
                                _("Offset by: %s") % ft.toStr())
            self._subtitleData.execute(command)
Beispiel #6
0
 def test_setSecondsWith100ms(self):
     fto = FrameTime(25, seconds=0)
     full_seconds = 3661.1
     fto.__setSeconds__(full_seconds)
     frames = full_seconds * 25
     self.compare(fto, 25, frames, full_seconds, 1, 1, 1, 100)
Beispiel #7
0
 def test_changeFpsToNegativeValueRaises(self):
     fto = FrameTime(24, time="1:00:01")
     with self.assertRaises(ValueError):
         fto.fps = -1
Beispiel #8
0
 def test_changeFpsToZeroRaises(self):
     fto = FrameTime(25, time="0:00:01")
     with self.assertRaises(ValueError):
         fto.fps = 0
Beispiel #9
0
 def test_changeFpsOkCase(self):
     fto = FrameTime(25, time="0:00:01")
     self.assertEqual(25, fto.frame)
     fto.fps = 31
     self.assertEqual(31, fto.frame)
Beispiel #10
0
 def test_setIncorrectlyFormattedTimeRaisesAnError(self):
     fto = FrameTime(25, time="0:00:00.000")
     with self.assertRaises(ValueError):
         fto.__setTime__("1:12;44-999")
Beispiel #11
0
 def test_setFrameWithNegativeSecondsRaisesAnError(self):
     fto = FrameTime(25, frames=0)
     with self.assertRaises(ValueError):
         fto.__setFrame__(-1)
Beispiel #12
0
 def test_setFrame(self):
     fto = FrameTime(25, frames=0)
     frames = 40120
     fto.__setFrame__(frames)
     full_seconds = frames / 25
     self.compare(fto, 25, frames, full_seconds, 0, 26, 44, 800)
Beispiel #13
0
def test_change_fps_nook(bad_fps):
    ft = FrameTime(25, time="0:00:01")
    with pytest.raises(ValueError):
        ft.fps = bad_fps
    assert ft.fps == 25
Beispiel #14
0
def test_change_fps():
    ft = FrameTime(25, time='0:00:01')
    assert ft.frame == 25
    ft.fps = 31
    assert ft.frame == 31