Skip to main content

select/
select.rs

1use video_levels::hevc::{Level, LevelSelector, Profile, Tier};
2pub fn main() {
3    // Find the level that supports 1920x1080 resolution at 60fps.
4    let level = LevelSelector::new()
5        .width(1920)
6        .height(1080)
7        .framerate(60.0)
8        .tier(Tier::Main)
9        .profile(Profile::Main)
10        .select();
11
12    println!("Level: {:?}", level.unwrap().id());
13
14    // Sometimes you are bound to the what the hardware encoder supports.
15    // You can define the clamp to search within a range.
16    // In this case, we are looking for a level that supports 3840x2160 resolution at 60fps.
17    let level = LevelSelector::new()
18        .width(3840)
19        .height(2160)
20        .framerate(60.0)
21        .tier(Tier::Main)
22        .profile(Profile::Main)
23        // Clamping between L4 and L5.2
24        .clamp(Level::L4, Level::L5_2)
25        .select();
26
27    println!("Level: {:?}", level.unwrap().id());
28}