Reputation: 21
I wrote a bit of code to boost song volume, the volume boosting bit is as follows:
song = AudioSegment.from_mp3(preboostSong)
louder_song = song + decibels
louder_song.export(p.strip(".mp3")+"_louder.mp3", format='mp3',tags=mediainfo(p).get('TAG', {}))
The songs get boosted as expected, however, for some reason the track lengths get doubled. They play normally, but the track lengths show up in iTunes as double what they actually are. Why is this and how do I fix it?
Upvotes: 1
Views: 508
Reputation: 21
Ok after a bit of digging around I think I have it. The issue lies in the bitrate being changed upon exporting. In the above code p is the path to the file (apologies for the lazy naming) so you have to do the following:
from pydub.utils import mediainfo
song = AudioSegment.from_mp3(preboostSong)
bitrate = mediainfo(preboostSong)["bit_rate"]
louder_song = song + decibels
louder_song.export(preBoostSong.strip(".mp3")+"_louder.mp3", format='mp3',tags=mediainfo(preboostSong).get('TAG', {}),bitrate=bitrate)
Upvotes: 1