mpromonet / v4l2rtspserver

RTSP Server for V4L2 device capture supporting HEVC/H264/JPEG/VP8/VP9
The Unlicense
1.82k stars 423 forks source link

RTSP has a delay of few seconds (SOLVED) #231

Closed KVAnton-WEB closed 3 years ago

KVAnton-WEB commented 3 years ago

raspberry pi 3 b and Camera Module v1

video delay of 1-2 seconds (clearly visible to the eye) - is this normal for this solution or am I having some problems? (I would not like to have a visible delay)

I'm testing on a local network, via ethernet, the bitrate is not high. I am connecting via VLC or ffmpeg (ffplay) from ubuntu 20.04 host: ffplay -allowed_media_types video -rtsp_transport udp rtsp://192.168.1.40:8554/unicast vlc rtsp://192.168.1.40:8554/unicast

pi@raspberrypi:~ $ v4l2rtspserver /dev/video0 -W 640 -H 480 -F 25 -v
2021-02-04 14:45:54,838 [INFO  ] - /home/pi/v4l2rtspserver/v4l2wrapper/inc/logger.h:44
        level:INFO
2021-02-04 14:45:54,838 [NOTICE] - /home/pi/v4l2rtspserver/main.cpp:385
        Version: 0.2.1-17-g6005c2f live555 version:2021.01.29
2021-02-04 14:45:54,840 [NOTICE] - /home/pi/v4l2rtspserver/main.cpp:426
        Create V4L2 Source.../dev/video0
2021-02-04 14:45:54,841 [NOTICE] - /home/pi/v4l2rtspserver/v4l2wrapper/src/V4l2Device.cpp:133
        driver:bm2835 mmal capabilities:85200005 mandatory:1000001
2021-02-04 14:45:54,841 [NOTICE] - /home/pi/v4l2rtspserver/v4l2wrapper/src/V4l2Device.cpp:136
        /dev/video0 support capture
2021-02-04 14:45:54,841 [NOTICE] - /home/pi/v4l2rtspserver/v4l2wrapper/src/V4l2Device.cpp:138
        /dev/video0 support read/write
2021-02-04 14:45:54,842 [NOTICE] - /home/pi/v4l2rtspserver/v4l2wrapper/src/V4l2Device.cpp:139
        /dev/video0 support streaming
2021-02-04 14:45:54,844 [NOTICE] - /home/pi/v4l2rtspserver/v4l2wrapper/src/V4l2Device.cpp:215
        /dev/video0:H264 size:640x480 bufferSize:307200
2021-02-04 14:45:54,845 [NOTICE] - /home/pi/v4l2rtspserver/v4l2wrapper/src/V4l2Device.cpp:236
        fps:1/25
2021-02-04 14:45:54,845 [NOTICE] - /home/pi/v4l2rtspserver/v4l2wrapper/src/V4l2Device.cpp:237
        nbBuffer:1
2021-02-04 14:45:54,845 [NOTICE] - /home/pi/v4l2rtspserver/main.cpp:449
        Create Source .../dev/video0
2021-02-04 14:45:54,846 [NOTICE] - /home/pi/v4l2rtspserver/src/DeviceSource.cpp:93
        begin thread
2021-02-04 14:45:54,846 [NOTICE] - /home/pi/v4l2rtspserver/inc/V4l2RTSPServer.h:84
        Play this stream using the URL "rtsp://192.168.1.40:8554/unicast"
2021-02-04 14:45:55,279 [INFO  ] - /home/pi/v4l2rtspserver/src/DeviceSource.cpp:29
        intv_sec:1612449955 fps:1 bandwidth:25kbps
2021-02-04 14:45:55,279 [INFO  ] - /home/pi/v4l2rtspserver/src/H264_V4l2DeviceSource.cpp:39
        SPS size:14 bufSize:3227
2021-02-04 14:45:55,279 [INFO  ] - /home/pi/v4l2rtspserver/src/H264_V4l2DeviceSource.cpp:40
        PPS size:4 bufSize:3219
2021-02-04 14:45:55,279 [INFO  ] - /home/pi/v4l2rtspserver/src/H264_V4l2DeviceSource.cpp:41
        IDR size:3215 bufSize:0
