Server

Configuration of Emu Server is achieved by editing the ".cfg" files found in the "%APPDATA%\Emu\Server" folder, using a text editor such as Notepad. Example settings files are placed here during installation but you will need to modify these to suit your environment before the system will become usable.

Emu Server can operate in two main modes, as an Accounts Server and as a Streaming Server.

An Accounts Server maintains a directory of users and their passwords (see Account Directory) together with a directory of Streaming Servers for each user which determines which servers a user is allowed to connect to (see Server Directory).

A Streaming Server maintains a directory of streaming sources and various settings defining how each source is encoded and controlled (see Source Directory).

Although the Accounts and Streaming modes are conceptually different, in practice it is likely that the same Emu Server instance will be operating as both Accounts Server and Streaming Server. The separation exists to provide scope for more elaborate setups involving multiple Streaming Servers at different locations and a separate dedicated Accounts Server.

Emu Server can also optionally operate in a third mode as a Relay Server. Setting up one or more Relay Servers can be of benefit to long-distance streaming. A Relay Server maintains a directory of mappings that specify how connections on incoming ports are relayed to Streaming Servers or other Relay Servers (see Relay Directory).

General settings

General settings that apply to all server operating modes are defined in the "settings.cfg" file found in the "%APPDATA%\Emu\Server" folder.

Setting Type Description
player_listen_port 1-65535 The port number to listen on for incoming player connections.
log_to_file true or false Set to true to write to %APPDATA%\Emu\Server\logs\log.txt.
verbosity 0-2 Controls the amount of information written to the log file.

Notes:

  • In common scenarios the server will be behind a firewall and port forwarding will need to be setup on the router to allow a remote player to open a connection to the server on the "player_listen_port". A good resource to help you configure your router is portforward.com.
  • Setting "log_to_file" to false will cause all logging information to be written to standard output instead of the log file.

Source directory

The Source Directory defines the sources the server can capture and control and is defined in the "settings.cfg" file found in the "%APPDATA%\Emu\Server" folder.

A Source Directory is required for the Streaming operating mode.

Setting Type Description
display_name text The main name displayed in the user-interface.
logo filename The logo displayed next to the display name.
hidden true or false Set this to true to hide the source from view.
video_device text The name of the DirectShow video capture device.
audio_device text The name of the DirectShow audio capture device.
audio_delay seconds Set this to a positive value to add an audio delay.
platforms text A comma separated list of supported player platforms.
video_profiles (various) See below.
ir_server_host xx.xx.xx.xx The host name or ip address of the IR server.
ir_server_port 1-65535 The port number the IR server is listening on.
ir_server_proto text The IR server protocol, either "irtrans" or "lirc".
remote_name text The name of the IR server remote control.
remote_codes (various) See below.
favourites (various) See below.

The following platforms can be specified:

Platform Description
pc Indicates the source can be used by desktop playback devices (PC, Mac and Linux).
ios Indicates the source can be used by iOS playback devices (iPhone and iPad).
tvos Indicates the source can be used by tvOS playback devices (Apple TV).

Notes:

  • See DirectShow Devices for details of how to identify the correct names to enter into the "video_device" and "audio_device" fields.

video_profiles

This sub-section defines sets of capture and encode settings. Up to four video profiles can be defined for a source and the user can switch between them in Emu Player as desired. The profiles must be listed in descending order of quality.

Setting Type Description
resolution text The DirectShow video capture resolution requested.
framerate 1-60 The DirectShow video capture framerate requested.
interlaced true or false Set this to true if the captured video is interlaced.
encode_params text A comma separated list of the encoding parameters.
encode_crf 0-51 Set this to a positive value to enable CRF encoding.
encode_vb kbps Set this to a positive value to specify the video bitrate.
encode_bufsize kbps Set this to a positive value to specify the buffer size.
encode_maxrate kbps Set this to a positive value to specify the max bitrate.
encode_gop 0-250 Set this to a positive value to specify the GOP size.
encode_ab kbps Set this to a positive value to specify the audio bitrate.
encode_volume 0.0-1.0 Adjust the audio volume by this factor when encoding.
encode_threads 0 or above Set this to a positive value to specify encode threads.

The following encoding parameters can be specified:

