12
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

iTunesで取得したm4aをwavに変換する方法

Last updated at Posted at 2014-03-10

普通にやろうとすると、soxでの変換になるが、soxはm4aのエンコーダを拡張子から解決できない。ffmpegで行うのが良い。

以下、同時変換用のpythonスクリプトの例を示す。日本語名を含むファイルが多数ある場合でも変換できるように書いた。

#!/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)

<path to output>の部分は自分で設定すること。

12
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?