Читать поток RTSP в Python - PullRequest
       8

Читать поток RTSP в Python

0 голосов
/ 15 апреля 2020

Я хочу читать поток RTSP с низкой задержкой. Я использую этот код чтения кадров в 100 мс ~ 200 мс. Но эта команда иногда не будет работать при перезапуске программы. Есть четыре подпроцесса, которые читают поток, 3 успешны, а 1 - нет. Моя команда неверна?

ffmpeg_cmd = ["ffmpeg", "-v", "debug", "-y",
                        "-skip_initial_bytes", "2000000",
                        "-c:v",  "h264",
                        "-vsync", "1",
                        "-flags", "low_delay",
                        "-fflags", "nobuffer",
                        "-analyzeduration", "100000",
                        "-max_delay", "100000",
                        "-reorder_queue_size", "10000",
                        "-rtsp_transport", "tcp",
                        "-i", "rtsp://xx:xx@ip/streaming/channels/101",
                        "-s", "1280x720",
                        "-preset", "ultrafast",
                        "-tune", "zerolatency",
                        "-f", "image2pipe",
                        "-pix_fmt", "rgb24",
                        "-vcodec", "rawvideo",
                        "-r", "25",
                        "-"]
ffmpeg = sp.Popen(ffmpeg_cmd, stdout=sp.PIPE, bufsize=1024)
x = ffmpeg.stdout.read(int(w*h*3))

Сообщение об ошибке:

Codec AVOption preset (Configuration preset) specified for output file #0 (pipe:) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
Codec AVOption tune (Tune the encoding to a specific scenario) specified for output file #0 (pipe:) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
detected 48 logical cores
Past duration 0.914436 too large
[h264 @ 0x55a59a5b8500] nal_unit_type: 7(SPS), nal_ref_idc: 3
[h264 @ 0x55a59a5b8500] nal_unit_type: 8(PPS), nal_ref_idc: 3
Clipping frame in rate conversion by 0.339165
[h264 @ 0x55a59a5b8500] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
[h264 @ 0x55a59a5b8500] Format yuvj420p chosen by get_format().
[h264 @ 0x55a59a5b8500] Reinit context to 1920x1088, pix_fmt: yuvj420p
[h264 @ 0x55a59a5b8500] Frame num gap 6 4
[h264 @ 0x55e256eef5c0] nal_unit_type: 7(SPS), nal_ref_idc: 3
[h264 @ 0x55e256eef5c0] nal_unit_type: 8(PPS), nal_ref_idc: 3
[h264 @ 0x55e256eef5c0] nal_unit_type: 5(IDR), nal_ref_idc: 3
[h264 @ 0x5649ea893700] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 3
    Last message repeated 3 times
[rtsp @ 0x5626b5bd85c0] max_analyze_duration 100000 reached at 120000 microseconds st:0
[rtsp @ 0x5626b5bd85c0] decoding for stream 0 failed
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...