Recording screen to video on Windows

I want to output my window to an encoded video.

I know there’s ofxVideoGrabber but it doesn’t seem to work on the OF / Windows combo I’m using (at least I can’t get it working anyway)
I’m on OF 0.9.3 and Windows 10 64bit

Could anyone recommend a good solution please?

And just to make sure, you want to do this programmatically? Just asking, because I’ve had more than one project in the past where using an external screen recording / broadcasting tool (like OBS) turned out to be much more appropriate :).

I’m currently working on that same topic with MSYS2 (Windows 7 & Windows 10).
My approach is to open a pipe to ffmpeg and then to write each frame to that pipe.
That seems to work but need further testing.

Thanks for the replies both.

@Paul-Jan: I don’t need to do this programatically for this project actually but I can see benefits of doing programatically via an integrated encoder such as ffmpeg and would really I would like to get it set up so I have it ready for future projects. Ideally I would be able to record performances programatically without using a 3rd party app.

@oxillo: that seems to be the method used by ofxVideoRecorder too. I don’t think I know enough about it yet to attempt my own solution and would prefer not to re-invent the wheel but saying that I’m not sure if there is a Windows ready solution available? If not I will attempt to hack the available source and get it working with ffmpeg.

I have tried 2 different versions of ofxVideoRecorder: the main branch by timscaffidi and a fork by DomAmato but neither of them seem to work on my system.

I may be doing something wrong (although I’m pretty sure the main branch isn’t compatible due to it using ‘unistd.h’ )

The DomAmato branch was, I think, meant to address the unistd.h and Windows compatibility issues.

I tried to compile the included example project but there are various methods which have been removed from the main branch, after commenting these out it compiles and runs but comes up with errors (such as \.\pipe\videoPipe915: Invalid argument and Output file #0 does not contain any stream

As I say I may have it set up wrong but am using the included example src.

I was wondering if anyone had this running succesfully on OF 093/win10 or if there are any other addons which would do the trick?

If not I will use a 3rd party solution for now and try to implement my own using pipes and ffmpeg when I have the time.

Thanks

As I just needed the video (no audio), I decided to go for my own implementation.
It is a little simple but seems to fit my need (but need more testing).

This is basically what I do : (code not tested)

// Open the pipe 
string cmd = "ffmpeg  -r 30 -f rawvideo -pix_fmt rgba -s 1024x768 -i - -threads 1 -preset fast -y -pix_fmt yuv420p -crf 21 movie.mp4";
ffmpeg = _popen(cmd.c_str(), "wb");

//Write a frame (Repeat as long as needed)
fwrite(pixels, sizeof(int)*1024*768, 1, ffmpeg);

//Close the pipe
_pclose(ffmpeg);

Hope it helps

Cheers oxillo - that does look straightforward I had no idea it could be that easy!
I also don’t need audio for this particular project.
I’ll give it a try later.

Thanks!

I should probably update the examples in my fork but I have not tried it on MSYS2 since I wrote it to work with people developing on visual studio. I am able to compile and run my fork but it has never been tested (to my knowledge) with MSYS2 so it might just be incompatible.

The fork utilizes named pipes on windows so its not using the same pipe that oxillio pointed out in his snippit of code. I should also mention that pipes on windows supposedly runs slower and that is the point of the named pipes paradigm.

Hello there, know this is old but is this a working solution? Looking in to get this working on windows but havent decided where to start yet.

Thanks!

Hello @berzen and welcome to the forum,

I was using the snippet above on Windows 7 and Windows 10 with MSYS2 until recently. One of the limitations was that the recorded video was playing at twice the recorded rate; but I didn’t had the time to look into it.
I’ve started a alternate version of this addon but using libav (the underlying libs of ffmpeg) instead of the pipe to ffmpeg. I’ll try clean the code and to make it available.
UPDATE : the code is available here ofxScreenRecorder

Thank you!
Will look in to it :slight_smile:

You wanna record screen on Windows? It is very easy. You need a Windows screen recording tool. The tool I often use is Joyoshare Screen Recorder and OBS. Such the software can record any area on your screen with high quality. If you still need a screen recorder now, you may choose to have a try.

hey @oxillo
should work on VS2017?