본문 바로가기
서버 및 보안

Universal Media Server

by 다움위키 2023. 12. 23.

Universal Media ServerDLNA-호환 UPnP 미디어 서버입니다. 그것은 PS3 Media Server의 포크로 시작되었습니다. 그것은 비디오 게임 콘솔, 스마트 TV, 스마트폰, 및 블루-레이 플레이어를 포함한 다양한 장치로 미디어 파일의 스트리밍을 허용합니다. 그것은 렌더링 장치에 대한 네트워크 연결을 통해 멀티미디어 파일을 스트리밍과 코드 변환하여 지원되는 렌더링 장치가 장치에서 지원하는 형식으로 콘텐츠를 수신하도록 합니다. 트랜스코딩은 AviSynth, FFMpeg, MEncoder, 및 VLC의 패키지를 통해 수행됩니다.

그것의 이전 버전, PS3 Media Server보다 향상된 기능은 비-DLNA 장치에 대해 웹 인터페이스 지원, 더 많은 지원되는 렌더러, 자동 비트 전송률 조정, 및 기타 많은 트랜스코딩 개선 사항을 포함합니다.

Installation

아래 이전 방법은 Initd를 사용하는 방법이며, 여기서는 Systemd를 사용하는 방법으로 설치해 보고자 합니다. 원 저자는 CentOS에서 설치/설정하는 과정을 보여주고 있습니다. 아래 과정까지는 첫 번째 방법과 같습니다.

  • sudo mv ums-5.2.2 /usr/ums

이후에 과정은 다음과 같습니다.

  • sudo mkdir /etc/ums
  • sudo mkdir /etc/ums/data
  • sudo cp UMS.conf WEB.conf /etc/ums
  • sudo useradd -d /usr/ums -s /usr/sbin/nologin ums
  • sudo chown -R ums:ums /usr/ums
  • sudo chown -R ums:ums /etc/ums
  • sudo nano /etc/systemd/system/ums.service
[Unit]
Description=Universal Media Server

[Service]
Type=simple
Environment="UMS_PROFILE=/etc/ums/UMS.conf"
User=ums
Group=ums
ExecStart=/usr/ums/UMS.sh

[Install]
WantedBy=multi-user.target
  • sudo systemctl daemon-reload
  • sudo systemctl enable ums
  • sudo systemctl start ums

Ums 설정에 오류가 없는지 확인하는 과정입니다.

  • sudo systemctl status ums
  • sudo journalctl _SYSTEMD_UNIT=ums.service

오류 메시지가 보이지 않는다면, 아래와 같은 명령으로 열린 포트를 확인할 수 있습니다.

  • sudo netstat -npl | grep java
tcp        0      0 192.168.200.140:5001    0.0.0.0:*               LISTEN      832/java        
tcp        0      0 0.0.0.0:9001            0.0.0.0:*               LISTEN

웹 브라우저를 실행한 후 http://localhost:9001로 접근하면 Ums 로고와 Browse the media on Ubuntu라는 메시지를 볼 수 있습니다.

이전 방법

Plex 미디어 서버는 deb 패키지가 있으므로 설치가 쉽습니다. 그렇지만 기능적인 면에서 보면 Universal Media Server가 더 좋다고 합니다. 프로그램이 타르볼로 제공되기 때문에 수작업으로 설치를 해야 합니다. 포럼에서 정보를 얻을 수 있습니다.

  • sudo add-apt-repository ppa:webupd8team/java
  • sudo apt-get update
  • sudo apt-get install oracle-java7-installer
  • sudo apt-get install oracle-java7-set-default

오라클 자바가 성능이 낫다는 말이 있는데 확신할 수 없으므로 오픈 자바를 사용하셔도 좋습니다. 오픈 자바를 사용하신다면 위 과정은 생략하고 아래와 같이 설치 진행합니다.

  • sudo apt-get install openjdk-7-jre-headless
  • sudo apt-get install mediainfo dcraw vlc-nox mplayer2 ssh

안타깝게도 mplayer가 데비안 패키지에서 빠지면서 필요한 mencoder 설치하기가 힘들어졌습니다. 아직까지 성공하지 못했습니다.

#!/bin/bash
#
### BEGIN INIT INFO
# Provides: ums
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $local_fs $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts UMS program.
# Description: Java Upnp Media Server dedicated to PS3
### END INIT INFO

#set -x

