Bug 775 - Improved handling for multiple copies of the same track in different formats
: Improved handling for multiple copies of the same track in different formats
Status: RESOLVED FIXED
Product: Logitech Media Server
Classification: Unclassified
Component: Formats
: unspecified
: All All
: P2 enhancement with 12 votes (vote)
: New Schema
Assigned To: Brandon Black
: new_schema
Depends on: 8303
Blocks:
  Show dependency treegraph
 
Reported: 2005-01-09 14:38 UTC by Ian Whalley
Modified: 2014-08-05 16:00 UTC (History)
13 users (show)

See Also:
Category: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ian Whalley 2005-01-09 14:38:47 UTC
Quoting from <46220160.20050109094534@whalley.org> on the discussion list (9
January 2005):

I have two SLIMP3s, and SlimServer 5.4.0.

I've recently started reripping my CDs in FLAC form, and placing the .flac files
next to the .mp3 files.  The new .flac files have their tags copied from the
corresponding (pre-existing) .mp3 files, so they're effectively identically tagged.

When I play an album, it turns out that the server picks some tracks in .flac
form, and some tracks in .mp3 form.  For my current setup, this is a waste of
CPU cycles -- if and when I upgrade to Squeezeboxen, _then_ I want it to send
the .flacs :). (Transcoding or not, per bug 230)

I would really (approximately) like the following algorithm in my situation:

   If both .flac and .mp3 versions of the track exist
     If sending to SLIMP3
       Send .mp3
     else /* squeezebox */
       Send .flac
     fi
   elsif only .flac version exists
     If sending to SLIMP3
       Transcode to .mp3 and send
     else /* squeezebox */
       Send .flac
     fi
   elsif only .mp3 exists
     Send .mp3
   fi

That is to say, in my current setup (SLIMP3s), I would like a .flac file to only
be used if there is no corresponding .mp3 file (this situation does occur in my
collection as well).

Of course, there are other formats, so there'd really need to be an ordered (by
preference) list of formats...
Comment 1 KDF 2005-01-10 12:35:38 UTC
I think this might be something that would be great as part of the bandwidth
limiting code.  Instead of just simply transcoding via LAME, if the server knew
that an MP3 existed of the same exact file, then it could send that and use a
lot less CPU resources.  This could work on other formats if any end up being
handled natively as well.  

We'd have to restrict this and only support for matching filename, and all tags.
(or some other specific definition of 'matching') It would probably be very bad
to be picking a wrong file just because of matching filename (sans extension).
This would confuse generic users who wouldn't necessarily have careful tagging
or filenaming. 
Comment 2 Dan Sully 2005-01-17 16:55:34 UTC
Ian - is there any reason you don't use the transcoding feature of the server to
convert your FLAC files to mp3 using lame?

Just remove the MP3 files at that point.
Comment 3 Ian Whalley 2005-01-18 05:11:11 UTC
>Ian - is there any reason you don't use
>the transcoding feature of the server to
>convert your FLAC files to mp3 using lame?

>Just remove the MP3 files at that point.

I need the MP3s for iPods etc -- for things that don't seamlessly transcode as
required.

Plus, I really want the server to use the file format that the SLIMP3 supports
natively, when the track is available in that format.  Fast forward and rewind
work, uses less juice on the (underpowered, in terms of CPU) server, etc.  I
think it's a good thing to offload the job of 'playing music' to the device
designed for 'playing music' :).

I suppose I could try to maintain parallel hierarchies, but I think the issue
here is really more general than that -- when the same track (need to work out
how closely the tags have to match for two files to be regarded as representing
the same track) is available in multiple formats, the server should have
predictable behaviour.  At the moment, it's not predictable.
Comment 4 KDF 2005-01-18 10:32:03 UTC
I think the problem is also that which format gets presented to the user seems
to be inconsistent, picking some mp3 and some flac to be available to the user.
 regardless of how we handled playback of multi-format, the server should
probably display them in a consistent way.  I'd say it should list them all, in
both formats.  chosing one for playback might be able to be re-filed as a
specific enhancement if that is not a trivial thing.
Comment 5 Ian Whalley 2005-01-18 11:16:30 UTC
>I'd say it should list them all, in both formats.

I think this might have negative effects when playing whole albums (to give one
example).  Whilst I may have two copies (one .mp3, one .flac) of each track in a
given 12-track album, I definitely don't want 24 tracks to be enqueued when I
tell the system to play the album.

