DLNA Linux

From OPPOwiki
Jump to: navigation, search

How-To configure a Linux machine with MiniDLNA to stream to the Oppo BDP-83

Requirements:

  1. A Linux (Fedora, CentOS, Ubuntu, Redhat, etc)
  2. An Oppo BDP-83 with minimum firmware BDP83-48-1224
  3. Media to stream

Begin by downloading the source code from The MiniDLNA Project on SourceForge.net. As of this writing, the current version is minidlna_1.0.16.3_static.tar.gz .

From a terminal window:

As root, move the source file into the '/' directory.

`mv /home/myuser/path/to/minidlna_1.0.16.3_static.tar.gz /`

Then, extract the files in the gzipped file:

`tar zxvf /minidlna_1.0.16.3_static.tar.gz`

There are two files that get installed in the following locations:

|__ etc
|   |__ minidlna.conf
|
|__ usr
    |__ sbin
        |__ minidlna

Change the ownership of the files to root:

`chown root:root /etc/minidlna.conf /usr/sbin/minidlna`

Almost done, next, we need to modify the minidlna.conf file. Using nano, or gedit, open the /etc/minidlna.conf file: Change the following directives to match your environment:

First, we need to make sure the service is listening on the correct interface.

#network_interface=eth0
network_interface=wlan0

Next, setup the directories you want to share.


# 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=A,/home/myuser/mp3
media_dir=A,/path/to/big/usb_drive/music
media_dir=V,/path/to/big/NAS/video
media_dir=P,/path/to/Pictures

You should now be able to start minidlna with the following command:

`/usr/sbin/minidlna`

Here is an init.d script for Redhat/CentOS/Fedora based systems. Put this in /etc/init.d, name it minidlna, chmod it to 775 and add it to chkconfig.

#! /bin/sh

# chkconfig: 345 99 10
# description: Fedora Startup/shutdown script for MiniDLNA daemon

# If you have chkconfig, simply:
# chkconfig --add minildna

# Proper init scripts on Linux systems normally require setting lock
# and pid files under /var/run as well as reacting to network
# settings, so you should treat this with care.

# Original author:  Perry Clark <omfgppc (at) gmail.com>

## 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

Pandora / other streaming media ideas: parse /tmp for new (completed loading) files for file in find /tmp -name Flash* do cp $file $HOME/stream/cache/$file.aac ffmpeg $file.aac $HOME/stream/music/$file.mp3 rm -rf $HOME/stream/cache/$file.aac done

DLNA share the $HOME/stream/music directory...

Problem: need to figure out how to know when the file is done being written in /tmp possible solutions: lsof fsniper - files are gone by the time fsniper knows... proper find command - may miss files, or if using access times, need proper syntax ... To me, this seems easy enough for Oppo to include a lightweight browser with direct pandora support. Maybe not as low hanging fruit as I think though. I did get it working decently with a similar solution to above using DLNA, bash script and cron job. Need to work on my find script.

Here's an example shell script, not for production usage :)

#!/bin/bash

TMP=/tmp
PREFIX=Flash

#for file in `find $TMP -mmin 1 -name ${PREFIX}*`
for file in `find $TMP -name ${PREFIX}* 2>/dev/null`
# for file in `ls $TMP/$PREFIX*`
# file file in `lsof $TMP/$PREFIX*`
  do 
  CLEAN=`echo $file | cut -d "/" -f 3`
  #   echo `file $file`
  #	 echo $CLEAN
  VERSION=`file $file | cut -d " " -f 8`

if [ ${VERSION} != "1" ]; then
	 if [ -e $HOME/stream/music/${CLEAN}.mp3 ]; 
	   then 
	     echo -n "$HOME/stream/music/${CLEAN}.mp3 exists skipping..."
	   else
	     # echo -n "linking $file to $HOME/stream/music/${CLEAN}.aac "
	     # ln -s ${file} $HOME/stream/music/${CLEAN}.aac
		 cp ${file} $HOME/stream/cache/${CLEAN}.aac
		 # ffmpeg -i $HOME/stream/cache/${CLEAN}.aac $HOME/stream/music/${CLEAN}.mp3
		 # rm -rf $HOME/stream/cache/${CLEAN}.aac

	 fi
else
    if [ -e $HOME/stream/video/${CLEAN}.mpg ]; 
	   then 
	     echo -n "$HOME/stream/video/${CLEAN}.mpg exists skipping..."
	   else
	     echo -n "linking $file to $HOME/stream/video/${CLEAN}.mpg "
	     ln -s ${file} $HOME/stream/video/${CLEAN}.mpg
		 cp ${file} $HOME/stream/cache/${CLEAN}.mpg 
	 fi
fi	 
  done;
Personal tools