* Log which file has extra-long vorbis comments.

* Gather duration and bitrate information from FLAC files.
This commit is contained in:
Justin Maggard 2009-04-04 01:13:14 +00:00
parent e50a0f04ef
commit 3f1afeeb40
4 changed files with 16 additions and 6 deletions

View File

@ -611,7 +611,7 @@ GetVideoMetadata(const char * path, char * name)
(ctx->streams[audio_stream]->codec->codec_id < CODEC_ID_ADPCM_IMA_QT) ) (ctx->streams[audio_stream]->codec->codec_id < CODEC_ID_ADPCM_IMA_QT) )
audio_profile = PCM; audio_profile = PCM;
else else
DPRINTF(E_DEBUG, L_METADATA, "Unhandled audio codec [%X]\n", ctx->streams[audio_stream]->codec->codec_id); DPRINTF(E_DEBUG, L_METADATA, "Unhandled audio codec [0x%X]\n", ctx->streams[audio_stream]->codec->codec_id);
break; break;
} }
asprintf(&m.frequency, "%u", ctx->streams[audio_stream]->codec->sample_rate); asprintf(&m.frequency, "%u", ctx->streams[audio_stream]->codec->sample_rate);

View File

@ -27,6 +27,7 @@ _get_flctags(char *filename, struct song_metadata *psong)
FLAC__Metadata_SimpleIterator *iterator = 0; FLAC__Metadata_SimpleIterator *iterator = 0;
FLAC__StreamMetadata *block; FLAC__StreamMetadata *block;
int block_number; int block_number;
unsigned int sec, ms;
int i; int i;
int err = 0; int err = 0;
@ -54,6 +55,15 @@ _get_flctags(char *filename, struct song_metadata *psong)
switch(block->type) switch(block->type)
{ {
case FLAC__METADATA_TYPE_STREAMINFO: case FLAC__METADATA_TYPE_STREAMINFO:
sec = (unsigned int)(block->data.stream_info.total_samples /
block->data.stream_info.sample_rate);
ms = (unsigned int)(((block->data.stream_info.total_samples %
block->data.stream_info.sample_rate) * 1000) /
block->data.stream_info.sample_rate);
if ((sec == 0) && (ms == 0))
break; /* Info is crap, escape div-by-zero. */
psong->song_length = (sec * 1000) + ms;
psong->bitrate = (((uint64_t)(psong->file_size) * 1000) / (psong->song_length / 8));
psong->samplerate = block->data.stream_info.sample_rate; psong->samplerate = block->data.stream_info.sample_rate;
psong->channels = block->data.stream_info.channels; psong->channels = block->data.stream_info.channels;
break; break;

View File

@ -174,11 +174,11 @@ _get_utf8_text(const id3_ucs4_t* native_text)
static void static void
vc_scan(struct song_metadata *psong, const char *comment, const size_t length) vc_scan(struct song_metadata *psong, const char *comment, const size_t length)
{ {
char strbuf[1024]; char strbuf[2048];
if(length > (sizeof(strbuf) - 1)) if(length > (sizeof(strbuf) - 1))
{ {
DPRINTF(E_ERROR, L_SCANNER, "Vorbis Comment too long\n"); DPRINTF(E_WARN, L_SCANNER, "Vorbis Comment too long [%s]\n", psong->path);
return; return;
} }
strncpy(strbuf, comment, length); strncpy(strbuf, comment, length);

View File

@ -263,9 +263,6 @@ readtags(char *path, struct song_metadata *psong, struct stat *stat, char *lang,
fname = strrchr(psong->path, '/'); fname = strrchr(psong->path, '/');
psong->basename = fname ? fname + 1 : psong->path; psong->basename = fname ? fname + 1 : psong->path;
// get tag
found |= _get_tags(path, psong);
if(stat) if(stat)
{ {
if(!psong->time_modified) if(!psong->time_modified)
@ -273,6 +270,9 @@ readtags(char *path, struct song_metadata *psong, struct stat *stat, char *lang,
psong->file_size = stat->st_size; psong->file_size = stat->st_size;
} }
// get tag
found |= _get_tags(path, psong);
// get fileinfo // get fileinfo
found |= _get_fileinfo(path, psong); found |= _get_fileinfo(path, psong);