2021-02-04 14:45:56,039 [INFO  ] - /home/pi/v4l2rtspserver/src/DeviceSource.cpp:29
        intv_sec:1612449956 fps:19 bandwidth:545kbps
2021-02-04 14:45:57,002 [INFO  ] - /home/pi/v4l2rtspserver/src/DeviceSource.cpp:29
        intv_sec:1612449957 fps:24 bandwidth:574kbps
2021-02-04 14:45:57,681 [INFO  ] - /home/pi/v4l2rtspserver/src/H264_V4l2DeviceSource.cpp:41
        IDR size:9934 bufSize:0
2021-02-04 14:45:58,038 [INFO  ] - /home/pi/v4l2rtspserver/src/DeviceSource.cpp:29
        intv_sec:1612449958 fps:26 bandwidth:668kbps
RTCPInstance::RTCPInstance error: totSessionBW parameter should not be zero!
2021-02-04 14:45:58,635 [INFO  ] - /home/pi/v4l2rtspserver/src/DeviceSource.cpp:29
        outtv_sec:1612449958 fps:1 bandwidth:22kbps
2021-02-04 14:45:59,004 [INFO  ] - /home/pi/v4l2rtspserver/src/DeviceSource.cpp:29
        outtv_sec:1612449959 fps:19 bandwidth:459kbps
2021-02-04 14:45:59,037 [INFO  ] - /home/pi/v4l2rtspserver/src/DeviceSource.cpp:29
        intv_sec:1612449959 fps:25 bandwidth:598kbps
2021-02-04 14:46:00,001 [INFO  ] - /home/pi/v4l2rtspserver/src/DeviceSource.cpp:29
        outtv_sec:1612449960 fps:25 bandwidth:591kbps
2021-02-04 14:46:00,037 [INFO  ] - /home/pi/v4l2rtspserver/src/DeviceSource.cpp:29
        intv_sec:1612449960 fps:25 bandwidth:592kbps
2021-02-04 14:46:00,080 [INFO  ] - /home/pi/v4l2rtspserver/src/H264_V4l2DeviceSource.cpp:41
        IDR size:9971 bufSize:0
2021-02-04 14:46:01,036 [INFO  ] - /home/pi/v4l2rtspserver/src/DeviceSource.cpp:29
        intv_sec:1612449961 fps:25 bandwidth:678kbps
2021-02-04 14:46:01,038 [INFO  ] - /home/pi/v4l2rtspserver/src/DeviceSource.cpp:29
        outtv_sec:1612449961 fps:28 bandwidth:700kbps
2021-02-04 14:46:02,001 [INFO  ] - /home/pi/v4l2rtspserver/src/DeviceSource.cpp:29
        outtv_sec:1612449962 fps:24 bandwidth:623kbps
2021-02-04 14:46:02,033 [INFO  ] - /home/pi/v4l2rtspserver/src/DeviceSource.cpp:29
        intv_sec:1612449962 fps:25 bandwidth:646kbps
2021-02-04 14:46:02,475 [INFO  ] - /home/pi/v4l2rtspserver/src/H264_V4l2DeviceSource.cpp:41
        IDR size:10135 bufSize:0
2021-02-04 14:46:03,005 [INFO  ] - /home/pi/v4l2rtspserver/src/DeviceSource.cpp:29
        outtv_sec:1612449963 fps:27 bandwidth:648kbps
2021-02-04 14:46:03,035 [INFO  ] - /home/pi/v4l2rtspserver/src/DeviceSource.cpp:29
        intv_sec:1612449963 fps:25 bandwidth:649kbps
2021-02-04 14:46:04,000 [INFO  ] - /home/pi/v4l2rtspserver/src/DeviceSource.cpp:29
        outtv_sec:1612449964 fps:25 bandwidth:608kbps
2021-02-04 14:46:04,035 [INFO  ] - /home/pi/v4l2rtspserver/src/DeviceSource.cpp:29
        intv_sec:1612449964 fps:25 bandwidth:608kbps
KVAnton-WEB commented 3 years ago

ffplay -framedrop -fflags nobuffer -flags low_delay -sync video -an -allowed_media_types video -rtsp_transport udp rtsp://192.168.1.40:8554/unicast

ok, solved the problem, this is the playback buffer on the host, can anyone help too. now I have about 100-150 ms