# Author: Papa Issa DIAKHATE <paissad@gmail.com>
#
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="Universal Media Server"
NAME=ums
UMS_PROFILE=/etc/ums
DAEMON=/usr/ums/UMS.sh
DAEMON_OPTS="console"
SCRIPTNAME=/etc/init.d/ums
UMS_START=1 # Wether to start or not UMS ver at boot time.
DODTIME=30  # Time to wait for the server to die, in seconds.
            # If this value is set too low you might not
            # let the program to die gracefully and 'restart' will not work

test -x $DAEMON || exit 1

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

# Include ums defaults if available
if [ -f "/etc/default/$NAME" ] ; then
        . /etc/default/$NAME
fi

# May we run the init.d script ?
[ $UMS_START = 1 ] || exit 1

#--------------------------------------------------------------------------
# Some color codes
txtred=$'\e[0;31m' # Red
txtylw=$'\e[0;33m' # Yellow
txtrst=$'\e[0m'    # Text Reset
#--------------------------------------------------------------------------
warnout(){
    echo >&2 -e ""$txtylw"Warning:$txtrst $1"
}
#--------------------------------------------------------------------------
running(){
    pid=`pgrep -f 'java .*ums.jar.*'`
}
#--------------------------------------------------------------------------
do_start(){
    running && { warnout "$NAME is already running !"; exit 0; }
    echo "Starting $DESC : $NAME"
    UMS_PROFILE="$UMS_PROFILE" start-stop-daemon --start --quiet --background --oknodo \
        --exec $DAEMON -- $DAEMON_OPTS

}
#--------------------------------------------------------------------------
do_stop(){
    running || { warnout "$NAME is NOT running !"; exit 0; }   
    local countdown="$DODTIME"
    echo -e "Stopping $DESC : $NAME \c "
    kill -9 $pid
    while running; do
        if (($countdown >= 0)); then
            sleep 1; echo -n .;
            ((--countdown))
        else
            break;
        fi
    done
    echo
    # If still running, then try to send SIGINT signal
    running && { \
        echo >&2 "Using kill -s SIGINT instead"; \
        echo >&2 "If you see this message again, then you should increase the value of DODTIME in '$0'."; \
        kill -2 $pid; \
    }

    if [ -e "/usr/share/ums/debug.log" ]; then
    count=9
    while [ $count -ge 1 ]
    do
    if [ -e "/usr/share/ums/debug.log.$count" ]; then
        plus=$((count+1))
        mv "/usr/share/ums/debug.log.$count" "/usr/share/ums/debug.log.$plus"
    fi
        count=$((count-1))
    done
    if [ -e "/usr/share/ums/debug.log" ]; then
        mv "/usr/share/ums/debug.log" "/usr/share/ums/debug.log.1"
    fi
    fi

    return 0
}
#--------------------------------------------------------------------------
do_force-stop(){
    running || { warnout "$NAME is NOT running !"; exit 0; }   
    echo "Stopping $DESC : $NAME"
    kill -9 $pid
    if [ -e "/usr/share/ums/debug.log" ]; then
    count=9
    while [ $count -ge 1 ]
    do
    if [ -e "/usr/share/ums/debug.log.$count" ]; then
        plus=$((count+1))
   mv "/usr/share/ums/debug.log.$count" "/usr/share/ums/debug.log.$plus"
    fi
       count=$((count-1))
    done
    if [ -e "/usr/share/ums/debug.log" ]; then
   mv "/usr/share/ums/debug.log" "/usr/share/ums/debug.log.1"
    fi
    fi
}
#--------------------------------------------------------------------------
do_status(){
    echo -n " * $NAME is "
    ( running || { echo "NOT running "; exit 0; } )
    ( running && { echo "running (PID -> $(echo $pid))"; exit 0; } )
}
#--------------------------------------------------------------------------
case "$1" in

    start|stop|force-stop|status)
        do_${1}
        ;;
    restart|reload)
        do_stop
        do_start
        ;;
    force-restart|force-reload)
        do_force-stop
        do_start
        ;;
    *)
        echo "Usage: $SCRIPTNAME {start|stop|force-stop|restart|force-restart|reload|force-reload|status}"
        exit 1
        ;;
esac
  • sudo chmod +x /etc/init.d/ums
  • sudo update-rc.d ums defaults
  • sudo service ums start
  • sudo service ums stop
  • sudo gvim /usr/ums/UMS.conf

필요한 부분이 있다면 설정을 바꿀 수 있습니다.

External links