Hi
I want to capture videos from opengl games.
i allready have done a hook to the game and extracted pictures from gl engine.
i use a memory map to capture the pictures.
Now i have the problem that the pictures are good as long they are processed in memory.
The whole data are to big to write it to hard drive ( min 25 fps a 2-10 mb depending on resolution of the game ).
Since i tryed several packages to create avi that are available for delphi i found none of them working with several problems.
So i started to write a Direct Show Filter that is reading from Memory Map and pushes the Bitmaps into Xvid codec.
This should explain what im doing:
Now i still have many troubles with that.
First i think xvid encoder is not fast enought to do that ( i tryed Mircrosoft DV too ).
The Video and Audio that i record is out of sync - mostly because of framedrop i think.
What i now need is a very fast encoder that can handle Bitmaps and convert it to whatever - it does not matter at all.
i Just want it to be fast enought to handle bitmaps about 3 mb size with 25 fps and write it down to harddrive.
The resulting size does not realy matter - it only matters in the case of harddrive speed limits.
And well since i allready have done this filter it would be nice if it works with as a direct show filter - but at last i would take any encoder that can be used in a thread or multimedia timer to write my bitmaps to hd
hope someone can help me
Arnulf
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays! or rip iTunes movies!
+ Reply to Thread
Results 1 to 24 of 24
Thread
-
-
Two things:
1) You need 2 HDDs. Do you already have them
2) XviD cannot be fast enough because it's a lossy format.
You'd need to use a fast lossless compression method. -
You could try writing your own lossless-JPG compressor.
I only know that the one from [s:ce0145588f]Pegasys[/s:ce0145588f] Pegasus is faster than the one
provided by ffdshow --- but I don't recall if either of them
works outside of the VfW universe. HTH.
P.S.: Thanks for correcting me, jagabo. -
Divx at its fastest setting is much faster than Xvid. I think you need the registered version to get that though. Target Quantizer mode and turning off B and P frames will make both Xvid and Divx go faster.
Try HuffYUV or PicVideo MJPEG. Both are very fast but you will get big files.
Most MP3 encoders are pretty slow too. Capture audio uncompressed. Compress later.
I just ran a quick test: a 90 second 720x480 23.976 fps MPEG video compressed in 7 seconds with Divx at its fastest settings. Xvid took 17 seconds. HuffYUV took 9 seconds. PicVideo MJPEG (v 2.0) 7 seconds. This was on a Q6600 CPU. -
Thanks for the tips
I tryed HuffYUV and Mjpeg ( the one included in direct show filters ).
With HuffYUV everything is running in slow motion while with mjpeg play speed is normal.
Both videos recorded are displayed as 10 fps ( for testing i use lower frame rate ).
Both videos are out of sync with audio ( bad ).
I realy have no idea what i could try next.
the memory map filter is ok i think - because if i connect a video window everything is displayed correctly - a duplicate of the original game window.
i realy have no idea what to try next ....
lg
Arnulf -
Have you tried running the capture program at a higher priority? And you're trying to capture something like 1280x720 RGB at 25 fps -- while playing a game on the same CPU?
-
no i capture 800x600 24 bit bitmaps RGB.
i copy them with glReadPixel into a memory map ( its a hook at opengl32.dll lib ).
the memory map filter then copys the bitmap out of the map and push this into the compressor ( encoder ).
The Picture explains the rest.
I would also post source codes - or upload the executeables i have creaded but this is done in delphi.
i have no idea what to try next.
lg
Arnulf -
Is the video source very disk intensive? If so be sure you are saving to a different disk than the source.
Did you set HuffYUV up to convert RGB to YUY2? Then use the fastest YUY2 compression setting?
Get a dual core CPU. Assign one core to the game, one to the capture program. -
Well i realy have no idea
i have made some changes to the testprogram so it might be used for testing.
Im not totaly sure if it works on other systems than mine because there are still some things hardcoded like filtercategorys.
Im not sure if the categorys are the same on other windows xp systems.
I have added a readme file so it should explain what to do to make it running.
The program will only work with opengl based games and you have to use a resolution of 800x600 for the game ( it does not matter if windowed or full screen - this is hardcoded ).
this restrictions are only for testing - this is the easyest part to change.
maybe then you can see what i mean.
i have also added a video window so you can choose to let it render into video window or to file ( c:test.avi is hardcoded )
you can also set and change the huffyuv settings if you select it.
i hope it works - never tested it with any other game than medal of honor or on any other system ...
http://rapidshare.com/files/131953627/GameRecorder.rar
if you have any idea what i could change or try next tell me.
also i do not sit on my source codes - the whole projekt might be open source so i do not care to much about it.
lg
Arnulf -
I found a little OpenGL game and tried out your program. I was able to record but, as you said, it drops lots of frames, typically in large batches. Since I was recording on a dual core computer I tried locking each process to a core. The game was only taking 20 percent of one core. The capture at 800x600 was taking about 80 percent of the other core. Still dropped frames. I tried changing the game to 640x480. The resulting AVI had a messed up display (I suspect you are assuming 800x600 but getting a 640x480 frame buffer) but it looked to be playing a little smoother -- fewer dropped frames.
-
yes i hardcoded 800x600 in the filter.
the hook will make a memmap for your resolution.
so the bitmap will have 640x480 but the filter will read 800x600.
well i have no time at the moment - until next week - but i can rewrite the program to make it more comfortable.
i will adjust the filter to take the resolution of the memmap - so resolution might be changed dynamicaly ( not while recording ).
also i will implement another selection field to select the compression filter - so you can try this with any encoder you like.
but i think the major problem is in the pushsource filter ( redone to read from memmap ) -
im not sure because im not experenced with direct show but maybe a pushsource filter cannot set framerate.
it maybe pushes frames into the ds stream whenever it can.
so maybe i set it to a framerate and other filters in chain think this is timed correctly.
this could be the reason that your dual core takes cpu time whatever it can get.
theoretical then the source filter takes maximum cpu time to push bitmaps into filter chain.
means i tell the filter chain that the video is correctly timed with 25 fps but the pushfilter pushes frames at maximum cpu time ( maybe much more than 25 fps or lower ).
the memmap is timed exactly to 30 fps ( that is why the live video window displays correctly) - so 30 per second a new picture is written to the memmap.
but the filter takes much more frames out of the map or drops them if low cpu time.
i hope this was readable
i maybe have to find a way to tell the filter chain or the pushmap filter to only push frames at a timed framerate.
but i realy have no idea how to do that.
lg
Arnulf
edit:
i made following changes.
the filter will accept othe resolution than 800x600
you can now select the compression filter.
http://rapidshare.com/files/132374416/GameRecorderV1.rar
anyway its still a testprogram and you maybe have to close game and appliacation sometimes while testing.
initialisation of everything is still not thought for a release.
also do not change resolution while rendering !!! -
The classic way to approach this problem is uncompressed capture to a RAID zero or hardware encoding which doesn't load the CPU. This is how high end video was handled through the 1990's.
By early 2000's CPU power and single drive speeds increased to the point a 100% dedicated CPU could software encode live video to single drive speed (e.g. Huffyuv or MJPEG).
Games tend to utilize full CPU capacity. To play a game and software encode, you will need more CPU cores.Recommends: Kiva.org - Loans that change lives.
http://www.kiva.org/about -
Perhaps your DirectShow filter is not an example of efficient coding
-
Originally Posted by Arnulf
-
maybe you have not updated the filter?
it worked with me.
anyway i have a new one available - will upload next days ( im not at home at the moment )
with the new one you do not have to install a filter anymore - it will use internal one.
efficient programming? - all is based on directshow - i cant handle anything with codecs - i have to use thoes that exist.
the problem is i think the timing of push source filter as i sayd before.
if someone does understand that and how to implement into pushsource filter:
http://msdn.microsoft.com/en-us/library/ms787780(VS.85).aspx
well then tell me
lg
Arnulf -
I'm pretty sure I just drag and dropped everything from the archive to the folder I was working in. Oh, maybe I didn't register the new filter?
-
you dont need to regist - but put the new filter in system32 folder.....
anyway i have allready the filter includet into executeable but not uploaded yet.. will do that soon.
hope i find a solution for this timing problem ...
lg
Arnulf
Edit:
still no solution for the timing problem.
No need to put the filter into system32 folder anymore.
http://rapidshare.com/files/132904839/GameRecorderV2.rar
you still have to register the filter - doubleklick reg.bat file.
hope i can find a solution for timing
lg
Arnulf
Edit:
just to add this.
the program is still not working correctyl - and the filter i added to the program is not used - its still the one registered in system - i realy have low experence with directshow.
i try to figure out ...... so dont load it until you do not have something to try or to tell me
Arnulf -
Originally Posted by Arnulf
so-called&&prefab "Base Classes", then I think you are wrong.
[ P.S. ]
Have you already thought of trying MKV instead of AVI
In other words, 'matroskamuxer.ax' instead of 'qcap.dll' -
Well i have stoped using direct show now.
i programed my own little encoder that works good.
i just have to clean up a litte messed code and then i upload the new version that should work ok...
( still beta and so on .. ).
i never tryed matroska - but i realy think the problem at all is that a push source filter like i have programed has no timer.
someone tould me i have to add audio pin an then it is timed correctly - but for me it was easyer to make my own minni codec.
At last i will build a conversion filter to make a standard video output.
but first i make the program useable ...
bad i have not solved the problems with direct show would have been nice to use windows own video conzept.
lg
Arnulf -
Originally Posted by Arnulf
-
Well, I suggested the use of Gabest's Matroska Muxer only because
I thought it would be more reliable than the default Avi Muxer provided by Microsoft.
IIRC, I read elsewhere @ the Doom9 forums that "the Microsoft way" of
dealing with RIFF-wrapped stuff is NOT 100%-compliant with the RIFF specs. -
@ pushsource - yes thats the point of pushsource but it was not possible to make the video timed correctly with push sorce.
i tryed to add timestamp ( start stop ) like in demo sources but audio & video never was synchron with avimixer.
maybe matroska would have solved that but i never tryed because i realy dealed with many codecs and pintees whatever - and never got a solution.
maybe if i have time i will try with matroska - maybe this can solve my problems.
anyway i made it working building my own minni codec and not using direct show ( im realy annoyed about direct show now )
you can try the program here:
http://rapidshare.com/files/135763130/AVRecorder.rar
i works now - maybe there is still some things that need to be changed ( audio source is still hardcoded - means it tryes to access stereomixer ) - und such things.
also to make it realy working it should be controlled by keyhook ( not done yet ).
but what has now done:
it will ignore resolution of the game and make it fit to 400x300
you can also change resolution while playing - no effect to video.
im sure there are still things to bring it down but in my tests it was very stable.
about the codec:
it will create movie.wav and movie.jvc
jvc means jpeg video codec - that is nothing more than jpegs in a video stream
details:
4 byte timestamp ( starting with 0 then every frame timed in milliseconds ), 4 byte offset to the next timestamp, raw jpegimage.
|4 byte|4 byte|sizeofjpeg|4 byte|4 byte|sizeofjpeg .............
with that minni codec it is easyely possible to write a converter to any format required - since it is only jpeg image in the file. The quality is good of the video since there is no p or b frame its still only jpeg.
i know it would have been much better to use direct show and choose codec from system but i had no time to deal any longer with this.
cu
Arnulf
Similar Threads
-
Need help in order to record game
By Neil_2004 in forum Video Streaming DownloadingReplies: 23Last Post: 20th Feb 2012, 14:58 -
best way to scan through youtube videos VERY FAST!
By snafubaby in forum Newbie / General discussionsReplies: 5Last Post: 5th Jun 2011, 11:48 -
Unable to record audio with game cam
By Crimson in forum Video Streaming DownloadingReplies: 2Last Post: 25th Apr 2011, 10:04 -
Video Game FRAPS Recordings - Blurry Videos - Compression Help!
By ItsJono in forum Newbie / General discussionsReplies: 0Last Post: 14th Jun 2010, 00:25 -
how can i record videos off youtube?
By Ade007 in forum Newbie / General discussionsReplies: 8Last Post: 15th Nov 2007, 18:46