This shithole is just a program to help me find the optimal bitrate to convert a video to a given precise size in MB, small but quite useful

					
						#include <cmath>
						#include <cstdio>
						#include <cstdlib>
						#include <string>
						float stringToFloat(char *toConvert){return std::atof(toConvert);}

						int stringToInt(char *toConvert){return std::atoi(toConvert);}

						int main(int argc, char *argv[]) {
						  std::string size, hours, minutes, seconds, framerate, height, width, colorDepth;
						  std::string argument = argv[1];
						  if (argument == "-h" || argument == "--help" || argument == "-?") {
						    std::printf("\n\n=========================================HELP MENU==========================================");
						    std::printf("\n| Bitrate Calculator v0.2p                                                                 |");
						    std::printf("\n| USAGE : ./bitrateCalculator <OPTIONS> [VALUES]                                           |");
						    std::printf("\n|                                                                                          |");
						    std::printf("\n| -? / -h / --help : Displays this help menu                                               |");
						    std::printf("\n| -s / --size : The desired size in MB                                                     |");
						    std::printf("\n| -l / --length : The length of the video (ex: -l 0 0 38 [0 hours, 0 minutes, 38 seconds]) |");
						    std::printf("\n| -f / --fps : The framerate of the actual footage                                         |");
						    std::printf("\n| -r / --res : The wanted resolution for the converted file (ex: -r 1920 1080)             |");
						    std::printf("\n| -d / --depth : The color depth for the codec [8bits, 10bits or 12bits]                   |");
						    std::printf("\n| Azrael Queenston@2026 - Under GPLv3 Licence                                              |");
						    std::printf("\n============================================================================================\n");
						  } else {
						    for (int i = 0; i < argc; ++i) {
						      std::string arg = argv[i];
						      if (arg == "-s" || arg == "--size") {
						        size = argv[i + 1];
						      }
						      if (arg == "-l" || arg == "--length") {
						        hours = argv[i + 1];
						        minutes = argv[i + 2];
						        seconds = argv[i + 3];
						      }
						      if (arg == "-f" || arg == "--fps") {
						        framerate = argv[i + 1];
						      }
						      if (arg == "-r" || arg == "--res") {
						        width = argv[i + 1];
						        height = argv[i + 2];
						      }
						      if (arg == "-d" || arg == "--depth") {
						        colorDepth = argv[i + 1];
						      }
						    }
						    float defSize = stringToFloat(size.data());
						    float defHours = stringToFloat(hours.data());
						    float defMinutes = stringToFloat(minutes.data());
						    float defSeconds = stringToFloat(seconds.data());
    
						    int defFramerate = stringToInt(framerate.data());
						    int defHeight = stringToInt(height.data());
						    int defWidth = stringToInt(width.data());
						    int defColDepth = stringToInt(colorDepth.data());

						    int resReferenceBitrate = (defWidth * defHeight * defFramerate * defColDepth) / std::pow(10, 6);
						    int resRawBitrate = defSize / ((defHours * 60 + defMinutes + defSeconds / 60) * 0.0075);
						    int resCompressionRatio = resRawBitrate / resReferenceBitrate;
						    int resBitsPerPixels = (resRawBitrate * std::pow(10, 6)) / (defWidth * defHeight * defFramerate);

						    std::printf("\n-> True File Bitrate              : %d kbps",resRawBitrate);
						    std::printf("\n-> Reference Uncompressed bitrate : %d kbps",resReferenceBitrate);
						    std::printf("\n-> Bits per Pixels (BPP)          : %d",resBitsPerPixels);
						    std::printf("\n-> Compression Ratio              : %d%%\n",resCompressionRatio);
						  }
						}
					
				


Return to the lobby