SUPPORT ACCOUNT CLANS
Welcome, Unregistered.
 

Thread: Video Capture on Linux

Results 1 to 7 of 7

Threaded View

  1. #1
    Offline
    Account Icon
    Join Date
    Jul 2009
    Location
    Denver, Colorado
    Posts
    537

    Video Capture on Linux

    I thought it might be nice to have an easy to follow guide for capturing HoN footage in Linux (this guide is geared towards Ubuntu specifically). If you've ever used/seen FRAPS in windows, we're going to accomplish the same thing in Linux.

    Installing the Recording Program

    The best program I've found is called GLC; it doesn't use much in the way of resources, is easy to install, and it's easy to use.

    To install in Ubuntu:

    Install these packages first:
    Code:
    sudo apt-get install build-essential cmake libx11-dev libxxf86vm-dev libgl1-mesa-dev libasound2-dev libpng12-dev
    On 64 bit these commands will also be necessary:
    Code:
    sudo apt-get install gcc-multilib
    sudo ln -s /usr/lib32/libGL.so.1 /usr/lib32/libGL.so
    sudo ln -s /usr/lib32/libasound.so.2 /usr/lib32/libasound.so
    sudo ln -s /usr/lib32/libXxf86vm.so.1 /usr/lib32/libXxf86vm.so
    sudo ln -s /usr/lib32/libX11.so.6 /usr/lib32/libX11.so
    sudo ln -s /usr/lib32/libpng12.so.0 /usr/lib32/libpng.so
    Then follow this build script, leaving everything at default (and saying No to git):
    *make sure to install glc into it's own directory for simplicity. I put it in ~/glc
    Code:
    wget http://nullkey.ath.cx/glc/scripts/glc-build.sh
    chmod a+x glc-build.sh
    ./glc-build.sh
    Capturing and Playing the Video

    Now that GLC is installed you could start capturing video right away by running "glc-capture ./hon-x86_64" (for 64 bit) from your HoN directory. Once in game you press shift+f8 to start (and stop) recording, which would create a .glc file with the video. This file can be viewed with "glc-play filename" in a terminal, but it gets very big extremely quickly and will eat up you hard drive space (as well as slow down your computer writing to the hard drive). To record a lot like this would use tons of space, and is also not ideal for streaming, so we're going to encode it on the fly before creating the files.

    Encoding on the Fly

    To accomplish this we're going to use the concept of named pipes to transfer the data between glc-capture and glc-play without actually writing it into a large video file like before. To do this we create the pipe with the command "mkfifo fifo.glc", and then we will send the output to that pipe by adding "-o fifo.glc" to glc-capture. We then start glc-play with the input file of fifo.glc like so "glc-play fifo.glc", and this will read the data as glc-capture inputs it.

    Now we can send the glc-play output to mencoder in order to encode this video on the fly. The command would look something like this (this can change a lot depending on the mencoder settings, which you can tweak to your liking):

    Code:
    glc-play fifo.glc -o - | mencoder - -demuxer y4m -ovc lavc -o video.mpeg
    This sends the output of glc-play to standard out (the -), and then pipes it (the | ) to mencoder, and mencoder then reads the input from standard in (again the -). Mencoder reads the stream (of type y4m) and encodes it (-ovc lavc, this will encode to mpeg4). Lastly mencoder outputs this file as video.mpeg which will be much much smaller than the unencoded video file would be. In my experience it tends to grow at about 100 kb/s, or 1 megabyte for every 10 seconds, which isn't too bad although it will get big if you leave it on for a long time.

    All of this together in a shell script would like like this:
    Code:
    #!/bin/bash
    
    rm fifo.glc
    mkfifo fifo.glc
    glc-capture -o fifo.glc -s $@ &
    glc-play fifo.glc -o - |glc-play fifo.glc -o - | mencoder - -demuxer y4m -ovc lavc -o video.mpeg
    The -s in the glc-capture line makes it start capturing the second you launch the game. There are also many other options available for glc-capture which you can see here.

    If you were to save this in a file, say something called glc-start, and put it in your HoN folder then you would start HoN by using this:

    Code:
    ./glc-start hon-x86_64  (for 64 bit)
    This would automatically record the entire time you play and save it to a file called video.mpeg in your HoN folder (obviously you can move the output to wherever you want).

    So that's it, you can now record HoN while you play and automatically encode it at the same time. Keep in mind though that even with a great computer this will still cause a big drop in performance, and it might be prudent to take steps to reduce some of the stress:

    I recommend using "-r 0.5" in glc-capture to reduce to half size (which is still pretty big), as well as using "--disable-audio" since I don't record audio personally anyways. Note that if you disable the audio you should use "-y 1" (or possibly 2) in glc-play to only play the video, and "-nosound" in the mencoder command. I also reduce the framerates in the recording to 15 with "-f 15" in glc-capture.

    My finished script looks like this:

    #!/bin/bash

    rm fifo.glc
    mkfifo fifo.glc
    glc-capture -o fifo.glc -s -f 15 -r 0.5 --disable-audio $@ &
    glc-play fifo.glc -y 1 -o - | mencoder -demuxer y4m -nosound - -ovc lavc -o video.mpeg


    Offload Encoding to Server

    Another thing you might be able to do, depending on your situation, is offload the encoding to another computer. I have a personal server do my encoding which greatly reduces the performance hit I take while playing HoN. In order to do this just run the mencoder command over ssh like so:

    Code:
    glc-play fifo.glc -o - | ssh username@server mencoder - -demuxer y4m -ovc lavc -o video.mpeg
    You'll need to use keys with ssh to do this (so it doesn't take a password), and you can read about setting that up here.

    Live Streaming

    Live streaming using this method is also possible, but I haven't ironed out all the kinks yet myself so I won't illustrate how here just yet. Once I get it working a little better, I'll edit this post with how to live stream. I've gotten streaming through VLC working just fine, but I haven't managed to get it to upload correctly to justin.tv without re-encoding the file which is pretty dirty. If anybody has experience with this please let me know.
    Last edited by Verith; 05-25-2010 at 09:24 PM.

    Thanks to Mediocrity for the fantastic signature!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •