Last active
February 25, 2023 02:59
-
-
Save Rudxain/af48d29203141b7c45e2794a1148ddb2 to your computer and use it in GitHub Desktop.
Calculates the byte-size of a video as if it wasn't compressed by a codec
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Final | |
BYTES_PER_PIXEL: Final = 3 # 24bit color, 8 per channel | |
def decoded_video_size(*, w: Final[int], h: Final[int], s: Final[float], fps: Final[float]): | |
pixels_per_frame: Final = w * h # px/px^2 = 1/px = px^-1 | |
total_frames: Final = fps * s # px^2/s * s = px^2 | |
total_pixels: Final = pixels_per_frame * total_frames # px^-1 * px^2 = px^2 / px^1 = px | |
total_bytes: Final = total_pixels * BYTES_PER_PIXEL # px * B/px = B | |
return total_bytes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment