[PYTHON] How to convert m4a acquired by iTunes to wav

If you try to do it normally, it will be converted by sox, but sox cannot solve the m4a encoder from the extension. It is better to do it with ffmpeg.

The following is an example of a python script for simultaneous conversion. I wrote it so that it can be converted even if there are many files containing Japanese names.

#!/usr/bin/env python

import os
import commands

import logging
import traceback

if __name__ == '__main__':
	outputdir = os.path.abspath(“<path to output>”)
	for root, dirs, files in os.walk('.'):
		for f in files:
			path = os.path.join(root, f)
			base, ext = os.path.splitext(f)
			outputpath = os.path.join(outputdir, base + ".wav")
			if ext == '.m4a':
				print 'converting %s to %s' % (path, outputpath)
				status, output = commands.getstatusoutput('ffmpeg -i "%s" "%s"' % (path, outputpath))
				if status:
					logging.error (output)

Set the \ part yourself.

Recommended Posts

How to convert m4a acquired by iTunes to wav
How to convert a mel spectrogram back to a wav file
Convert PDF to Documents by OCR
How to convert 0.5 to 1056964608 in one shot
How to convert Tensorflow model to Lite
How to convert from .mgz to .nii.gz
[Python] How to convert db file to csv
How to easily convert format from Markdown
[Python] How to convert a 2D list to a 1D list
How to convert csv to tsv in CLI
How to convert Python to an exe file
How to convert DateTimeField format in Django
[python] How to display list elements side by side
[Tensorflowjs_converter] How to convert Tensorflow model to Tensorflow.js format
[Django] How to get data by specifying SQL.
How to convert SVG to PDF and PNG [Python]
How to erase the characters output by Python
[Python] How to sort instances by instance variables
How to convert (32,32,3) to 4D tensor (1,32,32,1) with ndarray type
Inspired by "How to make pure functional JavaScript"
Convert to HSV
How to convert / restore a string with [] in python
[Continued] Inspired by "How to make pure functional JavaScript"
How to convert Python # type for Python super beginners: str
How to convert horizontally held data to vertically held data with pandas
How to convert a class object to a dictionary with SQLAlchemy
[Python] Convert PDF text to CSV page by page (2/24 postscript)
How to convert floating point numbers to binary numbers in Python
How to convert JSON file to CSV file with Python Pandas
How to check the Java version used by Maven
How to list numbers by dividing them into n
How to save a table scraped by python to csv
python, php, ruby How to convert decimal numbers to n-ary numbers
How to convert Json file to CSV format or EXCEL format
Compare how to write processing for lists by language
How to unprefix the DB name used by pytest-django