Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unlock fps during video rendering #104

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions nob.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@ void generate_default_config(Nob_String_Builder *content)
nob_sb_append_cstr(content, "\n");
nob_sb_append_cstr(content, "//// Unfinished feature that enables capturing sound from the mic.\n");
nob_sb_append_cstr(content, "// #define MUSIALIZER_MICROPHONE\n");
nob_sb_append_cstr(content, "\n");
nob_sb_append_cstr(content, "// Desired rendering FPS of the application.\n");
nob_sb_append_cstr(content, "#define MUSIALIZER_TARGET_FPS 60\n");
}

int main(int argc, char **argv)
Expand Down
3 changes: 2 additions & 1 deletion src/musializer.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <signal.h> // needed for sigaction()
#endif // _WIN32

#include "config.h"
#include "./hotreload.h"

int main(void)
Expand Down Expand Up @@ -36,7 +37,7 @@ int main(void)
SetWindowIcon(logo);
plug_free_resource(data);
}
SetTargetFPS(60);
SetTargetFPS(MUSIALIZER_TARGET_FPS);
SetExitKey(KEY_NULL);
InitAudioDevice();

Expand Down
25 changes: 13 additions & 12 deletions src/plug.c
Original file line number Diff line number Diff line change
Expand Up @@ -1250,10 +1250,21 @@ static void start_rendering_track(Track *track)
// TODO: set the rendering output path based on the input path
// Basically output into the same folder
p->ffmpeg = ffmpeg_start_rendering(p->screen.texture.width, p->screen.texture.height, RENDER_FPS, track->file_path);
SetTargetFPS(0);
p->rendering = true;
SetTraceLogLevel(LOG_WARNING);
}

static void finish_rendering_track(Track *track) {
SetTraceLogLevel(LOG_INFO);
UnloadWave(p->wave);
UnloadWaveSamples(p->wave_samples);
SetTargetFPS(MUSIALIZER_TARGET_FPS);
p->rendering = false;
fft_clean();
PlayMusicStream(track->music);
}

#ifdef MUSIALIZER_MICROPHONE
static void start_capture(void)
{
Expand Down Expand Up @@ -1615,12 +1626,7 @@ static void rendering_screen(void)
NOB_ASSERT(track != NULL);
if (p->ffmpeg == NULL) { // Starting FFmpeg process has failed for some reason
if (IsKeyPressed(KEY_ESCAPE)) {
SetTraceLogLevel(LOG_INFO);
UnloadWave(p->wave);
UnloadWaveSamples(p->wave_samples);
p->rendering = false;
fft_clean();
PlayMusicStream(track->music);
finish_rendering_track(track);
}

const char *label = "FFmpeg Failure: Check the Logs";
Expand Down Expand Up @@ -1654,12 +1660,7 @@ static void rendering_screen(void)
// cause it should deallocate all the resources even in case of a failure.
p->ffmpeg = NULL;
} else {
SetTraceLogLevel(LOG_INFO);
UnloadWave(p->wave);
UnloadWaveSamples(p->wave_samples);
p->rendering = false;
fft_clean();
PlayMusicStream(track->music);
finish_rendering_track(track);
}
} else { // Rendering is going...
// Label
Expand Down