Ejemplo n.º 1
0
def extractAudioSegment(inputFileName, begin, end):
    try:
        outputFileName='%s-%010u.mp3' % (os.path.splitext(inputFileName)[0], begin)
        duration=end - begin
        mob.doCommand(
            'ffmpeg -i %(inputFileName)s -ab 128 -ss %(begin)s -t %(duration)s %(outputFileName)s' % vars())
        return outputFileName
    except:
        raise mob.inContext(
            'extract segment of audio [%(begin)s:%(end)s] from file %(inputFileName)s' % vars(),
            sys.exc_info())
    pass
Ejemplo n.º 2
0
def extractAudio(inputFileName):
    try:
        outputFileName=os.path.splitext(inputFileName)[0]+'.mp3'
        mob.doCommand(
            'rm -f %(outputFileName)s' % vars())
        mob.doCommand(
            'ffmpeg -i %(inputFileName)s -ab 128 -ar 48000 -ac 2 %(outputFileName)s' % vars())
        return outputFileName
    except:
        raise mob.inContext(
            'extract audio from file %(inputFileName)s' %vars(),
            sys.exc_info())
    pass
Ejemplo n.º 3
0
def getDuration(inputFileName):
    try:
        x=mob.doCommand('midentify %(inputFileName)s' % vars())
        y=[ z for z in x.splitlines() if z.startswith('ID_LENGTH=') ]
        assert len(y) == 1, str(y)
        duration=int(float(y[0][10:]))
        return duration
    except:
        raise mob.inContext(
            'get duration of audio file %(inputFileName)s' % vars(),
            sys.exc_info())
    pass