This is why I agree with comment 1 -- the server (ideally) would have a concept
of which files represent the same track (in the same album, etc).  That is to
say, which files differ only in the encoding formats.

In the short term (and in my specific instance) having it examine .mp3 files
after .flac files would do the trick, so the data from the .flac was overridden
by that from the .mp3, but this hardly seems like the cleanest possible option.

Comment 6 Corey Huinker 2005-01-26 14:32:15 UTC
I've agreed to take this one over from Dean.  I also have a collection of CDs
that are ripped to both MP3 and FLAC, so my own collection is an idea testbed.

I've been programming perl for 10 years, but I have no experience with this
codebase.  This didn't seem to bother Dean, so I guess I'm good enough for the job.

Having received no feedback from my email about what policy to implement, I
think I'm going to just make a fix, and wait for somebody to hate it.

The policy of the fix will be "mp3 trumps everything, otherwise go by
alphabetical order".  So MP3 > AAC > FLAC > OGG > ZIPPY_NEW_FORMAT

This is really lazy on my part, and I'm hoping that this laziness with enrage
someone to the point of coming up with a real policy.

Comment 7 michael 2005-01-26 14:41:05 UTC
What about giving the lossless formats priority, followed by mp3, followed by
everything else?

I figure that if someone has lossless copies, that's probably what they want to
hear through the squeezebox and additional copies are probably there for use
with less advanced devices.  Putting mp3 second may avoid unnecessary
transcoding in some circumstances. After that I'd guess everything else falls
into the "pick any one" category.
Comment 8 KDF 2005-01-26 15:45:29 UTC
not having seen the email, thus not having the opportunity to reply...
I think you might want to consider following the bitrate limiting settings, at
least to a certain extent.  If a user has their player set to 'no limit', it
woudl be clear that they want high quality audio, thus lossless codecs shoud
come first.  WAV, FLAC, AppleLossless, WMA Lossless (don't care what order).  If
limited then mp3 first...the rest later (maybe based on cpu overhead to
transcode, perhaps).

Odds are this patch is only going to come into play for those who have a 'good
copy' and 'streamable copy' rather than users who just happen to like to back up
their FLAC files with WAV files :)
Comment 9 Ian Whalley 2005-01-26 18:08:26 UTC
Re: comment 7 -- the original report (mine) says quite clearly that the problem
in my case is not that sometimes it doesn't pick the lossless ones, but that
sometimes it _does_ pick the lossless ones.

This is, of course, because I have SLIMP3s, not Squeezeboxes.  The .FLACs are
for possible future Squeezeboxen.
Comment 10 michael 2005-01-26 18:50:48 UTC
kdf's suggestion above about bitrate limiting could solve the issue of having a
different behaviour for slimp3 (i.e. prefer the mp3 version to avoid
transcoding) as well.
Comment 11 Blackketter Dean 2005-02-01 12:10:24 UTC
There are a couple of things going on here.  Tell me if I've got it right:

1. Sometimes we want to ignore some file types globally (i.e. they get ignored in the scan).
This should be able to be accomplished by modifying the types.conf file.  

2. The database should recognize that there are two files that correspond to one song and then use 
some cleverness to decide which format to stream to a given player.  (i.e. Send MP3 to SLIMP3, FLAC to 
Squeezebox).  Choosing which format for which player may be configurable (or maybe we already have 
all the configuration we need via the transcoding framework.
Comment 12 KDF 2005-02-01 12:58:56 UTC
What worries me here, is what happens when the server fins two files of
identical filenames, only differing in teh extension.  If we send the MP3 to
Slimp3 and the FLAC to squeezbox and these file are NOT truly identical, the
user is in for an annoying surprise.  This is also an issue for synchronisation.
 The more I think about this, the more I shy away from any server-side
"automatic" solution, and the possible combinations for user options gets a
little crazy as well. I personally blame several recent headaches on conflicting
option requests.
Comment 13 michael 2005-02-01 13:11:19 UTC
not to imply that file names are the only/best way to match two songs, but for
the sake of argument if that's the mechinism that's chosen, then it's not too
unreasonable to expect the user who turns this feature on to have well named
files. Just as current users are expected to have the correct file extension on
a song, or have annoying surprises.
Comment 14 KDF 2005-02-01 13:18:18 UTC
I'm the first to say...do it the way the server likes, and stop whining. 
However, I've been blasted to no end for that, so I'm just sharing the
experience in the form of devils advocate :)

