9 std::vector<char> frame_data(width * height * 4);
11 for (
int y = 0; y < height; y++) {
12 for (
int x = 0; x < width; x++) {
13 int index = (y * width + x) * 4;
16 float time = frame_num / 30.0f;
20 static_cast<char>(128 + 127 * sin(x * 0.1f + time));
21 frame_data[index + 1] =
22 static_cast<char>(128 + 127 * sin(y * 0.1f + time));
23 frame_data[index + 2] =
static_cast<char>(
24 128 + 127 * sin((x + y) * 0.05f + time));
25 frame_data[index + 3] = 255u;
33 const int width = 1280;
34 const int height = 720;
35 const int frame_rate = 30;
36 const int total_frames = 300;
38 std::cout <<
"Creating gradient animation video..." << std::endl;
41 FfmpegCodec encoder(
"gradient_video.mp4", width, height, frame_rate);
43 for (
int i = 0; i < total_frames; i++) {
47 std::cerr <<
"Failed to append frame " << i << std::endl;
53 float progress = (i * 100.0f) / total_frames;
54 std::cout <<
"Progress: " << progress <<
"% (" << i <<
"/"
55 << total_frames <<
" frames)" << std::endl;
60 std::cerr <<
"Failed to finish encoding" << std::endl;
64 std::cout <<
"Video created successfully: gradient_video.mp4"
69 }
catch (
const std::exception& e) {
70 std::cerr <<
"Error: " << e.what() << std::endl;