File size: 723 Bytes
d948455
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Frame rates for different model types
MODEL_FRAME_RATES = {
    "wanvideo": 16,  # WanVideo models use 16 fps
    "hunyuan": 24    # Hunyuan models use 24 fps
}

def calculate_frames(duration, frame_rate):
    """
    Calculate frames ensuring they follow the 4K+1 pattern
    Args:
        duration: Video duration in seconds
        frame_rate: Frames per second
    Returns:
        int: Number of frames following 4K+1 pattern
    """
    # Calculate raw frames
    raw_frames = round(duration * frame_rate)
    
    # Adjust to nearest 4K+1 value
    # First, find the nearest multiple of 4
    nearest_multiple_of_4 = round(raw_frames / 4) * 4
    
    # Then add 1 to get 4K+1
    return nearest_multiple_of_4 + 1