The main thing I hope to see from this is really that the files are consistently
handled.  Right now, you can load an album and get a mix of FLAC and MP3. 
Eventualy, I plan to get rid of dupes, so it really wont matter to me after that.
Comment 15 Ian Whalley 2005-02-01 13:26:48 UTC
Re: Comment 11

Issue (1): I don't actually want to ignore some filetypes globally :).
           As stated in the original report, I only want to ignore
           those filetypes (.FLAC, in my case) if there is a
           "matching" .MP3 (for some definition of "matching" still
           to be determined).  This is because:
             (a) I have SLIMP3s, not Squeezeboxes;
             (b) The music server is underpowered, in terms of CPU; and
             (c) The music collection breaks down as follows:
                  + For lots of tracks:
                      Collection contains .FLAC and .MP3;
                  + For some tracks:
                      Collection contains .MP3 only;
                  + For a few tracks:
                      Collection contains .FLAC only.

Issue (2): This is the "matching" question, and I freely admit I don't know
           how to do this.  I would be happy with 'contains exactly the
           same tags' being the definition of "matching", but even there
           there are problems (what if the .MP3 contains fields for which
           no corresponding .FLAC field exists?).

Re: Comment 14, consistent behaviour.

Yes -- I agree that the most important thing is to get the server to at
least behave consistently (per my original report, I get an confusing mix
of .MP3s and .FLACs when I play an album).  The second most important thing
is to have the server choose the most appropriate version of a track to
play.  Comment 12 had a great point about synchronisation in mixed
SLIMP3/Squeezebox environments, which adds yet another layer of complexity.


This is a much larger can of worms than I had initially suspected!
Comment 16 Blackketter Dean 2005-02-01 21:44:54 UTC
I think that the real bug here is:   SlimServer should notice when there are multiple encodings for a 
single file and only show one instance when browsing and creating playlists.  When playing back a song 
that has multiple encodings, the preferred formats as expressed by the various players and the 
transcoding framework should take advantage of all the formats available.

How's that sound?
Comment 17 Ian Whalley 2005-02-02 05:31:23 UTC
Re: Comment 16

I think that's a good description.
Comment 18 Ian Whalley 2005-03-09 07:29:06 UTC
The arrival of the new Squeezebox2 makes this issue even more interesting --
what's the correct behaviour in a mixed network of SLIMP3s, Squeezebozen, and
Squeezebox2en when some tracks are available in MP3 and FLAC (for example), some
only in FLAC, and some only in MP3?

There's self-interest in this question, of course -- not only do I have such a
collection (per earlier comments), but I'm also about to have a mixed network of
SLIMP3s and Squeezebox2en, and would really like the Squeezebox2en to get the
FLACs natively, but still have the SLIMP3s get the matching MP3s natively (I
imagine that synchronization is off the table for the purposes of this discussion).

Fun fun.
Comment 19 Corey Huinker 2005-03-09 08:04:09 UTC
I agree.  This issue quickly went over my head, and is only getting more
complicated.  I no longer feel qualified to field it.  It seems simple when
considering only one's own home configuration.  Coming up with a policy engine
that fits all possible configurations quickly becomes a large undertaking.

And I still don't feel qualified to decide on the policy.

Perhaps the original suggestion to wait until the 6.0 release was best.
Comment 20 KDF 2005-03-09 10:07:12 UTC
well Dean, I guess its back to you for now :)
Comment 21 Blackketter Dean 2005-03-11 15:45:41 UTC
dan to find the dup of this and deal.
Comment 22 KDF 2005-03-11 16:36:29 UTC
*** Bug 707 has been marked as a duplicate of this bug. ***
Comment 23 Ian Whalley 2005-03-12 09:01:53 UTC
Another related behaviour of the current system -- when I browses the music
collection directly (via 'Browse Music Folder') and add a directory to the
playlist from there, two copies of each track is put in the playlist (one MP3,
one FLAC -- see earlier comments on my collection).

Technically, this is what 'add' is supposed to do in this context (put
everything in the directory on the playlist), but it's not what the user (this
user, anyway) expects to happen.  What I think should ideally happen is that one
copy of each track (using whatever system is chosen to detect multiple copies of
the same track, and to select which of those multiple copies to use in a given
situation) is added to the playlist.
Comment 24 Dan Sully 2005-03-12 13:12:35 UTC
Pushing off to 6.1.

