Skip to content

Commit

Permalink
d 8
Browse files Browse the repository at this point in the history
  • Loading branch information
ZiLko committed Jan 1, 2025
1 parent a8ae065 commit d715d4e
Showing 1 changed file with 49 additions and 46 deletions.
95 changes: 49 additions & 46 deletions src/renderer/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <fstream>

class $modify(PlayLayer) {

void showCompleteText() {
PlayLayer::showCompleteText();
if (Global::get().renderer.recording && m_levelEndAnimationStarted && Mod::get()->getSavedValue<bool>("render_hide_levelcomplete")) {
Expand All @@ -25,6 +26,7 @@ class $modify(PlayLayer) {
}
}
}

};

class $modify(EndLevelLayer) {
Expand All @@ -39,6 +41,7 @@ class $modify(EndLevelLayer) {
});
}
}

};

class $modify(FMODAudioEngine) {
Expand Down Expand Up @@ -235,53 +238,53 @@ void Renderer::start() {
settings.m_outputFile = path;

std::thread([&, path, songFile, songOffset, fadeIn, fadeOut, extension, settings]() {
// if (!codec.empty()) codec = "-c:v " + codec + " ";
// if (!bitrate.empty()) bitrate = "-b:v " + bitrate + " ";
// if (extraArgs.empty()) extraArgs = "-pix_fmt yuv420p";
// if (videoArgs.empty()) videoArgs = "colorspace=all=bt709:iall=bt470bg:fast=1";

// float fadeInTime = geode::utils::numFromString<float>(Mod::get()->getSavedValue<std::string>("render_fade_in_time")).unwrapOr(0.f);
// bool fadeInVideo = Mod::get()->getSavedValue<bool>("render_fade_in") && fadeInTime != 0.f;
// float fadeOutTime = geode::utils::numFromString<float>(Mod::get()->getSavedValue<std::string>("render_fade_out_time")).unwrapOr(0.f);
// bool fadeOutVideo = Mod::get()->getSavedValue<bool>("render_fade_out") && fadeOutTime != 0.f;

// std::string fadeArgs;
// if (fadeInVideo)
// fadeArgs = fmt::format(",fade=t=in:st=0:d={}", fadeInTime);

// // std::string command = fmt::format(
// // "\"{}\" -y -f rawvideo -pix_fmt rgb24 -s {}x{} -r {} -i - {}{}{} -vf \"vflip,{}{}\" -an \"{}\" ",
// // ffmpegPath,
// // std::to_string(width),
// // std::to_string(height),
// // std::to_string(fps),
// // codec,
// // bitrate,
// // extraArgs,
// // videoArgs,
// // fadeArgs,
// // path
// // );

// // log::info("Executing: {}", command);

// // auto process = subprocess::Popen(command);

// bool xd = ffmpeg.init(settings);

// while (recording || pause || recordingAudio || frameHasData) {
// lock.lock();
// if (frameHasData) {
// const std::vector<uint8_t> frame = currentFrame;
// frameHasData = false;
// lock.unlock();
// // process.m_stdin.write(frame.data(), frame.size());
// auto xd2 = ffmpeg.writeFrame(frame);
// }
// else lock.unlock();
// }
if (!codec.empty()) codec = "-c:v " + codec + " ";
if (!bitrate.empty()) bitrate = "-b:v " + bitrate + " ";
if (extraArgs.empty()) extraArgs = "-pix_fmt yuv420p";
if (videoArgs.empty()) videoArgs = "colorspace=all=bt709:iall=bt470bg:fast=1";

float fadeInTime = geode::utils::numFromString<float>(Mod::get()->getSavedValue<std::string>("render_fade_in_time")).unwrapOr(0.f);
bool fadeInVideo = Mod::get()->getSavedValue<bool>("render_fade_in") && fadeInTime != 0.f;
float fadeOutTime = geode::utils::numFromString<float>(Mod::get()->getSavedValue<std::string>("render_fade_out_time")).unwrapOr(0.f);
bool fadeOutVideo = Mod::get()->getSavedValue<bool>("render_fade_out") && fadeOutTime != 0.f;

std::string fadeArgs;
if (fadeInVideo)
fadeArgs = fmt::format(",fade=t=in:st=0:d={}", fadeInTime);

// std::string command = fmt::format(
// "\"{}\" -y -f rawvideo -pix_fmt rgb24 -s {}x{} -r {} -i - {}{}{} -vf \"vflip,{}{}\" -an \"{}\" ",
// ffmpegPath,
// std::to_string(width),
// std::to_string(height),
// std::to_string(fps),
// codec,
// bitrate,
// extraArgs,
// videoArgs,
// fadeArgs,
// path
// );

// log::info("Executing: {}", command);

// auto process = subprocess::Popen(command);

bool xd = ffmpeg.init(settings);

while (recording || pause || recordingAudio || frameHasData) {
lock.lock();
if (frameHasData) {
const std::vector<uint8_t> frame = currentFrame;
frameHasData = false;
lock.unlock();
// process.m_stdin.write(frame.data(), frame.size());
auto xd2 = ffmpeg.writeFrame(frame);
}
else lock.unlock();
}

// ffmpeg.stop();
ffmpeg.stop();

// if (process.close()) {
// Loader::get()->queueInMainThread([] {
Expand Down

0 comments on commit d715d4e

Please sign in to comment.