diff --git a/src/scan-mp3.c b/src/scan-mp3.c index 3eee893f..1de189b6 100644 --- a/src/scan-mp3.c +++ b/src/scan-mp3.c @@ -971,14 +971,16 @@ int scan_mp3_get_mp3fileinfo(char *file, MP3FILE *pmp3) { pmp3->song_length = (int) ((double) file_size * 8. / (double) fi.bitrate); - } else { + } else if (fi.samplerate ) { pmp3->song_length = (int) ((double)(fi.number_of_frames*fi.samples_per_frame*1000.)/ (double) fi.samplerate); } /* back-calculate bitrate from duration */ - pmp3->bitrate = ((file_size / 1000) * 8) / - (pmp3->song_length / 1000); + if(pmp3->song_length) { /* could still be unknown */ + pmp3->bitrate = ((file_size / 1000) * 8) / + (pmp3->song_length / 1000); + } } DPRINTF(E_DBG,L_SCAN," Song Length: %d\n",pmp3->song_length);