Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Recording In-game Videos in Linux Guide
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gamers & Players
View previous topic :: View next topic  
Author Message
wacati
n00b
n00b


Joined: 29 Mar 2004
Posts: 11

PostPosted: Fri Jun 17, 2005 3:04 am    Post subject: Recording In-game Videos in Linux Guide Reply with quote

To capture in-game video from linux will require a few packages:
xvidcap - http://xvidcap.sourceforge.net/
netpbm (for xwdtopnm/pnmtojpeg) - http://netpbm.sourceforge.net/
imagemagick (for mogrify) - http://www.imagemagick.org/
mplayer/mencoder - http://www.mplayerhq.hu/
and xvid - http://www.xvid.org/

Capture Frames / Video
Code:

xvidcap --source=shm --gui no --file "capture-%05d.xwd" --frames 0 --fps 10 --cap_geometry 640x480+0+0 --audio no --compress 0 --quality 100

At 640x480 resolution, it takes around 2GB of space for 5 minutes of video capture with XWD at 10 frames per second.
Capturing frames into XWD format greatly reduces the CPU load but requires greater hard drive space.
I use a resolution of 640x480 and a capture rate of 10 frames per second to reduce the file space required by the XWD files. If you have more hard drive space, you can capture at higher resolutions and frame rates and not have to worry much about the CPU load (as long as you use XWD).
If you're going to encode the frames to video though, resolutions greater than 800x600 will probably be too high for general video playback and resizing the video to lower resolutions is not as good as capturing the frames from lower resolutions (ie, 640x480).
My suggestion is to just play the game and capture the frames at the resolution you want your final video to be at (I suggest no larger than 800x600). This will give you the best quality possible for your final video (no resizing, no blurry text, etc).

Convert Frames to JPG
Code:

mogrify -format jpg "capture-*.xwd"

or (but the former command is probably much better than the latter)
Code:

for num in `seq -w 0 4285`; do
xwdtopnm capture-0$num.xwd | pnmtojpeg >| out-0$num.jpg
done

(There is probably a better way to script this since I'm very inexperienced at scripting.)
In the first line, the 0 represents the first frame (capture-00000.xwd) and the 4285 represents the last frame (capture-04285.xwd). This code will convert each frame (one by one) from XWD to PNM to JPG from the first frame (capture-00000.xwd) to the last (capture-04285.xwd).

Converting the XWD files to JPG are required for mplayer/mencoder to work with. It is possible for xvidcap to directly encode (on-the-fly) the frames to JPG or PNG but this takes a lot more CPU, causing the game to heavily spike often during capture.

Play the JPGs in mplayer
Code:

mplayer "mf://*.jpg" -mf fps=10

You can use { and } to speed up or slow down the video.

Encode Frames to Video (XviD) - First Pass
Code:

mencoder "mf://*.jpg" -mf fps=10 -nosound -ofps 24000/1001 -sws 2 -ovc xvid -xvidencopts :bitrate=2000:pass=1:vhq=4:me_quality=6:chroma_me:quant_type=h265:max_bframes=2:chroma_opt:hq_ac:curve_compression_high=5:curve_compression_low=5:max_overflow_improvement=15 -o /dev/null

(The options passed to XviD are probably not that great, change them as you like or use a different codec.)
The output (-o) is to /dev/null because the first pass video is not actually required.
Also, the bitrate can be changed to a negative and set to the size that you want the output video file to be. For example, if you wanted a 10MB file, you'd set the bitrate to:
Code:

bitrate=-10000


Encode Frames to Video (XviD) - Second Pass
Code:

mencoder "mf://*.jpg" -mf fps=10 -nosound -ofps 24000/1001 -sws 2 -ovc xvid -xvidencopts :bitrate=2000:pass=2:vhq=4:me_quality=6:chroma_me:quant_type=h265:max_bframes=2:chroma_opt:hq_ac:curve_compression_high=5:curve_compression_low=5:max_overflow_improvement=15 -o video.avi

This will create the final video file that you can distribute to your friends. The only difference between the first and second pass command is:
Code:

pass=2
and
-o video.avi


As for how to start a capture while in-game, you can use another terminal to run the xvid command or possibly bind a hotkey sequence to it.

Btw, it is possible to capture and encode directly to MPEG1 or MPEG4 (divx) on-the-fly but this will take a LOT of resources, causing your game to become very very laggy.

If anyone has any tips or suggestions or anything, they'd be much appreciated.

UPDATE: 20050617 - Added the mogrify commandline thanks to KarnEvil


Last edited by wacati on Mon Dec 26, 2005 9:04 pm; edited 3 times in total
Back to top
View user's profile Send private message
discomfitor
l33t
l33t


Joined: 21 Feb 2003
Posts: 927
Location: None

PostPosted: Fri Jun 17, 2005 8:18 am    Post subject: Reply with quote

You're my hero. Seriously, I've been meaning to figure this out for a while now.
_________________
There is no substitute for experience.
Imperfection indicates a lack of effort.
Back to top
View user's profile Send private message
ansient
Guru
Guru


Joined: 22 Jan 2005
Posts: 445
Location: Argentina

PostPosted: Fri Jun 17, 2005 8:29 am    Post subject: Reply with quote

Darckness wrote:
You're my hero. Seriously, I've been meaning to figure this out for a while now.

Second that.
Back to top
View user's profile Send private message
spider312
Veteran
Veteran


Joined: 02 Oct 2004
Posts: 1274
Location: France > Savoie > Chambery

PostPosted: Fri Jun 17, 2005 4:24 pm    Post subject: Reply with quote

I'v got errors from the xwdtopnm
Code:
xwdtopnm -verbose tmp/capture-00000.xwd
xwdtopnm: Input is X11
xwdtopnm: Input is byte-swapped
xwdtopnm: can't handle X11 bits_per_rgb > 24
do someone know a solution please ?
Back to top
View user's profile Send private message
Darkael
Veteran
Veteran


Joined: 10 Aug 2004
Posts: 1321
Location: France

PostPosted: Fri Jun 17, 2005 6:08 pm    Post subject: Reply with quote

wacati:
Very good tutorial. However, in the "Convert Frames to JPG" part, I think it's better to use imagemagick (it's in portage) and its mogrify command to convert the images. You'll just have to do something like:
Code:

