Caleb Epstein
2003-12-01, 12:47
While clearly not as neat as the forthcoming rewrite which
will read the FLAC tags natively instead of using metaflac,
here is a small patch to the Flac.pm module which fixes some
non-optimal behavior (e.g. getting file size twice for each
line in the metaflac output). It should help with speed when
indexing a large number of FLACs.
Also included is a patch for convert.conf which should make
shorten -> mp3 resampling and shorten -> wav playing work.
I'm not sure if its valid to have two different dest_formats
for the same source_format though.
Next up: "native" shorten support :)
diff -ur -x '*~' -x '*.log' SlimServer_v5.0.1.orig/Slim/Formats/Flac.pm SlimServer_v5.0.1/Slim/Formats/Flac.pm
--- SlimServer_v5.0.1.orig/Slim/Formats/Flac.pm 2003-11-28 19:40:21.000000000 -0500
+++ SlimServer_v5.0.1/Slim/Formats/Flac.pm 2003-12-01 14:38:52.000000000 -0500
@@ -64,46 +64,36 @@
foreach (@output)
{
if (/ARTIST=([^\n]*)\n/i)
- {$tag->{'ARTIST'} = $1; }
-
- if (/ALBUM=([^\n]*)\n/i)
- {$tag->{'ALBUM'} = $1;}
-
- if (/TITLE=([^\n]*)\n/i)
- {$tag->{'TITLE'} = $1;}
-
- if (/TRACKNUMBER=([^\n]*)\n/i)
- {$tag->{'TRACKNUM'} = $1;}
-
- if (/DATE=([^\n]*)\n/i)
- {$tag->{'YEAR'} = $1;}
-
- if (/GENRE=([^\n]*)\n/i)
- {$tag->{'GENRE'} = $1;}
-
- $tag->{'SIZE'} = -s $file;
- $tag->{'FS'} = -s $file;;
- $tag->{'CT'} = "flac";
-
+ {$tag->{'ARTIST'} = $1; }
+ elsif (/ALBUM=([^\n]*)\n/i)
+ {$tag->{'ALBUM'} = $1;}
+ elsif (/TITLE=([^\n]*)\n/i)
+ {$tag->{'TITLE'} = $1;}
+ elsif (/TRACKNUMBER=([^\n]*)\n/i)
+ {$tag->{'TRACKNUM'} = $1;}
+ elsif (/DATE=([^\n]*)\n/i)
+ {$tag->{'YEAR'} = $1;}
+ elsif (/GENRE=([^\n]*)\n/i)
+ {$tag->{'GENRE'} = $1;}
# Compute number of seconds from sample rate and num samples
- if (/sample_rate: (\d*) Hz/i)
- {
- $sampleRate = $1;
- $tag->{'RATE'} = $sampleRate;
+ elsif (/sample_rate: (\d*) Hz/i) {
+ $sampleRate = $1;
+ $tag->{'RATE'} = $sampleRate;
}
-
- if (/total samples: (\d*)/i)
- { $nSamples = $1; }
-
- if (defined($nSamples) && defined($sampleRate))
- { $tag->{'SECS'} = $nSamples / $sampleRate; }
- # Set this so to non-zero so it will play.
- else
- { $tag->{'SECS'} = 1; }
-
- if (/channels: (\*d)/i)
- { $tag->{'CHANNELS'} = $1; }
- }
+ elsif (/total samples: (\d*)/i)
+ { $nSamples = $1; }
+ elsif (/channels: (\*d)/i)
+ { $tag->{'CHANNELS'} = $1; }
+ }
+
+ $tag->{'SIZE'} = $tag->{'FS'} = -s $file;
+ $tag->{'CT'} = "flac";
+
+ if (defined $nSamples and defined $sampleRate and $sampleRate > 0)
+ { $tag->{'SECS'} = $nSamples / $sampleRate; }
+ # Set this so to non-zero so it will play.
+ else
+ { $tag->{'SECS'} = 1; }
}
return $tag;
}
diff -ur -x '*~' -x '*.log' SlimServer_v5.0.1.orig/convert.conf SlimServer_v5.0.1/convert.conf
--- SlimServer_v5.0.1.orig/convert.conf 2003-11-28 19:40:23.000000000 -0500
+++ SlimServer_v5.0.1/convert.conf 2003-12-01 14:41:32.000000000 -0500
@@ -44,7 +44,10 @@
$lame$ --silent -b $BITRATE$ $FILE$ -
shn mp3 * *
- shorten -d $FILE$ | $lame$ --silent -b $BITRATE$ - -
+ shorten -x $FILE$ - | $lame$ --silent -b $BITRATE$ - -
+
+shn wav * *
+ shorten -x $file -
flc mp3 * *
flac -dc $FILE$ | $lame$ --silent -b $BITRATE$ - -
--
Caleb Epstein | bklyn . org | All the really good ideas I ever had came to
cae at | Brooklyn Dust | me while I was milking a cow.
bklyn dot org | Bunny Mfg. | -- Grant Wood
will read the FLAC tags natively instead of using metaflac,
here is a small patch to the Flac.pm module which fixes some
non-optimal behavior (e.g. getting file size twice for each
line in the metaflac output). It should help with speed when
indexing a large number of FLACs.
Also included is a patch for convert.conf which should make
shorten -> mp3 resampling and shorten -> wav playing work.
I'm not sure if its valid to have two different dest_formats
for the same source_format though.
Next up: "native" shorten support :)
diff -ur -x '*~' -x '*.log' SlimServer_v5.0.1.orig/Slim/Formats/Flac.pm SlimServer_v5.0.1/Slim/Formats/Flac.pm
--- SlimServer_v5.0.1.orig/Slim/Formats/Flac.pm 2003-11-28 19:40:21.000000000 -0500
+++ SlimServer_v5.0.1/Slim/Formats/Flac.pm 2003-12-01 14:38:52.000000000 -0500
@@ -64,46 +64,36 @@
foreach (@output)
{
if (/ARTIST=([^\n]*)\n/i)
- {$tag->{'ARTIST'} = $1; }
-
- if (/ALBUM=([^\n]*)\n/i)
- {$tag->{'ALBUM'} = $1;}
-
- if (/TITLE=([^\n]*)\n/i)
- {$tag->{'TITLE'} = $1;}
-
- if (/TRACKNUMBER=([^\n]*)\n/i)
- {$tag->{'TRACKNUM'} = $1;}
-
- if (/DATE=([^\n]*)\n/i)
- {$tag->{'YEAR'} = $1;}
-
- if (/GENRE=([^\n]*)\n/i)
- {$tag->{'GENRE'} = $1;}
-
- $tag->{'SIZE'} = -s $file;
- $tag->{'FS'} = -s $file;;
- $tag->{'CT'} = "flac";
-
+ {$tag->{'ARTIST'} = $1; }
+ elsif (/ALBUM=([^\n]*)\n/i)
+ {$tag->{'ALBUM'} = $1;}
+ elsif (/TITLE=([^\n]*)\n/i)
+ {$tag->{'TITLE'} = $1;}
+ elsif (/TRACKNUMBER=([^\n]*)\n/i)
+ {$tag->{'TRACKNUM'} = $1;}
+ elsif (/DATE=([^\n]*)\n/i)
+ {$tag->{'YEAR'} = $1;}
+ elsif (/GENRE=([^\n]*)\n/i)
+ {$tag->{'GENRE'} = $1;}
# Compute number of seconds from sample rate and num samples
- if (/sample_rate: (\d*) Hz/i)
- {
- $sampleRate = $1;
- $tag->{'RATE'} = $sampleRate;
+ elsif (/sample_rate: (\d*) Hz/i) {
+ $sampleRate = $1;
+ $tag->{'RATE'} = $sampleRate;
}
-
- if (/total samples: (\d*)/i)
- { $nSamples = $1; }
-
- if (defined($nSamples) && defined($sampleRate))
- { $tag->{'SECS'} = $nSamples / $sampleRate; }
- # Set this so to non-zero so it will play.
- else
- { $tag->{'SECS'} = 1; }
-
- if (/channels: (\*d)/i)
- { $tag->{'CHANNELS'} = $1; }
- }
+ elsif (/total samples: (\d*)/i)
+ { $nSamples = $1; }
+ elsif (/channels: (\*d)/i)
+ { $tag->{'CHANNELS'} = $1; }
+ }
+
+ $tag->{'SIZE'} = $tag->{'FS'} = -s $file;
+ $tag->{'CT'} = "flac";
+
+ if (defined $nSamples and defined $sampleRate and $sampleRate > 0)
+ { $tag->{'SECS'} = $nSamples / $sampleRate; }
+ # Set this so to non-zero so it will play.
+ else
+ { $tag->{'SECS'} = 1; }
}
return $tag;
}
diff -ur -x '*~' -x '*.log' SlimServer_v5.0.1.orig/convert.conf SlimServer_v5.0.1/convert.conf
--- SlimServer_v5.0.1.orig/convert.conf 2003-11-28 19:40:23.000000000 -0500
+++ SlimServer_v5.0.1/convert.conf 2003-12-01 14:41:32.000000000 -0500
@@ -44,7 +44,10 @@
$lame$ --silent -b $BITRATE$ $FILE$ -
shn mp3 * *
- shorten -d $FILE$ | $lame$ --silent -b $BITRATE$ - -
+ shorten -x $FILE$ - | $lame$ --silent -b $BITRATE$ - -
+
+shn wav * *
+ shorten -x $file -
flc mp3 * *
flac -dc $FILE$ | $lame$ --silent -b $BITRATE$ - -
--
Caleb Epstein | bklyn . org | All the really good ideas I ever had came to
cae at | Brooklyn Dust | me while I was milking a cow.
bklyn dot org | Bunny Mfg. | -- Grant Wood