PDA

View Full Version : [Howto] Install DLNA media servers for Oleg firmware



ecaddict
28-10-2011, 11:25
After you've installed basic optware to the router using e.g. the Raas image directly or indirectly using my tutorial (http://wl500g.info/showthread.php?t=23684)DLNA could be the next step.

A router with 128MB RAM (RT-N16, WL-500gP or WL-500W with RAM upgrade) is recommended if you plan to run many other programs as well.

If you don't know what DLNA is just check the Wiki (http://en.wikipedia.org/wiki/Digital_Living_Network_Alliance).

The basic idea is that media servers (like the router) provide media to media player (like your TV, media player etc.) controlled by controller (like your PDA, mobile etc.)
There are many different options, the most popular being: mediatomb, minidlna and twonky.
You can install all, and disable what you don't like.

mediatomb (special thanks to rathalian and ignatz)
Original thread (http://wl500g.info/showthread.php?t=13963)

Just copy-paste as such:

cd /opt/share/file; [ ! -f magic.old ] && mv magic magic.old
ipkg update; ipkg install readline mediatomb
mkdir -p /opt/etc/mediatomb
mkdir -p /usr/local/root/.mediatomb
flashfs save && flashfs commit && flashfs enable
sed -i 's/MT_USER="root"/MT_USER="admin"/' /opt/etc/mediatomb.conf
sed -i 's/MT_ENABLE=false/MT_ENABLE=true/' /opt/etc/default/mediatomb
cd /opt/share/mediatomb
cat sqlite3.sql | sqlite3 mediatomb.db
mv mediatomb.db /opt/etc/mediatomb/
/opt/etc/init.d/S90mediatomb start
/bin/ps | grep mediatomb


MediaTomb web interface: http://192.168.1.1:50500/

More about MediaTomb: http://mediatomb.cc/

minidlna (special thanks to shantanugoel)
Original thread (http://wl500g.info/showthread.php?t=25942)

If you prefer not to compile it, fetch my compiled version and extract it on the router. 8426.

Copy-paste the following script and it will do everything (build also if you did not download the above binary version, however it can take half an hour in case of slow router):

#!/bin/sh
#written by ecaddict, distributed (conveyed) under GPL version 3 or any later version

MDIR=/mnt/protected/Storage
DDIR=/opt/var/cache/minidlna
STARTS=/opt/etc/init.d/S90minidlna
BDIR=/mnt/dev/minidlna
#user editable part end

EXSD=/bin/sed
DCONF=/opt/etc/minidlna.conf
DBIN=/opt/sbin/minidlna
LDIR=/opt/var/log

ipkg update
ipkg install libvorbis libogg libid3tag libexif libjpeg ffmpeg flac

if [ ! -x ${DBIN} ] || [ ! -f /opt/etc/minidlna.conf ]; then
ipkg install buildroot optware-devel unzip
ipkg remove wget
ipkg install wget-ssl
mkdir -p ${BDIR} && cd ${BDIR}
wget --no-check-certificate https://github.com/shantanugoel/minidlna-asus/zipball/asus
unzip asus && rm asus
cd shantanugoel-minidlna*
make
export INSTALLPREFIX=/opt
export DESTDIR=/opt
make install
fi

mkdir -p ${MDIR}
mkdir -p ${DDIR}
mkdir -p ${LDIR}
${EXSD} -i 's%^media_dir=.*%media_dir='''${MDIR}'''%' ${DCONF}
${EXSD} -i 's%^#db_dir.*%db_dir='''${DDIR}'''%' ${DCONF}
${EXSD} -i 's%^#log_dir.*%log_dir='''${LDIR}'''%' ${DCONF}

cat > ${STARTS} << __EOF__
#!/bin/sh
#written by ecaddict, distributed (conveyed) under GPL version 3 or any later version

CONF=${DCONF}
EXDL=${DBIN}

NAME="\${EXDL##*/}"
OPTS="-f \${CONF}"

if [ -z "\$1" ] ; then
case \${0##*/} in
S??*) rc="start" ;;
K??*) rc="stop" ;;
*) rc="usage" ;;
esac
else
rc="\$1"
fi

case "\$rc" in
start)
if [ ! -x \${EXDL} ];then
echo -e "\\033[1;31mMinidlna is missing: "\$EXDL"\\033[0m"
exit 1
fi
if [ ! -f \${CONF} ];then
echo -e "\\033[1;31mConfig file "\$CONF" is missing\\033[0m"
exit 2
fi
if [ -n "\$(pidof \$NAME)" ]; then
echo -e "\\033[1;33m\$NAME runs already\\033[0m"
exit 3
fi
echo "Starting \$NAME"
\${EXDL} \${OPTS}
;;
stop)
if [ -n "\$(pidof \$NAME)" ]; then
echo "Stopping \$NAME"
killall \$NAME 2> /dev/null
fi
;;
restart)
"\$0" stop
sleep 5
"\$0" start
;;
*)
echo "Usage: \$0 (start|stop|restart|usage)"
;;
esac
__EOF__
chmod u+x ${STARTS}
${STARTS} start


8471
My usual single line install:

cd /tmp && wget -O installm.tar.gz "http://wl500g.info/attachment.php?attachmentid=8471&d=1321546056" && tar xvzf installm.tar.gz && ./install.sh && rm install*

Config adjustments in /opt/etc/minidlna.conf

It has no web IF but you may try (I have not used it):
http://minidlnawebmin.sourceforge.net/

twonkymedia (special thanks to wpte)
Original thread (http://wl500g.info/showthread.php?t=22549)
Wiki about install (http://www.twonkyforum.com/mediawiki/index.php/Asus_Routers_-_Oleg_FW).

Install script (that you may copy-paste as such):

#!/bin/sh
#written by ecaddict, distributed (conveyed) under GPL version 3 or any later version

INSTDIR=/opt/twonkymedia
MDIR=/mnt/protected/Storage
STARTS=/opt/etc/init.d/S90twonkymedia
TINST=twonkymedia-asus-6.0.37.zip
MDTD=${MDIR}/twonkymedia
#user editable part end

EXSD=/bin/sed
DBIN=${INSTDIR}/twonkymedia
DCONF=${INSTDIR}/twonky-config/twonkymedia.ini
CONFD="${DCONF%\/*}"
DBDIR=${INSTDIR}/db
ODDIR=${INSTDIR}/online-data
STDIR=${INSTDIR}/media-statistics
CB=${INSTDIR}/cgi-bin

ipkg update
ipkg install libvorbis libogg libid3tag libexif libjpeg unzip
#ipkg install flac ffmpeg imagemagick

if [ ! -x "${DBIN}" ]; then
mkdir -p ${INSTDIR} && cd ${INSTDIR}
mkdir -p ${DBDIR}; mkdir -p ${CONFD}; mkdir -p ${ODDIR}; mkdir -p ${STDIR}
mkdir -p ${MDTD}
TVER=$(echo $TINST | ${EXSD} -n 's/[^0-9]*\(.*\).zip/\1/p')
wget http://www.twonkyforum.com/downloads/${TVER}/${TINST}
unzip twonkymedia-asus-6.*.zip
rm -f readme.txt twonkymedia-asus-6.*.zip nas* install.nas
chmod +x twonkym* cgi-bin/* plugins/* resources/*
echo "/opt/bin" > ${CB}/ffmpeg.location
echo "/opt/bin" > ${CB}/convert.location
echo "/opt/bin" > ${CB}/flac.location
fi

cat > ${DCONF} << __EOF__
contentbase=/
contentdir=+A|${MDIR}
dbdir=${DBDIR}
onlinedir=${ODDIR}
mediastatisticsdir=${STDIR}
servermanagedmusicdir=${MDTD}
servermanagedpicturedir=${MDTD}
servermanagedvideodir=${MDTD}
friendlyname=Twonky Asus
httpport=9000
enableweb=2
scantime=60
maxmem=5000
startupmb=0
norescale=1
platform=Asus router
suppressmenu=divAutoShare
ip=$(nvram get lan_ipaddr)
__EOF__

cat > ${STARTS} << __EOF__
#!/bin/sh
#written by ecaddict, distributed (conveyed) under GPL version 3 or any later version

SDIR=${INSTDIR}
CONF=${DCONF}
EXDL=${DBIN}

NAME="\${EXDL##*/}"
OPTS="-D -inifile \${CONF}"

if [ -z "\$1" ] ; then
case \${0##*/} in
S??*) rc="start" ;;
K??*) rc="stop" ;;
*) rc="usage" ;;
esac
else
rc="\$1"
fi

case "\$rc" in
start)
if [ ! -x \${EXDL} ];then
echo -e "\\033[1;31mTwonkymedia is missing: "\$EXDL"\\033[0m"
exit 1
fi
if [ ! -f \${CONF} ];then
echo -e "\\033[1;31mConfig file "\$CONF" is missing\\033[0m"
exit 2
fi
if [ -n "\$(pidof \$NAME)" ]; then
echo -e "\\033[1;33m\$NAME runs already\\033[0m"
exit 3
fi
echo "Starting \$NAME"
cd \${SDIR} && \${EXDL} \${OPTS}
;;
stop)
if [ -n "\$(pidof \$NAME)" ]; then
echo "Stopping \$NAME"
killall \$NAME 2> /dev/null
fi
;;
restart)
"\$0" stop
sleep 5
"\$0" start
;;
*)
echo "Usage: \$0 (start|stop|restart|usage)"
;;
esac
__EOF__
chmod u+x ${STARTS}
${STARTS} start


8451
My usual single line install:

cd /tmp && wget -O installt.tar.gz "http://wl500g.info/attachment.php?attachmentid=8451&d=1320263226" && tar xvzf installt.tar.gz && ./install.sh && rm install*

Config adjustment in: /opt/twonkymedia/twonky-config/twonkymedia.ini
It has a rather slow web interface during media scan, but it works:
http://192.168.1.1:9000

It's possible to start and run all 3 at the same time, however most probably you don't need to and it can also use quite some memory and CPU time (even with powerful routers like the RT-N16 with 128MB RAM).
After tried what works for you, you can disable automatic start by renaming the /opt/etc/init.d/S90... script to DS90... (as only services starting with S... started). stop/start to the scripts work for manual stop/start.

Unfortunately I cannot answer which works for you as it depends on your player and your preferences.

Enjoy!

ecaddict
28-10-2011, 11:28
reserved for continuation

ecaddict
28-10-2011, 12:13
Does someone know how to correct typo I've made in the title?

wpte
28-10-2011, 15:51
Does someone know how to correct typo I've made in the title?

What is the typo?
perhaps as mod I'm able to fix it:)

slow twonky web interface? :s
perhaps it is while it's still scanning for media...
apart from that it is smooth for me :)

ecaddict
28-10-2011, 18:52
Intall DLNA -> Install DLNA

Thank you if you can fix it.

Maybe you're right, it was still scanning media.

Btw. when I start twonkymedia there is a zombie left, e.g.:

17265 ? Z 0:00 \_ [mediafusion-int] <defunct>
Search in the net shows that it's considered normal for Linux version (I don't think so); does it happen also when you start it? Is there any way to prevent it?

wpte
28-10-2011, 19:19
Intall DLNA -> Install DLNA

Thank you if you can fix it.

Maybe you're right, it was still scanning media.

Btw. when I start twonkymedia there is a zombie left, e.g.:

17265 ? Z 0:00 \_ [mediafusion-int] <defunct>
Search in the net shows that it's considered normal for Linux version (I don't think so); does it happen also when you start it? Is there any way to prevent it?

fixed:)

I have that too... but since it does not use any cpu time (or nearly none) over hours of time it doesn't affect the performance significantly :)

lskarda
25-11-2011, 08:31
Mod: please don't include the entire how-to as a quote...

Thak you very well for these scripts :-)

I have TV Samsung and this brand have many problems with some Media Servers.

I tried install MediaTomb. It works great, but I dont see it on my Samsung TV.

Then I tried MiniDLNA. I see it on TV, but not content of my library.
In log I see:

inotify.c:189: warn: WARNING: Could not read inotify max_user_watches! Hopefully it is enough to cover 0 current directories plus any new ones added.

What is wrong?

Thank you.

Ludek

ecaddict
25-11-2011, 09:19
Are you sure that your media files are located in the directory that's indicated in the minidlna config file, /opt/etc/minidlna.conf parameter media_dir?

minidlna works with Samsung TV very well.

Btw, can you please avoid quoting the entire tutorial in your post (editing even after the post is possible)?

lskarda
25-11-2011, 21:44
Are you sure that your media files are located in the directory that's indicated in the minidlna config file, /opt/etc/minidlna.conf parameter media_dir?

minidlna works with Samsung TV very well.

Btw, can you please avoid quoting the entire tutorial in your post (editing even after the post is possible)?

I tried use all combination of path.
After command DF I see this for disk with my movies
/dev/discs/disc0/part3 /tmp/mnt/disc0_3
I used first and second form too. I used /tmp/harddisk

For all free types of writing location command CD work.

I use default SAMBA. In one forum I red something about this error and SAMBA 3. Which SAMBA use you?

Thank you.

Ludek

ecaddict
26-11-2011, 09:59
I use Samba3 but probably that's not the issue here.

df -h command should show /mnt for the "Mounted on" part (this is the case if you installed optware based on my tutorial or using the tutorial from Raas; /tmp/harddisk is not used by me).
What it shows currently for you is something like it would be auto mounted and not via using /etc/fstab (cat /etc/fstab).

Anyhow, as the files are there, you should find them (e.g. cd / && find -name *.avi or whatever media files you store there) and set the correct directory in /opt/etc/minidlna.conf.

You can see what's currently configured with the following command:
cat /opt/etc/minidlna.conf | grep media_dir

tex
26-11-2011, 10:23
Hi Ecaddict, could you please help me in configuring Twonky to let play Mkv files? On my samsung television when i try to open this kind of file it says "unsupported format"!
Thank you for all your nice tutorials

ecaddict
26-11-2011, 18:07
Playing mkv minidlna is the best option (I know for sure that it works with Samsung TV). Also meditomb has some issues with it due to e.g. missing <map from="mkv" to="video/mpeg"/> from /opt/etc/mediatomb/config.xml.

I don't know what's wrong with Twonky.