python m4a to wav

Solutions on MaxInterview for python m4a to wav by the best coders in the world

showing results for - "python m4a to wav"
Liah
27 Sep 2018
1#!/usr/bin/env python
2
3import os
4import commands
5
6import logging
7import traceback
8
9if __name__ == '__main__':
10    outputdir = os.path.abspath(“<path to output>”)
11    for root, dirs, files in os.walk('.'):
12        for f in files:
13            path = os.path.join(root, f)
14            base, ext = os.path.splitext(f)
15            outputpath = os.path.join(outputdir, base + ".wav")
16            if ext == '.m4a':
17                print 'converting %s to %s' % (path, outputpath)
18                status, output = commands.getstatusoutput('ffmpeg -i "%s" "%s"' % (path, outputpath))
19                if status:
20                    logging.error (output)
21