Skip to content

Conversation

fkwp
Copy link
Contributor

@fkwp fkwp commented Jun 18, 2025

Recent research has confirmed that the number of devices lacking H.264 decoding capabilities is negligible.

In contrast, many modern devices come equipped with native H.264 encoders and decoders. By switching to the H.264 codec, we can significantly reduce CPU usage. Especially mobile devices will benefit, where it can lead to better battery life.

Furthermore, we add a 540p simulcast video layer.

fixes #3166 #2579 #2373

Current state

H264 video is still broken on iOS — other participants won’t receive video from an iOS device. This happens when the iOS device is the first to join a LiveKit room and starts streaming H264.

However, it's working if a non-iOS client is already streaming H264 before the iOS device joins. Note Using VP8 on the other client does not fix the issue — it must be H264.

@fkwp fkwp requested a review from a team as a code owner June 18, 2025 14:49
@fkwp fkwp requested a review from BillCarsonFr June 18, 2025 14:49
@fkwp fkwp added the PR-Improvement Release note category. A PR that improves EC's performance or stability. label Jun 18, 2025
@fkwp fkwp changed the title Changing the video codec from VP8 to H264 Changing the video codec from VP8 to H.264 Jun 18, 2025
@fkwp fkwp marked this pull request as draft June 18, 2025 15:13
@fkwp fkwp marked this pull request as draft June 18, 2025 15:13
Comment on lines 26 to 36
videoSimulcastLayers: [
VideoPresets.h180,
VideoPresets.h360,
VideoPresets.h540,
] as VideoPreset[],
Copy link

@spaetz spaetz Jun 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be misunderstanding the livekit docs. But can we actually hand it three presets here? Livekit docs stated up to 2 custom layers. Or are those standard preset no custom layers?

videoSimulcastLayers: [VideoPreset]

custom video simulcast layers for camera tracks, defaults to h180, h360, h540.
You can specify**up to two custom layers** that will be used instead of the LiveKit default layers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope its limited to three in total including the base layer.

Copy link
Member

@BillCarsonFr BillCarsonFr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small comment regarding the loglevel

@@ -29,7 +29,7 @@ window.setLKLogLevel = setLKLogLevel;
initRageshake().catch((e) => {
logger.error("Failed to initialize rageshake", e);
});
setLKLogLevel("info");
setLKLogLevel("debug");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this on purpose? or a left over of a dev setup?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is part of debugging why h264 with simulcast is not working on iOS devices.

VideoPresets,
} from "livekit-client";

const VideoPresetsH264 = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what makes this specific H264 presets? Aren't those just regular presets that could also be used with other encordings?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this PR is in draft -- this is part of debugging why h264 with simulcast is not working on iOS devices.

using h264 specific presets help finding out if the h264 macro-block constraint is the problem here.

Comment on lines 37 to 38
VideoPresetsH264.h144,
VideoPresets.h360,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the mixture of VideoPresetsH264 and VideoPresets?

@toger5
Copy link
Contributor

toger5 commented Aug 5, 2025

What is the status on this one? Can the OP get a description what this is blocked by. (I do remember some device specific issues where some resolution just were not send at all?)

@fkwp
Copy link
Contributor Author

fkwp commented Aug 5, 2025

What is the status on this one? Can we OP get a description what this is blocked by. (I do remember some device specific issues where some resolution just were not send at all?)

H264 video is still broken on iOS — other participants won’t receive video from an iOS device. This happens when the iOS device is the first to join a LiveKit room and starts streaming H264.

However, it's working if a non-iOS client is already streaming H264 before the iOS device joins. Note Using VP8 on the other client does not fix the issue — it must be H264.

@toger5
Copy link
Contributor

toger5 commented Aug 6, 2025

Test on safari on mac os works.
(to make sure its ios and not safari in general

screenShareEncoding: ScreenSharePresets.h1080fps30.encoding,
stopMicTrackOnMute: false,
videoCodec: "vp8",
videoCodec: "h264",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
videoCodec: "h264",
videoCodec: platform === "ios" || !useH264Setting ? "vp8" : "h264",

Adding a dev setting for using h264 would allow merging this and would provide us more data on how this behaves in real live.

Let me know if I should update this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fkwp any thoughts on this? This would also be nice to have in the 15 release ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-Improvement Release note category. A PR that improves EC's performance or stability.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Selected video resolution often not that great (EC defaults lower than livekit defaults)
4 participants