Page 21 of 22

Re: MiniDLNA 1.0.24 - 1.7 (18-Feb-2012)

PostPosted: Sun Apr 28, 2013 1:46 pm
by sonic_blue
Found the problem: when minidlna creates its file database, it actually requires a lot longer than it seems in order to finalise the database file. For a music collection of around 10,000 songs it needs about 3 hours to actually finish making the database even though all the files are available to stream much earlier than that.

If you run

Code: Select all
minidlna -d -f /conf/minidlna.conf


yo will see the debug output for minidlna. Only when it says the database is finalised and complete can you turn the wdtv off, otherwise you will be left with an incomplete/corrupt database which will then start rebuilding again on the next boot.

I also changed the media directory to each individual sub folder that I wanted to share, rather than just the top level folder. Not sure if that helps as well or not.

Also disabled inotify, but that may not be required.

Re: MiniDLNA 1.0.24 - 1.7 (18-Feb-2012)

PostPosted: Tue Apr 30, 2013 6:21 am
by recliq
Note: If you disable inotify support, MiniDLNA will not be aware of new files added after the last database indexing, I guess...
inotify is used to tell a process when a file or directory changes, meaning if you enable inotify support in minidlna it should
notice if you add new files and update it's database.

Re: MiniDLNA 1.0.24 - 1.7 (18-Feb-2012)

PostPosted: Tue Apr 30, 2013 11:56 am
by sonic_blue
recliq wrote:Note: If you disable inotify support, MiniDLNA will not be aware of new files added after the last database indexing, I guess...
inotify is used to tell a process when a file or directory changes, meaning if you enable inotify support in minidlna it should
notice if you add new files and update it's database.


Yeah, problem with inotify is that it needs wdtv to be running while new media files are being added to the drive. Wish there was a way for it to check for new media files on every boot, and only append those changes to the database without having to do a complete rebuild.

Re: MiniDLNA 1.0.24 - 1.7 (18-Feb-2012)

PostPosted: Tue Apr 30, 2013 1:53 pm
by sonic_blue
I think what's taking so long to generate the database in my case is the playlist files I have at the root of each audio folder. Minidlna is scanning through each playlist file to check that the paths within them are correct, and this takes HOURS.

If I could tell minidlna to ignore playlist files then this would shorten the database build time from hours to just a few minutes. Is there any way to tell minidlna which file types to share or ignore? Maybe something I can add to minidlna.conf to specify file types?

eg. filetypes="mp3|flac|m4a|wav" etc.

Re: MiniDLNA 1.0.24 - 1.7 (18-Feb-2012)

PostPosted: Tue Apr 30, 2013 2:25 pm
by sonic_blue
Ok, so minidlna lets you specify audio files only like this:

Code: Select all
media_dir=A,/home/user/Music


If I could redefine what "A" means, then I could tell it to exclude playlist files. Now I just need to know where the piece of code is that defines "A"...does anyone know?

Re: MiniDLNA 1.0.24 - 1.7 (18-Feb-2012)

PostPosted: Wed May 01, 2013 1:26 pm
by recliq
By quickly scanning through the code I'd say it's defined in file scanner.c, function filter_audio()
Code: Select all
filter_audio(const struct dirent *d)
{
   return ( (*d->d_name != '.') &&
            ((d->d_type == DT_DIR) ||
             (d->d_type == DT_LNK) ||
             (d->d_type == DT_UNKNOWN) ||
        ((d->d_type == DT_REG) &&
         (is_audio(d->d_name) ||
               is_playlist(d->d_name)
        )
          ) ));
}

You can try to change the function to this to exclude playlists:
Code: Select all
filter_audio(const struct dirent *d)
{
   return ( (*d->d_name != '.') &&
            ((d->d_type == DT_DIR) ||
             (d->d_type == DT_LNK) ||
             (d->d_type == DT_UNKNOWN) ||
        ((d->d_type == DT_REG) &&
         (is_audio(d->d_name)
        )
          ) ));
}

Note, I haven't tested this, just deduced from code... :geek:

Re: MiniDLNA 1.0.24 - 1.7 (18-Feb-2012)

PostPosted: Wed May 01, 2013 4:48 pm
by sonic_blue
Thanks, that looks like it should work. I'm new to linux and C...am I correct in thinking that I need to make the change to scanner.c, then recompile it to minidlna.app.bin using the makefile, and then place the file onto my USB drive?

edit:

Also if you could share any other tips on how to compile correctly for wdtv so that I don't screw anything up that would be much appreciated :)

Re: MiniDLNA 1.0.24 - 1.7 (18-Feb-2012)

PostPosted: Wed May 01, 2013 11:29 pm
by recliq
Basically that's it, yes.
I haven't compiled minidlna for WDTV so far, I have to ask RMerlin who built this app.bin, how he built it. Seems there are some pitfalls to watch out for (eg. you need to statically link some libraries to get them to work on WDTV...)

Re: MiniDLNA 1.0.24 - 1.7 (18-Feb-2012)

PostPosted: Thu May 02, 2013 11:09 pm
by sonic_blue
Thanks, I have sent RMerlin a PM. If it works and reduces the db build time to something reasonable such as a few minutes, then I can just launch rebuilds via the DoSomething plugin to overcome this issue of minidlna not detecting changes to the library while wdtv not running. Otherwise it's a massive pain: turn PC on, log into wdtv, launch rebuild in debug mode, wait 3 hours until it finally says it finished the database. Not much fun :shock:

I am using it to stream to xbox while playing games, which seems to work fairly well, but as soon as I want to add some more tracks to the library it's going to be a long wait...

The reason I have such large playlist files in the first place is because wdtv has no way to select all music of a particular genre or artist. eg. if you sort by genre it then gives you a list of artists, without having any way to just play all files of that genre. So, I had to make a playlist for each genre, artist etc. Stupid, stupid programmers of wdtv :?

Re: MiniDLNA 1.0.24 - 1.7 (18-Feb-2012)

PostPosted: Thu May 02, 2013 11:27 pm
by sonic_blue
I guess a better way to solve the inconvenience of having to do manual rebuilds is to write a simple script that calculates the size of media_dir every x seconds, and if it's changed, then launch a rebuild.