Parameter Description
x264 Encode the video using the x264 software h.264 encoder.
x265 Encode the video using the x265 software h.265 encoder.
nvenc_h264 Encode the video using the NVIDIA hardware h.264 encoder.
nvenc_hevc Encode the video using the NVIDIA hardware h.265 encoder.
aac Encode the audio using the AAC software encoder.
good Encode the video at higher quality but more slowly.
fast Encode the video at lower quality but more quickly.
900 Scale the video down to 1600x900 resolution (HD).
720 Scale the video down to 1280x720 resolution (HD).
648 Scale the video down to 1152x648 resolution (SD).
576 Scale the video down to 1024x576 resolution (SD).
540 Scale the video down to 960x540 resolution (SD).
504 Scale the video down to 896x504 resolution (SD).
432 Scale the video down to 768x432 resolution (SD).
360 Scale the video down to 640x360 resolution (SD).
288 Scale the video down to 512x288 resolution (SD).
yadif1x Deinterlace the video using the yadif1x video filter.
yadif2x Deinterlace the video using the yadif2x video filter.
w3fdif Deinterlace the video using the w3fdif video filter.
yuv420p Encode the video using the yuv420p pixel format.
yuv422p Encode the video using the yuv422p pixel format.
yuv444p Encode the video using the yuv444p pixel format.
nv12 Encode the video using the nv12 pixel format.
dup Convert the video to 60fps using frame duplication.
blend Convert the video to 60fps using frame blending.
mci Convert the video to 60fps using motion compensation.

Notes:

  • The resolution, framerate and interlaced settings should match the source's output. For example in the UK, a Sky+ HD box normally outputs 1080i50 so the resolution would be set to "1920x1080", the framerate to "50" and interlaced to "true".
  • Any automatic resolution switching feature on the STB should be disabled and the output fixed to either 1080i or 720p.
  • If no video encoder (x264, x265, nvenc_h264 or nvenc_hevc) is specified then the video stream is passed through unchanged and all other video encoding parameters are ignored.
  • If no audio encoder (aac) is specified then the audio stream is passed through unchanged and all other audio encoding parameters are ignored.
  • The "good" video quality is equivalent to the highest quality two-pass setting for the NVIDIA encoders and the Medium profile for the x264 and x265 encoders.
  • The "fast" video quality is equivalent to the highest quality one-pass setting for the NVIDIA encoder and the Superfast profile for the x264 and x265 encoders.
  • If no video quality (good or fast) is specified then the encoder defaults to encoding the video as if the "fast" video quality was specified.
  • If no video scaling (900, 720, 648, 576, 540, 504, 432, 360 or 288) is specified then the video stream is encoded at the same size as it was captured.
  • If no deinterlacing (yadif1x, yadif2x or w3fdif) is specified for an interlaced source then the video stream is encoded as interlaced and deinterlaced by the player. This scenario is only supported when using the x265 encoder, however.
  • If no pixel format (yuv420p, yuv422p, yuv444p or nv12) is specified then a suitable pixel format is chosen automatically by the server depending on the capture format and the encoder.
  • The "nvenc_h264" and nvenc_hevc" video encoders require a compatible NVIDIA GPU to be installed.

remote_codes

This sub-section assigns IR server commands to remote STB commands. The template settings file contains a list of all the possible remote STB commands.

favourites

This sub-section defines the favourite channels for the source.

Setting Type Description
name text The name of the channel. This is not displayed.
channel text The channel number that switches to the channel.
show_channel true or false Set this to true to display the channel number.
logo filename The channel logo displayed on the channel button.

Notes:

  • Ideally the logo should include the name of the channel but if a more generic logo is used instead then setting the "show_channel" field to true will display the channel number underneath the logo.
  • A good source for TV station and channel logos is LyngSat Logo. Adding favourite channels and logos to the settings file is recommended as it greatly improves the visual appeal and usability of the player.

Account directory

The Account Directory defines the names and passwords of users that can access the server and is defined in the "settings.cfg" file found in the "%APPDATA%\Emu\Server" folder.

An Account Directory is required for both Accounts and Streaming operating modes.

Setting Type Description
user_name text The name of the user.
password text The user's password.

Server directory

The Server Directory defines the servers that a user can connect to and is defined in the "server_directory.cfg" file found in the "%APPDATA%\Emu\Server\accounts\username" folder where "username" must match a user name defined in the Account Directory.

A Server Directory is required for the Accounts operating mode.

Setting Type Description
display_name text The main name displayed in the user-interface.
logo filename The logo displayed next to the display name.
server_host xx.xx.xx.xx The host or ip address of the server.
server_port 1-65535 The port number the server is listening on.
route_name text See below.
group_id 0 or above See below.

Notes:

  • Unless you are configuring intermediate Relay Servers, the "route_name" field should be left blank and the "group_id" field should be set to zero.

