Page 1 of 1

sunvox lib + ffmpeg video export?

Posted: Sat Oct 31, 2020 12:41 am
by AutumnCheney
i made a visualizer for sunvox files in pixilang using the new built-in sunvox library, and i want to allow it to export video using ffmpeg. the issue is, i don't know where to get started. i'm trying to analyze the compo player code, but there's too much other code to connect the video export parts

can someone give me some hints on how i can impliment it in my own program? thanks!

i've included the program and the files it references in a zip file; just run it in the unzipped directory

Re: sunvox lib + ffmpeg video export?

Posted: Sun Nov 01, 2020 2:27 pm
by NightRadio
Unfortunately there is no simple way to do the AV export...

But I created a special framework for such purposes - lib/demo.pixi
You can see examples in the graphics/demoscene folder
Especially such an example as demo_test_sunvox.pixi

You can put your visualizer in the scene1() function
Then uncomment the following line:
demo_video_export = "video.avi" //export to AVI using FFMPEG (only in Linux and macOS) or MJPEG AVI (work on any system)
or
demo_video_export = "video.gif" //export to animated GIF :)

Ask any questions about this library - I'll be happy to answer.

It may seem a little complicated at first, but it's actually a very handy environment for creating all sorts of visualizations, demos, etc.

Re: sunvox lib + ffmpeg video export?

Posted: Sun Nov 01, 2020 11:29 pm
by AutumnCheney
thank you so much!!! i got video export to work with the demo library

however, i noticed that the raw video and raw audio seems to be saved in different directories (the directory that pixilang was run in and the pixilang root directory, respectively) and the video can't fully render because it can't find the audio file. a workaround is to render it twice and move the raw audio from the first render to the directory that the second render will be ran in. this really only works if the audio will be the same in both exports, generative sunvox files won't work very well with this. it's enough for me, but you may want to take a look at this

again, thank you!

Re: sunvox lib + ffmpeg video export?

Posted: Tue Nov 03, 2020 1:36 pm
by leondustar
Awesome I was just about to ask this.
Will check out this demo lib.
@Nightradio did you also use this to generate the beautiful animated GIF's in the docs / pixilang website?

Re: sunvox lib + ffmpeg video export?

Posted: Tue Nov 03, 2020 2:06 pm
by NightRadio
did you also use this to generate the beautiful animated GIF's in the docs / pixilang website?
I used similar code in Pixilang :)

Re: sunvox lib + ffmpeg video export?

Posted: Tue Nov 03, 2020 2:09 pm
by NightRadio
however, i noticed that the raw video and raw audio seems to be saved in different directories
Please try to use the updated version of the library:
demo.pixi
Pixilang Demoscene Engine 1.0.1
(26.21 KiB) Downloaded 38 times

Re: sunvox lib + ffmpeg video export?

Posted: Tue Nov 03, 2020 8:23 pm
by AutumnCheney
NightRadio wrote: Tue Nov 03, 2020 2:09 pm
however, i noticed that the raw video and raw audio seems to be saved in different directories
Please try to use the updated version of the library: demo.pixi
thank you! it works perfectly now!

Re: sunvox lib + ffmpeg video export?

Posted: Sat Apr 24, 2021 2:56 pm
by burij
I also need to comment out the content of Scenes 2 - 4, right?

Code: Select all

include "../lib/demo.pixi"

//demo_show_fps = 1
//demo_opengl = 1
//demo_xsize = 320
//demo_ysize = 240
//demo_video_export = "video.avi"

//demo_load_sunvox( "../../sound/sound_files/test2.sunvox" )

demo_init()
demo_add_scene( 0, 0, 0, scene1 )
demo_add_scene( 0, 0, 1000, scene2 )
demo_add_scene( 0, 0, 2000, scene3 )
//demo_add_scene( 0, 0, 3000, DEMO_STOP )
demo_add_scene( 0, 1, 0, scene4 )

demo_play()
demo_deinit()

fn scene1( $t1, $t2, $len )
{
include "boot.pixi"
}

fn scene2( $t1, $t2, $len )
{
//    clear( #304050 )
//    sprintf( demo_ts, "SCENE #2\n%d\n%d\n%d", $t1, $t2, $len )
//    print( demo_ts )
}

fn scene3( $t1, $t2, $len )
{
//    clear( #405060 )
//    sprintf( demo_ts, "SCENE #3\n%d\n%d\n%d", $t1, $t2, $len )
//    print( demo_ts )
}

fn scene4( $t1, $t2, $len )
{
    //time function = 1 (SunVox player); time unit = line;
//    $t = $t1
//    fbox( -demo_xsize/2 + $t, 32, 4, 1000, WHITE )
}


sv_remove(sv, 0)
show_memory_debug_messages( 1 )

Re: sunvox lib + ffmpeg video export?

Posted: Sat Apr 24, 2021 6:33 pm
by burij
Is it possible, that the rendering is reaaaaly slow. I'm testing it with a 6 secondes sunvox file and it's exporting already half day.

Re: sunvox lib + ffmpeg video export?

Posted: Mon Apr 26, 2021 11:26 am
by NightRadio
Is it possible, that the rendering is reaaaaly slow.
Try to add the follofing option
maxfps 1000
to ~/.config/Pixilang/pixilang_config.ini

Re: sunvox lib + ffmpeg video export?

Posted: Thu Apr 29, 2021 1:01 am
by burij
Thx. I think the mistake was somewhere else. Autostop of an implemented sunvox project, doesn't work, if it's inside a demoscene. So the project is looping and export never ends. I tried different things and export works like a charm, if I don't try to build those complex sunvox-reacting visualisations inside the demoscene, but more straight forward visuals.