Currently, I am trying to use python with FFmpeg to query rtsp data which the original format is h264.
The information of the live stream video is, fps:29; resolution: 1280*720.
I wish that I can query the data as the same format "h264" and put into a python queue in order to the future use.
Here is my code:
class CCTVReader(threading.Thread):
def __init__(self, queue, URL, fps=29):
super().__init__()
self.queue = queue
self.command = ["ffmpeg", "-y",
"-hwaccel", "nvdec",
"-c:v", "h264_cuvid",
"-vsync", "0",
"-max_delay", "500000",
"-reorder_queue_size", "10000",
"-i", "rtsp://xxx.xxx.xxx.xxx:xxx/Streaming/Channels/101?transportmode=multicast",
"-pix_fmt", "yuv420p",
"-preset", "slow",
"-an", "-sn",
"-vf", "fps=29",
"-"]
def run(self):
pipe = sp.Popen(self.command, stdout = sp.PIPE, bufsize=1024**3, shell=True)
timer = time.time()
counter = 0
while True:
self.queue.put(pipe.stdout.read(int(1280*720*6//4)))
However, after I run this program about 10 second, my console shows the warning message:
[rtsp @ 0000020be0fbb9c0] max delay reached. need to consume packet
[rtsp @ 0000020be0fbb9c0] RTP: missed 127 packets
It seems like my command doesn't type appropriately.
Could you kindly give me some suggestion about how to deal with this problem?
Thank you very much