Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The delay in webrtc streaming is very obvious #6

Open
guozanhua opened this issue Jun 19, 2024 · 1 comment
Open

The delay in webrtc streaming is very obvious #6

guozanhua opened this issue Jun 19, 2024 · 1 comment

Comments

@guozanhua
Copy link

reference below video,left windows is video capture game windows, right is the user side window, and test in a same machine,use 127.0.0.1, the latency is very obvious,it seems that push frequency is too low, is there anywhere to config push rate or frequency

stream-play-server.mp4
@delcourtfl
Copy link
Owner

Hello,

Is the Audio disabled in your test ? If not, disabling it might help reduce the latency (it's a known issue that I haven't been able to fix in the past).

If the stream is Video-only, the issue could come from the WebRTC browser/server configuration, which needs some parameter adjustements (and could cause buffering) :

stream-play-server/webserver/client/connect.js

    if (testVideoButton) {
        peerConnection.addTransceiver('video', {'direction': 'recvonly'})
        // Additional parameters can be added to the transceiver (bitrate, framerate, constraints...)
    }

Alternatively, it might be caused by the FFMPEG configuration :

stream-play-server/media-server/capture.go

	// Start FFMPEG process to generate raw video frames
	ffmpegCmdVideo, err = launchCommand(
		"ffmpeg",
		[]string{
			"-stats_period", "10",
			"-f", "gdigrab",
			"-thread_queue_size", "1024",
			"-framerate", "30",
			"-i", "title="+windowTitle,
			"-vf", "scale=-1:720",
			"-c:v", "libx264",
			"-preset", "ultrafast",
			"-tune", "zerolatency",
			"-crf", "25",
			"-pix_fmt", "yuv420p",
			"-an",
			"-f", "rtp", "rtp://127.0.0.1:5004?pkt_size=1200",
		},
		"../logs/video.log",
	)
	if err != nil {
		panic(err)
	}

The current implementation is far from perfect, so if you find any configurations that produce better results, don't hesitate to share them !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants