These forums have been archived and are now read-only.

The new forums are live and can be found at https://forums.eveonline.com/

Linux

 
  • Topic is locked indefinitely.
 

Live video streaming of EVE with Linux

Author
Whitehound
#1 - 2012-04-01 16:54:36 UTC  |  Edited by: Whitehound
For those interested in streaming their EVE session onto the Internet here is how you can do it under Linux.

What you need is a streaming provider like Justin TV and a tool called ffmpeg. There are other providers, but I will use Justin TV as my example.

First you need to get a stream ID or a stream key from your provider. In the case of Justin TV do you need to create an account with them and then click on the big red button that says "Desktop". You will get to a page where you can view your stream key. Your key will look something like this:

live_12345678_AbCdEfGhIjKlMnOpQrStUvWxYZ

All you then need to do is to use the key together with ffmpeg, which will do the rest for you:

AUDIO="-f alsa -ar 44100 -i hw:0"
VIDEO="-f x11grab -s:v 1680x1050 -r 15 -i :0"
FILTER="-aspect 16:10 -filter:v scale=-1:720"
ENCODE="-f flv -codec:v libx264 -threads 4 -g 75"
BITRATES="-b:a 24k -b:v 360k"
STREAM="rtmp://live.justin.tv/app/live_12345678_AbCdEfGhIjKlMnOpQrStUvWxYZ"

ffmpeg -v quiet $AUDIO $VIDEO $FILTER $ENCODE $BITRATES $STREAM


I have broken down the command line into several variables, because it is quiet long and would otherwise be hard to read here on the forum. What it does is this:

It takes the audio from the first ALSA device ("hw:0") at a sample rate of 44.1kHz. The sample rate is important, because the output format does not support all rates, i.e. 48kHz will not work, but 44.1kHz and 22050Hz will.

It takes the video from display :0 at a sample rate of 15 frames/sec with a size of 1680 by 1050.

It scales the input video to a height of 720 at an aspect ratio of 16:10. The height is a standard height for HD video and you can use 480 or 1080, too. It is also possible to leave out this part entirely and to stream at exactly your display resolution, but chances are that your viewers will not be able to make use of it and it will also slow down the encoding process. So best is to choose a reasonable size here before you encode it and send it out.

The video stream gets encoded as a H.264 Flash Video, which is what Justin TV expects. The "-g 75" option stands for a GOP size of 75 and means to encode a full frame every 5 seconds or after every 75 frames (15 fp/s * 5 = 75). This is especially useful when streaming at low bit rates to improve the video quality.

The bit rates used here are 24kbps for audio and 360kbps for the video stream and should together not exceed what your Internet connection is capable of sending upstream. You can set your own bit rates.


One last note, when your EVE session appears to flicker then you may have to set a registry key under WINE:

HKEY_CURRENT_USER\Software\Wine\Direct3D\AlwaysOffscreen = enabled

It forces WINE never to render directly into the frame buffer, which can be a problem for the frame grabber of ffmpeg.

Loss is meaningful. Therefore is the loss of meaning likewise meaningful. It is the source of all trolling.

Sidra Necia
Imperial Academy
Amarr Empire
#2 - 2012-04-26 15:59:00 UTC
Interesting read tnx :)

I take it that you stream ?
If so what hardware do you use ?
Just so that I can get an idea of how much resources it eats up...etc
TWHC Assistant
#3 - 2012-04-26 21:18:15 UTC
Sidra Necia wrote:
Interesting read tnx :)

I take it that you stream ?
If so what hardware do you use ?
Just so that I can get an idea of how much resources it eats up...etc

Not at the moment. My distribution got some sound updates lately involving pulseaudio and it is all new and not everything works. In short, audio is not working when I stream.

I use an AMD Phenom 9850 (quad core, 2.5GHz) with an Nvidia GTX260. I can play EVE at 30 fps when I set it to medium values and stream with 20 fps with a HD720 resolution at the same time (ffmpeg with x264). I do however use a self-compiled ffmpeg and WINE version to get the last bit of FPS out of it. I am pretty much on the edge with my hardware.
Zor'katar
Matari Recreation
#4 - 2012-05-30 19:39:04 UTC  |  Edited by: Zor'katar
Thanks for this. I'm trying to play around a bit with it myself. I based my initial settings on yours, and found that I had to change "-filter:v" to "-vf" and "-codec:v" to "-vcodec" to get it to run (ffmpeg 0.8.1 on Xubuntu Precise).

It seems that it grabs sound from my microphone rather than from the output channel. I'm going through the ffmpeg documentation at the moment, but nothing's jumping out at me. Any idea on that?

(EDIT: Heh, just noticed you mentioned that you've had trouble with audio recently. Besides it grabbing the wrong channel, there's a significant (1-2 sec) delay between audio and video. Are your issues similar, or something completely different?)
Zor'katar
Matari Recreation
#5 - 2012-05-30 21:45:59 UTC
Solved my audio issue... I used:

AUDIO="-f alsa -ar 44100 -i pulse"

and then the next time I ran ffmpeg, I first went up to the volume control, found the setting for the ffmpeg application (under the "Recording" tab in Xubuntu), and set it to use "Monitor of Built-in Audio Analog Stereo" instead of just "Built-in Audio Analog Stereo". Only have to do that the first time... it sticks after that. Now it's properly pulling Eve's sounds instead of the microphone. In addition, 95% of the sync issue appears to have resolved itself.

Seems to be working great. Just uploading a test video to YouTube.