27
Янв
1

Linux: DLNA сервер или домашний медиа-сервер.

После покупки Samsung Smart TV захотелось мне смотреть фильмы прямо с сервера. Почитал различные варианты реализации и остановился на minidlna. B основном из-за его простоты. Итак, приступим:

  1. cd /usr/src
  2. wget "http://ignum.dl.sourceforge.net/project/minidlna/minidlna/1.0.25/minidlna_1.0.25_src.tar.gz" -O minidlna_1.0.25_src.tar.gz
  3. tar -zxvf ./minidlna_1.0.25_src.tar.gz
  4. cd minidlna-1.0.25
  5. aptitude install libavcodec-dev libavformat-dev libflac-dev libvorbis-dev libogg-dev libexif-dev libsqlite3-dev libjpeg-dev libid3tag0-dev
  6. make && checkinstall
  7. cp minidlna.conf /etc/
  8. nano /etc/minidlna.conf

    Вот пример моей конфигурации:

    # port for HTTP (descriptions, SOAP, media transfer) traffic
    port=8200
     
    # network interfaces to serve, comma delimited
    network_interface=eth0
     
    # set this to the directory you want scanned.
    # * if have multiple directories, you can have multiple media_dir= lines
    # * if you want to restrict a media_dir to a specific content type, you
    #   can prepend the type, followed by a comma, to the directory:
    #   + "A" for audio  (eg. media_dir=A,/home/jmaggard/Music)
    #   + "V" for video  (eg. media_dir=V,/home/jmaggard/Videos)
    #   + "P" for images (eg. media_dir=P,/home/jmaggard/Pictures)
    #media_dir=/opt
    media_dir=V,/home/dmitry/data/torrents
    media_dir=V,/home/dmitry/data/media/video
    media_dir=A,/home/dmitry/data/media/audio
     
    # set this if you want to customize the name that shows up on your clients
    friendly_name=sun
     
    # set this if you would like to specify the directory where you want MiniDLNA to store its database and album art cache
    db_dir=/var/cache/minidlna
     
    # set this if you would like to specify the directory where you want MiniDLNA to store its log file
    log_dir=/var/log
     
    # set this to change the verbosity of the information that is logged
    # each section can use a different level: off, fatal, error, warn, info, or debug
    #log_level=general,artwork,database,inotify,scanner,metadata,http,ssdp,tivo=warn
     
    # this should be a list of file names to check for when searching for album art
    # note: names should be delimited with a forward slash ("/")
    album_art_names=Cover.jpg/cover.jpg/AlbumArtSmall.jpg/albumartsmall.jpg/AlbumArt.jpg/albumart.jpg/Album.jpg/album.jpg/Folder.jpg/folder.jpg/Thumb.jpg/thumb.jpg
     
    # set this to no to disable inotify monitoring to automatically discover new files
    # note: the default is yes
    inotify=yes
     
    # set this to yes to enable support for streaming .jpg and .mp3 files to a TiVo supporting HMO
    enable_tivo=no
     
    # set this to strictly adhere to DLNA standards.
    # * This will allow server-side downscaling of very large JPEG images,
    #   which may hurt JPEG serving performance on (at least) Sony DLNA products.
    strict_dlna=no
     
    # default presentation url is http address on port 80
    #presentation_url=http://www.mylan/index.php
     
    # notify interval in seconds. default is 895 seconds.
    notify_interval=30
     
    # serial and model number the daemon will report to clients
    # in its XML description
    serial=12345678
    model_number=1
     
    # specify the path to the MiniSSDPd socket
    #minissdpdsocket=/var/run/minissdpd.sock
     
    # use different container as root of the tree
    # possible values:
    #   + "." - use standard container (this is the default)
    #   + "B" - "Browse Directory"
    #   + "M" - "Music"
    #   + "V" - "Video"
    #   + "P" - "Pictures"
    # if you specify "B" and client device is audio-only then "Music/Folders" will be used as root
    #root_container=.
  9. Теперь необходимо создать скрипт для автозагрузки
    nano /etc/init.d/minidlna

    Со следующим содержимым:

    #! /bin/sh
     ### BEGIN INIT INFO
     # Provides: minidlna
     # Required-Start: $local_fs $remote_fs $syslog $network
     # Should-Start:
     # Required-Stop: $local_fs $remote_fs $syslog $network
     # Should-Stop:
     # Default-Start: 2 3 4 5
     # Default-Stop: 0 1 6
     # Short-Description: Minidlna
     # Description: DLNA Media Server
     ### END INIT INFO
     
     ## EDIT FROM HERE
     
     # Installation details
     MINIDLNA="/usr/sbin/minidlna"
     ARGS="/etc/minidlna.conf"
     
     # Where to keep a log file
     MINIDLNA_LOG="/var/log/minidlna.log"
     
     # Where the PID lives
     PID_FILE="/var/run/minidlna.pid"
     
     ## STOP EDITING HERE
     
     # The path that is to be used for the script
     PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
     
     set -e
     
     # Only start if we can find the minidlna.conf.
     test -x $MINIDLNA || exit 0
     
     # Parse command line parameters.
     case $1 in
     start)
     echo -n "Starting MiniDLNA: "
     $MINIDLNA -f $ARGS -P $PID_FILE >> $MINIDLNA_LOG 2>&1
     echo "ok"
     ;;
     stop) 
     echo -n "Stopping MiniDLNA: "
     for pidf in `/bin/ls $PID_FILE 2>/dev/null`; do
     if [ -s $pidf ]; then
     kill `cat $pidf` >/dev/null 2>&1
     fi
     rm -rf $PIF_FILE
     done 
     echo "ok"
     ;;
     restart|reload|force-reload)
     echo "Restarting MiniDLNA: "
     
     $0 stop
     sleep 2
     $0 start
     
     ;;
     *)
     # Print help
     echo "Usage: /etc/init.d/minidlna {start|stop|restart|reload|force-reload}"
     exit 1
     ;;
     esac
     
     exit 0
  10. Даем права на исполнение
    chmod +x /etc/init.d/minidlna
  11. И добавляем скрипт в автозагрузку
    update-rc.d minidlna defaults
  12. Enjoy!
Понравилась эта запись? Вы можете подписаться на RSS-ленту и читать новые записи сразу после их появления.
1 Комментарий:
  1. Alexander 22 Июл, 2013

    Большое спасибо, очень полезная информация. Как раз сам дома настроить пробую что-то типа этого.

Оставить комментарий