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

I want to keep the remaining buffer constant. #6622

Closed
brodiddev opened this issue May 16, 2024 · 4 comments
Closed

I want to keep the remaining buffer constant. #6622

brodiddev opened this issue May 16, 2024 · 4 comments
Labels
type: question A question from the community

Comments

@brodiddev
Copy link

Have you read the Tutorials?
yes

Have you read the FAQ and checked for duplicate open issues?
yes

If the question is related to FairPlay, have you read the tutorial?

yes

What version of Shaka Player are you using?
4.8.4

What browser and OS are you using?
window chrome

Please ask your question
I want to keep the remaining buffer constant.
leftFormatted in the code below is currently staying at 5-6 seconds.

I want to keep it at 3-4 seconds, so how about adjusting liveSegmentsDelay to 2 if the remaining buffer (leftFormatted) is more than 5, and 4 if it is less than 2?

Is there a better way?

leftBuffer

	calculateBufferedInfo(videoElement) {
		const position = videoElement.currentTime;
		let bufferedInfo = { total: 0, played: 0, left: 0 };

		for (let i = 0; i < videoElement.buffered.length; i++) {
			const start = videoElement.buffered.start(i);
			const end = videoElement.buffered.end(i);
			const duration = end - start;

			if (start <= position && end > position) {
				bufferedInfo.played += Math.max(0, position - start);
				bufferedInfo.left += Math.max(0, end - position);
			} else if (start > position) {
				bufferedInfo.left += duration;
			} else {
				bufferedInfo.played += duration;
			}

			bufferedInfo.total += duration;
		}
		const leftFormatted = bufferedInfo.left.toFixed(3);
		const playedFormatted = bufferedInfo.played.toFixed(3);
		const totalFormatted = bufferedInfo.total.toFixed(3);

		return { leftFormatted, playedFormatted, totalFormatted };
	}

config

		abr: { enabled: false },
		streaming: {
			rebufferingGoal: 2,
			bufferingGoal: 10,
			bufferBehind: 30,
            }
@brodiddev brodiddev added the type: question A question from the community label May 16, 2024
@joeyparrish
Copy link
Member

I want to keep the remaining buffer constant.

How strictly do you expect "constant" to be? Shaka downloads whole segments by default, so you can be at your target +/- (segment length + network delay).

@avelad avelad added the status: waiting on response Waiting on a response from the reporter(s) of the issue label May 21, 2024
@brodiddev
Copy link
Author

brodiddev commented May 21, 2024

Can I use liveSyncMinLatency and liveSyncMaxLatency to set the settings below to keep the remaining buffer between 2 and 2.5 seconds?

streaming: {
rebufferingGoal: 2;
bufferingGoal: 5,
useNativeHlsOnSafari: true;
lowLatencyMode: true,
liveSync: true;
liveSyncMaxLatency: 2.5,
liveSyncMinLatency: 2,
},
manifest: {
hls: {
liveSegmentsDelay: 1.5,
},
},
#EXTM3U
#EXT-X-VERSION:7
#EXT-X-TARGETDURATION:2
#EXT-X-MEDIA-SEQUENCE:19373
#EXT-X-MAP:URI="https://test.com/a69cf780-4d6c-4722-9473-d5be143585b4/brodi/pF86M5TirQgf3KmVjSWBF8QHyNWDh26McsGGQYC3eRHCk3Jt9fKp30yvBNS4ksArSjZ57EPqyUKd-J0sm5VbzA==/video/1920x1080/surplus.m4s"
#EXT-X-PROGRAM-DATE-TIME:2024-05-21T07:49:17.027Z
#EXTINF:1,
https://test.com/a69cf780-4d6c-4722-9473-d5be143585b4/brodi/pF86M5TirQgf3KmVjSWBF8QHyNWDh26McsGGQYC3eRHCk3Jt9fKp30yvBNS4ksArSjZ57EPqyUKd-J0sm5VbzA==/video/1920x1080/19373.mp4v
#EXT-X-PROGRAM-DATE-TIME:2024-05-21T07:49:18.027Z
#EXTINF:1,
https://test.com/a69cf780-4d6c-4722-9473-d5be143585b4/brodi/pF86M5TirQgf3KmVjSWBF8QHyNWDh26McsGGQYC3eRHCk3Jt9fKp30yvBNS4ksArSjZ57EPqyUKd-J0sm5VbzA==/video/1920x1080/19374.mp4v
#EXT-X-PROGRAM-DATE-TIME:2024-05-21T07:49:19.027Z
#EXTINF:1,
https://test.com/a69cf780-4d6c-4722-9473-d5be143585b4/brodi/pF86M5TirQgf3KmVjSWBF8QHyNWDh26McsGGQYC3eRHCk3Jt9fKp30yvBNS4ksArSjZ57EPqyUKd-J0sm5VbzA==/video/1920x1080/19375.mp4v
#EXT-X-PROGRAM-DATE-TIME:2024-05-21T07:49:20.027Z
#EXTINF:1,
https://test.com/a69cf780-4d6c-4722-9473-d5be143585b4/brodi/pF86M5TirQgf3KmVjSWBF8QHyNWDh26McsGGQYC3eRHCk3Jt9fKp30yvBNS4ksArSjZ57EPqyUKd-J0sm5VbzA==/video/1920x1080/19376.mp4v
#EXT-X-PROGRAM-DATE-TIME:2024-05-21T07:49:21.027Z
#EXTINF:1,
https://test.com/a69cf780-4d6c-4722-9473-d5be143585b4/brodi/pF86M5TirQgf3KmVjSWBF8QHyNWDh26McsGGQYC3eRHCk3Jt9fKp30yvBNS4ksArSjZ57EPqyUKd-J0sm5VbzA==/video/1920x1080/19377.mp4v

@shaka-bot shaka-bot removed the status: waiting on response Waiting on a response from the reporter(s) of the issue label May 21, 2024
@joeyparrish
Copy link
Member

Seems reasonable

@avelad avelad added the status: waiting on response Waiting on a response from the reporter(s) of the issue label May 23, 2024
@brodiddev
Copy link
Author

many thanks :)

@avelad avelad closed this as completed May 27, 2024
@shaka-bot shaka-bot removed the status: waiting on response Waiting on a response from the reporter(s) of the issue label May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question A question from the community
Projects
None yet
Development

No branches or pull requests

4 participants