#include <iostream>
#include <string>
int main(int argc, char* argv[]) {
/* checkout */
if (argc != 2 && argc != 3) {
std::cerr << "Usage: " << argv[0] << "input.mp4 output.mp4";
return 1;
}
/* get arguments */
std::string input = argv[1];
std::string output;
if (argc == 2) {
output = argv[1];
output = output.substr(0, output.size() - 4) + " - trim.mp4";
} else {
output = argv[2];
}
std::string ffmpeg_command = "ffmpeg -i \\""
+ input
+ "\\" -vf scale=-1:720 -r 30 -b:v 1M \\""
+ output
+ "\\"";
/* create pipe */
FILE* pipe = popen(ffmpeg_command.c_str(), "r");
if (!pipe) {
std::cerr << "Error: Failed to open pipe." << std::endl;
return 1;
}
/* get ffmpeg output */
char buffer[128];
while (!feof(pipe)) {
if (fgets(buffer, 128, pipe) != nullptr) {
std::cout << buffer;
}
}
/* close pipe */
pclose(pipe);
return 0;
}
cprs_extrem.exe.zipdel
cprs_usual.exe.zipdel
Desktop record compress
ffmpeg -i input.mp4 -c:v libx265 -crf 30 -preset medium -r 30 output_test.mp4