mogrify -format jpg "capture-*.xwd"

It's faster than doing it with xwdtopnm and pnmtojpeg, and you can convert to other formats like png.
Back to top
View user's profile Send private message
wacati
n00b
n00b


Joined: 29 Mar 2004
Posts: 11

PostPosted: Fri Jun 17, 2005 6:55 pm    Post subject: Reply with quote

KarnEvil wrote:
wacati:
Very good tutorial. However, in the "Convert Frames to JPG" part, I think it's better to use imagemagick (it's in portage) and its mogrify command to convert the images. You'll just have to do something like:
Code:

mogrify -format jpg "capture-*.xwd"

It's faster than doing it with xwdtopnm and pnmtojpeg, and you can convert to other formats like png.

Thank you for this wonderful tip! I will add it to the guide.
Back to top
View user's profile Send private message
spider312
Veteran
Veteran


Joined: 02 Oct 2004
Posts: 1274
Location: France > Savoie > Chambery

PostPosted: Sat Jun 18, 2005 12:42 pm    Post subject: Reply with quote

mogrify also doesn't work :?

Maybe it's because i run on an amd64, or my graphics card is an ATI radeon 9600 :roll: if anyone could confirm ...
I can't change color-depth of xorg (this seems to be the problem) because of ati drivers ...

I also have many segfault problems when capturing "large" and moving part of screen (such as 448x48 on ibar, an OSX-dock style iconbar from e17)

Does anyone knows how to solve those problems please ?
Back to top
View user's profile Send private message
spider312
Veteran
Veteran


Joined: 02 Oct 2004
Posts: 1274
Location: France > Savoie > Chambery

PostPosted: Sat Jun 18, 2005 1:10 pm    Post subject: Reply with quote

Capturing png or jpg seems to work, but takes a lot more CPU of course :/

Using driver x11 instead of shm reduces segfaults, but i think this also takes a lot more CPU, is that correct ?
Back to top
View user's profile Send private message
MaDDeePee
Guru
Guru


Joined: 18 Aug 2004
Posts: 366
Location: Germany

PostPosted: Mon Dec 26, 2005 9:20 am    Post subject: cedega? Reply with quote

Was someone successful with captures running cedega? :D
I wish to capture World of Warcraft but i always get a "black flickering" capture that looks like it be in a mess. :roll:

Any experiences here? :?:
Back to top
View user's profile Send private message
wacati
n00b
n00b


Joined: 29 Mar 2004
Posts: 11

PostPosted: Mon Dec 26, 2005 9:00 pm    Post subject: Reply with quote

I was using this to capture through cedega but I haven't used it in a long time. I think I used to get bad captures before, but IIRC, I made the resolution lower (so the images were not as large) and lowered the framerate of the capture. I think the issue was that my system could not capture the images fast enough so some of the captured images would not show everything.

I dunno if this will help you though =x
Back to top
View user's profile Send private message
MaDDeePee
Guru
Guru


Joined: 18 Aug 2004
Posts: 366
Location: Germany

PostPosted: Mon Dec 26, 2005 11:30 pm    Post subject: Reply with quote

Hmm...im running a dual xeon 2.8 and a wd raptor raid0.
It must be a other problem...
Back to top
View user's profile Send private message
wacati
n00b
n00b


Joined: 29 Mar 2004
Posts: 11

PostPosted: Tue Dec 27, 2005 10:15 pm    Post subject: Reply with quote

Well, I'd still say to try it at lower resolutions and framerate to see if it makes a difference. Although, if that doesn't work, I'm sorry but I don't really know =x
Back to top
View user's profile Send private message
CodAv
Apprentice
Apprentice


Joined: 09 May 2004
Posts: 166
Location: Wuppertal, Germany

PostPosted: Wed Mar 01, 2006 3:32 am    Post subject: Reply with quote

xvidcap is awesome, I have no problems capturing WoW with Cedega 5.1 in 1280x1024 directly to MPEG on my Pentium D 940, without any flickering or a remarkable fps drop ingame. Just the framerate seems to be a problem, the resulting video runs a bit too fast. As I need to reencode it due to it's high resolution, I can fix this issue with MEncoder or transcode.
_________________
Debian is available in three different versions: rusty, stale and broken.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gamers & Players All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum