How to use the ffpyplayer.player.MediaPlayer function in ffpyplayer

To help you get started, we’ve selected a few ffpyplayer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github BillBillBillBill / Tickeys-linux / tickeys / kivy / core / audio / audio_ffpyplayer.py View on Github external
def load(self):
        self.unload()
        ff_opts = {'vn': True, 'sn': True}  # only audio
        self._ffplayer = MediaPlayer(self.source,
                                     callback=self._callback_ref,
                                     loglevel='info', ff_opts=ff_opts)
        player = self._ffplayer
        player.set_volume(self.volume)
        player.toggle_pause()
        self._state = 'paused'
        # wait until loaded or failed, shouldn't take long, but just to make
        # sure metadata is available.
        s = time.clock()
        while ((not player.get_metadata()['duration'])
               and not self.quitted and time.clock() - s < 10.):
            time.sleep(0.005)
github snuq / Snu-Photo-Manager / generalelements.py View on Github external
def open_video(self):
        self.player = MediaPlayer(self.source, ff_opts={'paused': True, 'ss': 1.0, 'an': True})
        frame = None
        while not frame:
            frame, value = self.player.get_frame(force_refresh=True)
        data = self.player.get_metadata()
        self.length = data['duration']
        self.framerate = data['frame_rate']
        self.pixel_format = data['src_pix_fmt']
github snuq / Snu-Photo-Manager / main.py View on Github external
extension = os.path.splitext(fullpath)[1].lower()

        try:
            if extension in imagetypes:
                #This is an image file, use PIL to generate a thumnail
                image = Image.open(full_filename)
                image.thumbnail((self.thumbsize, self.thumbsize), Image.ANTIALIAS)
                if image.mode != 'RGB':
                    image = image.convert('RGB')
                output = BytesIO()
                image.save(output, 'jpeg')
                thumbnail = output.getvalue()

            elif extension in movietypes:
                #This is a video file, use ffpyplayer to generate a thumbnail
                player = MediaPlayer(full_filename, ff_opts={'paused': True, 'ss': 1.0, 'an': True})
                frame = None
                while not frame:
                    frame, value = player.get_frame(force_refresh=True)
                player.close_player()
                player = None
                frame = frame[0]
                frame_size = frame.get_size()
                frame_converter = SWScale(frame_size[0], frame_size[1], frame.get_pixel_format(), ofmt='rgb24')
                new_frame = frame_converter.scale(frame)
                image_data = bytes(new_frame.to_bytearray()[0])

                image = Image.frombuffer(mode='RGB', size=(frame_size[0], frame_size[1]), data=image_data, decoder_name='raw')
                image = image.transpose(1)

                image.thumbnail((self.thumbsize, self.thumbsize), Image.ANTIALIAS)
                output = BytesIO()
github kivy / kivy / kivy / core / audio / audio_ffpyplayer.py View on Github external
def load(self):
        self.unload()
        ff_opts = {'vn': True, 'sn': True}  # only audio
        self._ffplayer = MediaPlayer(self.source,
                                     callback=self._player_callback,
                                     loglevel='info', ff_opts=ff_opts)
        player = self._ffplayer
        player.set_volume(self.volume)
        player.toggle_pause()
        self._state = 'paused'
        # wait until loaded or failed, shouldn't take long, but just to make
        # sure metadata is available.
        s = time.perf_counter()
        while ((not player.get_metadata()['duration']) and
               not self.quitted and time.perf_counter() - s < 10.):
            time.sleep(0.005)
github kivy / kivy / kivy / core / video / video_ffpyplayer.py View on Github external
def play(self):
        if self._ffplayer and self._state == 'paused':
            self._ffplayer.toggle_pause()
            self._state = 'playing'
            return

        self.load()
        self._out_fmt = 'rgba'
        ff_opts = {
            'paused': True,
            'out_fmt': self._out_fmt,
            'sn': True,
            'volume': self._volume,
        }
        self._ffplayer = MediaPlayer(
                self._filename, callback=self._player_callback,
                thread_lib='SDL',
                loglevel='info', ff_opts=ff_opts)

        # Disabled as an attempt to fix kivy issue #6210
        # self._ffplayer.set_volume(self._volume)

        self._thread = Thread(target=self._next_frame_run, name='Next frame')
        self._thread.daemon = True
        self._thread.start()

ffpyplayer

A cython implementation of an ffmpeg based player.

LGPL-3.0
Latest version published 23 days ago

Package Health Score

61 / 100
Full package analysis

Similar packages