Patches welcome.
Comment 25 KDF 2005-03-17 21:52:29 UTC
*** Bug 1119 has been marked as a duplicate of this bug. ***
Comment 26 Ian Whalley 2005-07-09 08:33:16 UTC
Another aspect of this occurred to me today when trying to play "The Wall" -- an
album of which I have three copies in my collection:
  (1) MP3, one file per track.
  (2) FLAC, one file per track.
  (3) MP3, one file per disk, with cuesheet.
Several days ago I diddled types.conf so that (2) is not seen any more, but (as
one might expect) two copies of each track still show up in the album listing --
one from (1), and one from (3).

This is the same bug, but it's another aspect of it.
Comment 27 Ron Thigpen 2005-08-08 09:56:39 UTC
suggestion: quick, highly limited workaround that might take care of Ian's issue
in Comment #26

have SS recognize a marker of some sort that would skip some tracks on scan. 
perhaps a text file named something like 'ignore.txt'.  creating this file in
any subdirectory of the music directory would cause SS's scan to skip that
directory and any subs.  

presumably simple to implement and would take care of a small but annoying class
of library management issues.

possibly extensible to the greater issue if, for instance, scripts that
automatically generate mirror FLAC/MP3 encodings of the same material were to
mark one of these to be ignored.  not ideal, but perhaps useful in the interim.
Comment 28 cdl 2005-10-07 03:12:59 UTC
I agree with comment 16.  I would like to see the following:

If there are multiple duplicates of a track in a directory (duplicates either from exact tag matches, exact 
filename matches (except extension) - then show on browse and/or search just the files that match a 
given player's prefered type.

If there is both FLAC and MP3, stream the best fit to the given player
If just MP3 or FLAC, then stream (and/or transcode) to deliver the track to the player.
Comment 29 Brian Yen 2006-01-31 08:19:25 UTC
I would be nice to have filtered view of my music library.
One of the filter could be display highest quality format for any single tracks.
I'm sure many audiophiles would rip songs in a lossless format such as FLAC and one in mp3 for portable devices.
So, as is now, it's a major pain to have to scroll through two copies of everything in the lib.
Or the only other way, is the manually seperate them and never mix them in the lib.
Comment 30 Petri Ojala 2006-02-20 06:32:52 UTC
I just received my Squeezebox3, moving from SoundBridge, and have exactly the same problem.  All the songs in my music server are in Apple Lossless (for anything) and MP3 (for iPod).  With the SoundBridge I had two mt-daapd's running, one for m4a's, and one for mp3's.

Simple option to ignore certain file types would be sufficient enough, anything more complex would be even better.
Comment 31 Ian Whalley 2006-02-20 06:38:39 UTC
Re: Comment 30

The workaround is to comment out the filetypes that you don't want to support from types.conf and convert.conf.  In my case, I commented out all the FLAC-related things to get MP3s everywhere.  In your case, perhaps you'll want to comment out all the MP3-related things.

I have been running with these local changes since the time of the bug report.
Comment 32 Greg Dowling 2006-06-17 05:28:06 UTC
Music Magic has an interesting way of doing something similar with 'exclude' lists.

Basically you can tell it not to load certain wildcards - even if it seems them in the directory or from reading iTunes etc.

Micght be worth considering (it would allow me to link SlimServer with iTunes - which I can't today without adding all the AAC files to the DB - however I can have MM integrate with iTunes without trouble).

Note that just extensions (or using the .conf file) doesn't work for ALE vs AAC since both are .m4a (!).

I keep my 'unique' AAC/mp3 files in a different directory from my 'available in both formats' AAC/mp3 - so in my care this would do most of what people are asking for.

Comment 33 Dan Sully 2006-06-28 11:35:26 UTC
A partial "fix" for this bug has been added in change 8171 - an option to exclude file extensions during scan time.
Comment 34 Michael Herger 2007-12-12 01:23:11 UTC
While digging through the BMF code I found reference to a preference called "ignoreDirRE" which allows to skip given item names (Slim::Utils::Misc::readDirectory()). It's been there since revision 2, but isn't used anywhere else. There's no GUI for it.

Was this an early attempt to do what we're discussing here? 
Comment 35 cdl 2008-06-03 20:23:51 UTC
Nice, guys.  If you are going to just close it saying you will never fix it, it would be nice for you least to comment on why, given that a number of your customers indicated enough interest to document this.  I may be wrong, but I don't think the original crowd would have done this with nary a comment.  Please tell me this isn't the way that the new company is going to behave.

Chris

Comment 36 Michael Herger 2014-08-05 16:00:24 UTC
7.9 comes with an option to prefer lossless over lossy copies of the same track. It's part of the "Extended Browse Modes" plugin.