Record a 60fps movie (with sound) using Uzem
Posted: Mon Sep 21, 2015 2:06 am
Here is the result (a sneak peek of my work in progress):
And this is what I did to get it:
Edit: Scroll down a bit in this thread to this post, because I discovered a much better way to record the video and audio directly into an mp4 file in a single pass. I'll leave my original post here for historical purposes. If you want to see the results of the latest and greatest on-the-fly video recorder, click here and be sure to select the 720p60 stream.
First, run an unmodified copy of uzem fullscreen, and with the -c flag to capture your input:
This is necessary, because the recording process slows uzem down to a crawl, and this allows us to first play it through at full speed. Due to this delay, we can't actually capture sound and video at the same time (it won't stay synchronized), so two playbacks of the capture file will be required.
Then, play the capture file back (making sure you hit "Esc" when it's done) to record just the audio portion:
Then convert the generated audio into a WAVE file:
Next we'll need to use a hacked version of uzem to record a BMP file for each frame. Add the following chunk of code to line 321 of uzebox/tools/uzem/avr8.cpp, right after the controller capture/playback code. Save a copy of the original uzem binary, and recompile it with this recording hack in place:
Recording each frame at 60fps takes a lot of disk space (about 84 MB/sec), so be prepared for that.
Next, run the hacked version of uzem with the -l (lowercase L) flag to playback the input capture you created previously, and create a ton of BMP files. Make sure you hit "Esc" to stop the recording at around the same time as you did before.
And then finally use avconv to combine the BMP files and the audio recording into a single (tiny) movie file called test.mkv:
To reclaim the gigabytes of disk space we just wasted, run:
And now you can share your video recording, or upload it to YouTube!
And this is what I did to get it:
Edit: Scroll down a bit in this thread to this post, because I discovered a much better way to record the video and audio directly into an mp4 file in a single pass. I'll leave my original post here for historical purposes. If you want to see the results of the latest and greatest on-the-fly video recorder, click here and be sure to select the 720p60 stream.
First, run an unmodified copy of uzem fullscreen, and with the -c flag to capture your input:
Code: Select all
~/uzebox/bin/uzem -f -c physics.hex
Then, play the capture file back (making sure you hit "Esc" when it's done) to record just the audio portion:
Code: Select all
SDL_AUDIODRIVER=disk ~/uzebox/bin/uzem -f -l physics.hex
Code: Select all
sox -u -b8 -c1 -r15700 sdlaudio.raw sdlaudio.wav
Code: Select all
// Record screen capture
static uint32_t vidcapnum;
char vidcapbuf[32] = {0};
sprintf(vidcapbuf, "vidcap_%08d.bmp", vidcapnum++);
SDL_SaveBMP(screen, vidcapbuf);
Recording each frame at 60fps takes a lot of disk space (about 84 MB/sec), so be prepared for that.
Next, run the hacked version of uzem with the -l (lowercase L) flag to playback the input capture you created previously, and create a ton of BMP files. Make sure you hit "Esc" to stop the recording at around the same time as you did before.
Code: Select all
~/uzebox/tools/uzem/uzem -f -l physics.hex
Code: Select all
avconv -r 60 -f image2 -i vidcap_%08d.bmp -i sdlaudio.wav -c:v libx264 -r 60 -crf 21 -c:a copy test.mkv
Code: Select all
rm vidcap_*.bmp sdlaudio.raw sdlaudio.wav