Use the -sync flag to adjust video synchronization. Setting it to video forces FFplay to sync with the video stream, which can help with reducing latency.
Example command:
- ffplay -rtsp_transport udp -fflags nobuffer -analyzeduration 0 -probesize 32 -sync video rtsp://192.168.1.120:554/live/1_0
5. Reduce Video and Audio Buffering
Disable or minimize audio playback with -vn (no video) or adjust audio buffer sizes using -an (no audio) if audio is not necessary for the test.
Example:
- ffplay -rtsp_transport udp -fflags nobuffer -analyzeduration 0 -probesize 32 -sync video -an rtsp://192.168.1.120:554/live/1_0
6. Fine-tune Decoding Options
Add options to optimize decoding performance and minimize latency. For instance:
- ffplay -rtsp_transport udp -fflags nobuffer -analyzeduration 0 -probesize 32 -sync video -an -flags low_delay rtsp://192.168.1.120:554/live/1_0
7. Additional Optimizations (Optional)
You can further tune FFplay by using -x and -y flags to specify the size of the video window, and -framedrop to discard frames if they can't be processed quickly enough:
- ffplay -rtsp_transport udp -fflags nobuffer -analyzeduration 0 -probesize 32 -sync video -an -framedrop -flags low_delay -x 640 -y 360 rtsp://192.168.1.120:554/live/1_0
Explanation:
-framedrop
: Drops frames when the system can't keep up with decoding, reducing buffering.
- -x 640 -y 360: Specifies the resolution to play the video, reducing the decoding workload.
Final Command Example
- ffplay -rtsp_transport udp -fflags nobuffer -analyzeduration 0 -probesize 32 -sync video -an -framedrop -flags low_delay -x 640 -y 360 rtsp://192.168.1.120:554/live/1_0
8. Monitor Latency
After setting up, monitor the playback to observe the reduction in latency. You can use tools like FFprobe to measure latency in real-time by inspecting stream details.
Example FFprobe command to check the stream’s stats:
- ffprobe -v quiet -print_format json -show_streams rtsp://192.168.1.120:554/live/1_0
By using the above commands and tweaking the various flags, you can effectively reduce the latency when testing the RTSP stream from your video encoder.