faint-cartoon-29510
08/10/2025, 8:06 AMtall-airline-16756
08/10/2025, 8:06 AMtall-airline-16756
08/10/2025, 8:06 AMVideoParametersPresets.h720_169
(which is 1280x720 at 30fps with a 450 kbps bitrate) for a great balance of quality and performance.
• Room Configuration: Make sure to enable adaptive streaming and dynacast in `RoomOptions`—this helps keep your video smooth even if the network gets a bit shaky:
final roomOptions = RoomOptions(
adaptiveStream: true,
dynacast: true,
);
• Video Track Publishing: When creating and publishing your video tracks, use LocalVideoTrack
with these settings to get things just right:
final videoTrack = await LocalVideoTrack.createCameraTrack(
options: CameraCaptureOptions(
cameraPosition: CameraPosition.front,
params: VideoParameters(
dimensions: VideoDimensions(1280, 720),
encoding: VideoEncoding(
maxBitrate: 450 * 1000,
maxFramerate: 30,
),
),
),
);
await room.localParticipant.publishVideoTrack(videoTrack);
• Platform-Specific Configurations: For iOS, don’t forget to update your Info.plist
with camera and microphone usage descriptions. On Android, make sure your AndroidManifest.xml
includes permissions for camera and audio.
• Screen Sharing: If you’re adding screen sharing, use ScreenShareCaptureOptions
with optimized settings like VideoParametersPresets.screenShareH720FPS15
to keep things smooth.
• Audio Configuration: Use the communication
audio mode—it’s perfect for two-way voice chats.
• Performance Considerations: To get the best encoding settings based on the device and network, try using computeVideoEncodings
.
These tweaks should help your app deliver awesome video quality and performance. If you have any questions or want to dive deeper, just let me know—I’m here to help!
Sources: Swift & iOS SDK | livekit/livekit_composite | DeepWiki | lib/src/utils.dartfaint-cartoon-29510
08/10/2025, 8:07 AMtall-airline-16756
08/10/2025, 8:07 AMimport 'package:livekit_client/livekit_client.dart';
void main() async {
// Connect to the LiveKit server
final room = await LiveKit.connect(
'YOUR_SERVER_URL',
'YOUR_ACCESS_TOKEN',
roomOptions: RoomOptions(
adaptiveStream: true,
dynacast: true,
),
);
// Create and publish a video track
final videoTrack = await LocalVideoTrack.createCameraTrack(
options: CameraCaptureOptions(
cameraPosition: CameraPosition.front, // Use front or back camera
params: VideoParameters(
dimensions: VideoDimensions(1280, 720), // 720p resolution
encoding: VideoEncoding(
maxBitrate: 450 * 1000, // 450 kbps
maxFramerate: 30, // 30 fps
),
),
),
);
await room.localParticipant.publishVideoTrack(videoTrack);
// Handle room events
room.onParticipantConnected = (participant) {
print('Participant connected: ${participant.identity}');
};
room.onParticipantDisconnected = (participant) {
print('Participant disconnected: ${participant.identity}');
};
}
Just swap out YOUR_SERVER_URL
and YOUR_ACCESS_TOKEN
with your actual LiveKit server URL and access token. This setup connects you to the server, turns on adaptive streaming, and publishes a crisp 720p video track using your front camera.
If you have any questions or want me to walk you through more examples, just let me know—I’m here to help!faint-cartoon-29510
08/10/2025, 8:08 AMtall-airline-16756
08/10/2025, 8:08 AMVideoParametersPresets.h720_169 // 1280x720 @ 30fps, 450 kbps bitrate
VideoParametersPresets.h1080_169 // 1920x1080 @ 30fps, 3 Mbps bitrate
• Room Configuration: To boost performance, enable adaptive streaming and dynacast like this:
final roomOptions = RoomOptions(
adaptiveStream: true,
dynacast: true,
);
• Video Track Publishing: Here’s how to set up and publish a video track with optimal settings:
final videoTrack = await LocalVideoTrack.createCameraTrack(
options: CameraCaptureOptions(
cameraPosition: CameraPosition.front, // or CameraPosition.back
params: VideoParameters(
dimensions: VideoDimensions(1280, 720),
encoding: VideoEncoding(
maxBitrate: 450 * 1000, // 450 kbps
maxFramerate: 30, // 30 fps
),
),
),
);
await room.localParticipant.publishVideoTrack(videoTrack);
• Platform-Specific Configurations:
• iOS: Don’t forget to add these keys to your Info.plist
to keep things smooth:
<key>NSCameraUsageDescription</key>
<string>$(PRODUCT_NAME) uses your camera</string>
<key>NSMicrophoneUsageDescription</key>
<string>$(PRODUCT_NAME) uses your microphone</string>
• Also, make sure to enable the "Audio, AirPlay, and Picture in Picture" background mode in Xcode.
• Android: Add these permissions to your `AndroidManifest.xml`:
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
• If you’re using Bluetooth audio devices, don’t forget to request Bluetooth permissions too.
• Screen Sharing: For screen sharing, use these optimized settings:
final screenShareTrack = await LocalVideoTrack.createScreenShareTrack(
options: ScreenShareCaptureOptions(
params: VideoParametersPresets.screenShareH720FPS15,
),
);
• Audio Configuration: To get clear two-way voice communication, use the communication
audio mode like this:
await webrtc.WebRTC.initialize(options: {
'androidAudioConfiguration': webrtc.AndroidAudioConfiguration.communication.toMap(),
});
• Focus and Exposure: You can configure the camera focus and exposure modes for the best video quality:
CameraCaptureOptions(
focusMode: CameraFocusMode.auto,
exposureMode: CameraExposureMode.auto,
);
• Performance Considerations: It’s a great idea to automatically adjust encoding settings based on the device and network conditions, like this:
var encodings = Utils.computeVideoEncodings(
isScreenShare: track.source == TrackSource.screenShareVideo,
dimensions: dimensions,
options: publishOptions,
codec: publishOptions.videoCodec,
);
• Testing: Finally, try testing your app on different devices with varying hardware capabilities. For older devices, lowering the video resolution and framerate can really help keep things smooth.
By following these tips, your app will deliver awesome video quality and smooth performance on both Android and iOS. If you run into any questions or need a hand, just let me know—I’m here to help!faint-cartoon-29510
08/10/2025, 8:20 AMtall-airline-16756
08/10/2025, 8:20 AMVideoParametersPresets.h720_169 // 1280x720 @ 30fps, 450 kbps bitrate
VideoParametersPresets.h1080_169 // 1920x1080 @ 30fps, 3 Mbps bitrate
• Room Configuration: For better performance, it’s great to enable adaptive streaming and dynacast:
final roomOptions = RoomOptions(
adaptiveStream: true,
dynacast: true,
);
• Video Track Publishing: Here’s how to set up and publish a video track with the best settings:
final videoTrack = await LocalVideoTrack.createCameraTrack(
options: CameraCaptureOptions(
cameraPosition: CameraPosition.front, // or CameraPosition.back
params: VideoParameters(
dimensions: VideoDimensions(1280, 720),
encoding: VideoEncoding(
maxBitrate: 450 * 1000, // 450 kbps
maxFramerate: 30, // 30 fps
),
),
),
);
await room.localParticipant.publishVideoTrack(videoTrack);
• Android-Specific Configurations:
• Don’t forget to add these permissions to your `AndroidManifest.xml`:
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
• If you’re using Bluetooth audio devices, make sure to request those permissions too.
• Audio Configuration: For clear two-way voice communication, use the communication
audio mode like this:
await webrtc.WebRTC.initialize(options: {
'androidAudioConfiguration': webrtc.AndroidAudioConfiguration.communication.toMap(),
});
• Screen Sharing: When sharing your screen, these optimized settings will help:
final screenShareTrack = await LocalVideoTrack.createScreenShareTrack(
options: ScreenShareCaptureOptions(
params: VideoParametersPresets.screenShareH720FPS15,
),
);
• Focus and Exposure: It’s a good idea to configure your camera’s focus and exposure modes like this:
CameraCaptureOptions(
focusMode: CameraFocusMode.auto,
exposureMode: CameraExposureMode.auto,
);
• Performance Considerations: To get the best encoding based on the device and network, you can automatically compute settings like this:
var encodings = Utils.computeVideoEncodings(
isScreenShare: track.source == TrackSource.screenShareVideo,
dimensions: dimensions,
options: publishOptions,
codec: publishOptions.videoCodec,
);
These tips are tailored for Android to help you get the best video quality and performance. If you want to chat more or need a hand with anything else, just let me know!faint-cartoon-29510
08/10/2025, 8:40 AMtall-airline-16756
08/10/2025, 8:40 AMVideoDimensionsPresets
class, and you can pair them with VideoParametersPresets
to get the best results. For instance, using h720_169
(1280x720) is a great choice for high-quality video streaming.
If you want, I’m here to help with more details or examples—just let me know!faint-cartoon-29510
08/10/2025, 8:44 AMdimensions: VideoDimensions(1280, 720),
encoding: VideoEncoding(
maxBitrate: 450 * 1000, // 450 kbps
maxFramerate: 60, // 30 fps
),
i want to be high resolutiontall-airline-16756
08/10/2025, 8:44 AMdimensions: VideoDimensions(1920, 1080), // Full HD resolution
encoding: VideoEncoding(
maxBitrate: 3000 * 1000, // 3 Mbps for higher quality
maxFramerate: 60, // 60 fps for smoother video
),
This setup bumps your video to 1920x1080 (Full HD) with a nice 3 Mbps bitrate and a max framerate of 60 fps, which should give you smoother, better-looking video. Just double-check that your network and device can keep up with these settings so everything runs smoothly.
If you have any questions or want me to walk you through it, just let me know—I’m here to help!