you can even use the ‘-vcodec copy’ option and the re-encoding takes no time at all. All you need to do to make it into a real MJPEG. The great thing about this is that mashing a bunch of JPGs together one after another is very similar to an MJPEG video file. I did this by using the freeImage library to get compressed jpg binary data into memory and then send that into a file stream. This can drastically reduce the amount of IO calls because you no longer need to create a new file every time you want to save a frame, instead it gets tacked on to an existing file that is kept open while the program is recording. The second enhancement was to stop saving each frame as an individual file. If you have a slow disk, then you’ll eventually run out of memory doing this, so in some cases you will have to drop a frame here or there. I started with memo’s threaded image saver, and initially extended it to use a linked list of queued up frames to save just in case the disk gets slowed down for a bit, so it’s essentially saving images to memory first, in the form of unsigned char arrays, then writing them to disk as jpgs. I’ve come up with a fairly efficient method of doing this because I needed to write a program that could record live video from up to three cameras at once. ![]() This way you don’t lose any frames like you most likely will with an external screen grabbing program. ![]() I prefer saving images every frame, or whenever it is necessary.
0 Comments
Leave a Reply. |