Avoid divide-by-zero for files with duration < AV_TIME_BASE

This commit is contained in:
Julien BLACHE 2009-11-01 12:51:50 +01:00
parent c36b3c360d
commit 9b56d51f92

View File

@ -165,7 +165,7 @@ scan_metadata_ffmpeg(char *file, struct media_file_info *mfi)
if (ctx->bit_rate > 0)
mfi->bitrate = ctx->bit_rate / 1000;
else if (ctx->duration > 0) /* guesstimate */
else if (ctx->duration > AV_TIME_BASE) /* guesstimate */
mfi->bitrate = ((mfi->file_size * 8) / (ctx->duration / AV_TIME_BASE)) / 1000;
DPRINTF(E_DBG, L_SCAN, "Duration %d ms, bitrate %d kbps\n", mfi->song_length, mfi->bitrate);