mirror of
https://github.com/owntone/owntone-server.git
synced 2025-04-01 10:13:45 -04:00
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;
|
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) &&
|
if((conf_get_int("general","scan_type",0) != 0) &&
|
||||||
(fi.number_of_frames == 0) &&
|
(fi.number_of_frames == 0) &&
|
||||||
(!pmp3->song_length)) {
|
(!pmp3->song_length)) {
|
||||||
@ -977,9 +985,9 @@ int scan_mp3_get_mp3fileinfo(char *file, MP3FILE *pmp3) {
|
|||||||
/* get full frame count */
|
/* get full frame count */
|
||||||
scan_mp3_get_frame_count(infile, &fi);
|
scan_mp3_get_frame_count(infile, &fi);
|
||||||
}
|
}
|
||||||
|
pmp3->bitrate=fi.bitrate;
|
||||||
}
|
}
|
||||||
|
|
||||||
pmp3->bitrate=fi.bitrate;
|
|
||||||
pmp3->samplerate=fi.samplerate;
|
pmp3->samplerate=fi.samplerate;
|
||||||
|
|
||||||
/* guesstimate the file length */
|
/* 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.)/
|
pmp3->song_length = (int) ((double)(fi.number_of_frames*fi.samples_per_frame*1000.)/
|
||||||
(double) fi.samplerate);
|
(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);
|
DPRINTF(E_DBG,L_SCAN," Song Length: %d\n",pmp3->song_length);
|
||||||
|
|
||||||
fclose(infile);
|
fclose(infile);
|
||||||
|
@ -148,6 +148,7 @@ int main(int argc, char *argv[]) {
|
|||||||
char *ext;
|
char *ext;
|
||||||
char *configfile = "mt-daapd.conf";
|
char *configfile = "mt-daapd.conf";
|
||||||
int debuglevel=1;
|
int debuglevel=1;
|
||||||
|
FILE *fin;
|
||||||
|
|
||||||
memset((void*)&mp3,0x00,sizeof(MP3FILE));
|
memset((void*)&mp3,0x00,sizeof(MP3FILE));
|
||||||
|
|
||||||
@ -190,6 +191,16 @@ int main(int argc, char *argv[]) {
|
|||||||
err_setlevel(debuglevel);
|
err_setlevel(debuglevel);
|
||||||
printf("Getting info for %s\n",argv[0]);
|
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;
|
ext = strrchr(argv[0],'.')+1;
|
||||||
plist=scanner_list;
|
plist=scanner_list;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user