Relay directory

In most situations it is best for the player to connect directly to the Streaming Server, however sometimes it is beneficial to relay the stream via an intermediate server. One reason might be to mitigate the problem of high latency or packet loss encountered when streaming over a long distance; by using a Relay Server the route is split into two or more lower latency segments which may improve performance. Another reason might be to force the stream to take a route away from known network bottlenecks.

The Relay Directory defines how incoming connections from a player are relayed to Streaming Servers or other Relay Servers and is defined in the "settings.cfg" file found in the "%APPDATA%\Emu\Server" folder.

Setting Type Description
listen_port 1-65535 The port number the server is listening on.
forward_host xx.xx.xx.xx The host or ip to forward the connection to.
forward_port 1-65535 The port number to forward the connection to.

Notes:

  • Once a Relay Server has been setup it can then be added as another server in a user's Server Directory, except that instead of specifying the host and port of the Streaming Server in the "server_host" and "server_port" fields, those of the Relay Server should be entered instead.
  • The "route_name" field should be set to something identifying the route taken (for example, if the Relay Server is located in Paris you might enter "via Paris").
  • The same "group_id" should be given to all entries in the Server Directory that lead to the same Streaming Server, whether via a Relay Server or a direct connection.
  • Using the same "group_id" forces the player to treat the group of servers as a single entity, monitoring the latency of each segment of each route and selecting the best one, while the information entered in the "route_name" field is used to indicate within the user-interface which route is currently optimal.

DirectShow Devices

When configuring a Streaming Server you will need to know the name of the DirectShow video and audio capture devices so that they can be entered into the settings file. You can use the FFmpeg executable included with Emu Server to retrieve this information as shown here.

Open a command prompt, navigate to the folder where Emu Server was installed and type the following command:

c:\Program Files\Emu Server>ffmpeg -list_devices true -f dshow -i dummy

FFmpeg should output something similar to the below.

ffmpeg version N-81990-ga2c5f5a Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.4.0 (GCC)
configuration: --enable-gpl --enable-version3 --enable-static --enable-libx264 --enable-libx265 --enable-nvenc --disable-w32threads --disable-debug
libavutil 55. 32.100 / 55. 32.100
libavcodec 57. 61.103 / 57. 61.103
libavformat 57. 52.100 / 57. 52.100
libavdevice 57. 0.102 / 57. 0.102
libavfilter 6. 64.100 / 6. 64.100
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 2.100 / 2. 2.100
libpostproc 54. 0.100 / 54. 0.100
[dshow @ 000002043cc924a0] DirectShow video devices (some may be both video and audio devices)
[dshow @ 000002043cc924a0] "XI100DUSB-HDMI Video"
[dshow @ 000002043cc924a0] Alternative name "@device_pnp_\\?\usb#vid_2935&pid_0001&mi_00#6&b4fe70b&0&
0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global"
[dshow @ 000002043cc924a0] DirectShow audio devices
[dshow @ 000002043cc924a0] "Digital Audio Interface (XI100DUSB-HDMI Audio)"
[dshow @ 000002043cc924a0] Alternative name "@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\wave_{BF1C03DB-75C1-40DA-B1F1-47551060A36A}"
dummy: Immediate exit requested

The above output lists a video device named "XI100DUSB-HDMI Video" and an audio device named "Digital Audio Interface (XI100DUSB-HDMI Audio)" and this is what would be entered into the "video_device" and "audio_device" fields of the Source Directory respectively, for this capture device.

Service Mode

Once the server has been successfully configured and tested it is recommended to run it as a Windows service so that it doesn't display an output window on the desktop and starts automatically each time Windows boots.

To install Emu Server as a Windows service, open a command prompt as administrator, navigate to the folder where Emu Server was installed and type the following command:

c:\Program Files\Emu Server>emu-server.exe install

To start the service type:

c:\Program Files\Emu Server>emu-server.exe start

To stop the service type:

c:\Program Files\Emu Server>emu-server.exe stop

To uninstall the service type:

c:\Program Files\Emu Server>emu-server.exe uninstall

Note that when running as a service, Emu Server looks for the settings files in the application data folder for the system user instead of the current user. For example, on Windows 10 this folder is located at "C:\WINDOWS\System32\config\systemprofile\AppData\Roaming".

Therefore when switching to service mode it is necessary to move the "Emu\Server" folder from its old location inside "%APPDATA%" to its new location described above.

© 2017 Beard Cat Baby Bat Ltd. All Rights Reserved.