Better guess of bitrate when tag includes a duration tag
This commit is contained in:
parent
ad16949d12
commit
c797d64eb1
|
@ -964,6 +964,14 @@ int scan_mp3_get_mp3fileinfo(char *file, MP3FILE *pmp3) {
|
|||
fi.bitrate = 0;
|
||||
}
|
||||
|
||||
|
||||
DPRINTF(E_DBG,L_SCAN,"Scan Type: %d, no of frames: %d, song_length: %d, "
|
||||
"file size: %d\n",
|
||||
conf_get_int("general","scan_type",0),
|
||||
fi.number_of_frames,
|
||||
pmp3->song_length,
|
||||
pmp3->file_size);
|
||||
|
||||
if((conf_get_int("general","scan_type",0) != 0) &&
|
||||
(fi.number_of_frames == 0) &&
|
||||
(!pmp3->song_length)) {
|
||||
|
@ -977,9 +985,9 @@ int scan_mp3_get_mp3fileinfo(char *file, MP3FILE *pmp3) {
|
|||
/* get full frame count */
|
||||
scan_mp3_get_frame_count(infile, &fi);
|
||||
}
|
||||
pmp3->bitrate=fi.bitrate;
|
||||
}
|
||||
|
||||
pmp3->bitrate=fi.bitrate;
|
||||
pmp3->samplerate=fi.samplerate;
|
||||
|
||||
/* guesstimate the file length */
|
||||
|
@ -994,13 +1002,14 @@ int scan_mp3_get_mp3fileinfo(char *file, MP3FILE *pmp3) {
|
|||
pmp3->song_length = (int) ((double)(fi.number_of_frames*fi.samples_per_frame*1000.)/
|
||||
(double) fi.samplerate);
|
||||
}
|
||||
|
||||
/* back-calculate bitrate from duration */
|
||||
if(pmp3->song_length) { /* could still be unknown */
|
||||
pmp3->bitrate = (file_size / pmp3->song_length) * 8;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* back-calculate bitrate from duration */
|
||||
if((pmp3->song_length) && (!pmp3->bitrate)) { /* could still be unknown */
|
||||
pmp3->bitrate = (file_size / pmp3->song_length) * 8;
|
||||
}
|
||||
|
||||
|
||||
DPRINTF(E_DBG,L_SCAN," Song Length: %d\n",pmp3->song_length);
|
||||
|
||||
fclose(infile);
|
||||
|
|
|
@ -148,6 +148,7 @@ int main(int argc, char *argv[]) {
|
|||
char *ext;
|
||||
char *configfile = "mt-daapd.conf";
|
||||
int debuglevel=1;
|
||||
FILE *fin;
|
||||
|
||||
memset((void*)&mp3,0x00,sizeof(MP3FILE));
|
||||
|
||||
|
@ -190,6 +191,16 @@ int main(int argc, char *argv[]) {
|
|||
err_setlevel(debuglevel);
|
||||
printf("Getting info for %s\n",argv[0]);
|
||||
|
||||
fin=fopen(argv[0],"r");
|
||||
if(!fin) {
|
||||
perror("fopen");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
fseek(fin,0,SEEK_END);
|
||||
mp3.file_size = ftell(fin);
|
||||
fclose(fin);
|
||||
|
||||
ext = strrchr(argv[0],'.')+1;
|
||||
plist=scanner_list;
|
||||
|
||||
|
|
Loading…
Reference in New Issue