Example #1
0
	def _calc_gain(self):
		song = Song(url = self.url, _useDb = False)
		try:
			song.openFile()
		except IOError as exc:
			return {"error": exc}
		import ffmpeg
		try:
			duration, gain = ffmpeg.calcReplayGain(song)
		except Exception as exc:
			return {"error": exc}			
		return {"duration": duration, "gain": gain}
Example #2
0
 def _calc_gain(self):
     song = Song(url=self.url, _useDb=False)
     try:
         song.openFile()
     except IOError as exc:
         return {"error": exc}
     import ffmpeg
     try:
         duration, gain = ffmpeg.calcReplayGain(song)
     except Exception as exc:
         return {"error": exc}
     return {"duration": duration, "gain": gain}
Example #3
0
import sys, os

if len(sys.argv) == 2:
    filename = sys.argv[1]
else:
    files = [
        "~/Music/Classic/Glenn Gould Plays Bach/Two- & Three-Part Inventions - Gould/19 Bach - Invention 13 in a (BWV 784).mp3",
        "~/Music/Rock/Tool/Lateralus/09 Lateralus.flac",
        "~/Music/Cults - Cults 7/Cults - Cults 7- - 03 The Curse.flac",
        "~/Music/Special/zorba/(01) - Theme From Zorba The Greek.ogg",
        "~/Music/Classic/Glenn Gould Plays Bach/French Suites, BWV812-7 - Gould/Bach, French Suite 5 in G, BWV816 - 5 Bourree.mp3",
        "~/Music/Electronic/Von Paul Kalkbrenner - Aaron.mp3",
        "~/Music/Electronic/One Day_Reckoning Song (Wankelmut Remix) - Asaf Avidan & the Mojos.mp3",
        "~/Music/Electronic/Swing & Electro Swing/Parov Stelar/2008 - Daylight (Japan Only)/03 - Charlestone Butterfly.flac",  # this one has replaygain metadata
    ]
    files = map(os.path.expanduser, files)
    filename = files[7]

print(os.path.basename(filename))
assert os.path.isfile(filename)

import ffmpeg
metadata = ffmpeg.getMetadata(Song(filename))
from pprint import pprint
pprint(metadata)

duration, replaygain = ffmpeg.calcReplayGain(Song(filename))
print("duration: %f" % duration)
print("replaygain: %f" % replaygain)
print("gain factor: %f" % (10.**(replaygain / 20)))
Example #4
0
if len(sys.argv) == 2:
    filename = sys.argv[1]
else:
    files = [
        "~/Music/Classic/Glenn Gould Plays Bach/Two- & Three-Part Inventions - Gould/19 Bach - Invention 13 in a (BWV 784).mp3",
        "~/Music/Rock/Tool/Lateralus/09 Lateralus.flac",
        "~/Music/Cults - Cults 7/Cults - Cults 7- - 03 The Curse.flac",
        "~/Music/Special/zorba/(01) - Theme From Zorba The Greek.ogg",
        "~/Music/Classic/Glenn Gould Plays Bach/French Suites, BWV812-7 - Gould/Bach, French Suite 5 in G, BWV816 - 5 Bourree.mp3",
        "~/Music/Electronic/Von Paul Kalkbrenner - Aaron.mp3",
        "~/Music/Electronic/One Day_Reckoning Song (Wankelmut Remix) - Asaf Avidan & the Mojos.mp3",
        "~/Music/Electronic/Swing & Electro Swing/Parov Stelar/2008 - Daylight (Japan Only)/03 - Charlestone Butterfly.flac",  # this one has replaygain metadata
    ]
    files = map(os.path.expanduser, files)
    filename = files[7]

print(os.path.basename(filename))
assert os.path.isfile(filename)

import ffmpeg

metadata = ffmpeg.getMetadata(Song(filename))
from pprint import pprint

pprint(metadata)

duration, replaygain = ffmpeg.calcReplayGain(Song(filename))
print("duration: %f" % duration)
print("replaygain: %f" % replaygain)
print("gain factor: %f" % (10.0 ** (replaygain / 20)))
Example #5
0
	def _calc_gain(self):
		song = Song(url = self.url, _useDb = False)
		song.openFile() # this is another process, so safe
		import ffmpeg
		duration, gain = ffmpeg.calcReplayGain(song)
		return {"duration": duration, "gain": gain}