jaseg / python-mpv

Python interface to the awesome mpv media player
https://git.jaseg.de/python-mpv.git
Other
550 stars 68 forks source link

cache is too long #250

Closed penghongguang closed 1 year ago

penghongguang commented 1 year ago

when I use mpv to play a network stream, the player only begin to play when the stream is over, and the solution I found such as set demuxer-cache-time is invalid. the code is as follow:

import sys
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
import mpv

class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()

        self.widget = QWidget(self)
        self.widget.setFixedSize(960,540)
        self.widget.setAttribute(Qt.WA_DontCreateNativeAncestors)
        self.widget.setAttribute(Qt.WA_NativeWindow)
        self.setCentralWidget(self.widget)

        self.playVedio('http://10.12.53.227:8080/')

    def playVedio(self, address):
        self.player = mpv.MPV(wid=str(int(self.widget.winId())))
        # self.player._set_property('demuxer-cache-time', 1.0)
        # self.player._set_property('demuxer-max-bytes', 1000000)
        # self.player._set_property('cache-seek-min', 0.1)
        # self.player.cache_secs =  3.0
        self.player.play(address)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    w = MainWindow()
    w.show()
    sys.exit(app.exec_())

what can I do to play a realtime network stream?

jaseg commented 1 year ago

python-mpv is only a thin wrapper around libmpv. All the stream caching logic is inside libmpv, not python-mpv, so you may find the issue tracker of libmpv/mpv at https://github.com/mpv-player/mpv/issues more useful. You aren't the first person with this issue, so you could try seraching python-mpv's issue archives too. Also perhaps check out some projects using python-mpv using github's search function. I know there are a few internet radio/stream players among those. Maybe you can find a solution in one of them.