| 両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン |
| python:mutagen [2020/03/23 14:22] – [参考文献] ともやん | python:mutagen [2021/10/05 01:13] (現在) – ともやん |
|---|
| | <html> |
| | <style> |
| | #mincode pre { |
| | /*height: 300px;*/ |
| | overflow: scroll; |
| | overflow-x: hidden; |
| | font-size: 10px; |
| | } |
| | #mintbl table { |
| | font-size: 12px; |
| | } |
| | .dokuwiki .plugin_wrap table { |
| | width: auto; |
| | } |
| | </style> |
| | </html> |
| ====== Mutagen ====== | ====== Mutagen ====== |
| {{python:mutaggen_logo.svg?400|Mutagen Logo}}\\ | {{python:mutaggen_logo.svg?400|Mutagen Logo}}\\ |
| 本家: [[https://mutagen.readthedocs.org/|Overview — mutagen]]\\ | 本家: [[https://mutagen.readthedocs.org/|Overview - mutagen]]\\ |
| ソースコード: [[https://github.com/quodlibet/mutagen|quodlibet/mutagen: Python module for handling audio metadata]]\\ | ソースコード: [[https://github.com/quodlibet/mutagen|quodlibet/mutagen: Python module for handling audio metadata]]\\ |
| \\ | \\ |
| [[http://docs.puddletag.net/|Home — puddletag]]\\ | [[http://docs.puddletag.net/|Home — puddletag]]\\ |
| [[https://github.com/keithgg/puddletag|keithgg/puddletag: Powerful, simple, audio tag editor for GNU/Linux]] - github\\ | [[https://github.com/keithgg/puddletag|keithgg/puddletag: Powerful, simple, audio tag editor for GNU/Linux]] - github\\ |
| | |
| | ===== インストール ===== |
| | <WRAP prewrap 100%> |
| | <code> |
| | $ pip install mutagen |
| | </code> |
| | </WRAP> |
| | <WRAP prewrap 100% #result> |
| | <code> |
| | Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple |
| | Collecting mutagen |
| | Downloading https://files.pythonhosted.org/packages/16/b3/f7aa8edf2ff4495116f95fd442b2a346aa55d1d46313143c8814886dbcdb/mutagen-1.45.1-py3-none-any.whl (218kB) |
| | 100% |████████████████████████████████| 225kB 226kB/s |
| | Installing collected packages: mutagen |
| | Successfully installed mutagen-1.45.1 |
| | </code> |
| | </WRAP> |
| | |
| | ===== 基礎知識 ===== |
| | ==== ID3 Tag のネット情報源 ==== |
| | [[https://musicbrainz.org|MusicBrainz - The Open Music Encyclopedia]]\\ |
| | |
| | ==== 音楽ファイルフォーマット ==== |
| | |
| | === .mp3 (MPEG-1 Audio Layer-3) === |
| | MP3 (エムピースリー、英: MPEG-1 Audio Layer-3) は、音響データを圧縮する技術の1つであり、それから作られる音声ファイルフォーマットでもある。ファイルの拡張子は「.mp3」である。\\ |
| | [[wpjp>MP3|MP3 - Wikipedia]] より\\ |
| | <WRAP prewrap 100% #mincode> |
| | <code python> |
| | PS > py |
| | Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)] on win32 |
| | Type "help", "copyright", "credits" or "license" for more information. |
| | >>> import mutagen |
| | >>> ft = mutagen.File(r"B'z\048.15.2006.MONSTER\01 - ALL-OUT ATTACK.mp3") |
| | >>> ft.info.pprint() |
| | 'MPEG 1 layer 3, 192000 bps (CBR?), 44100 Hz, 2 chn, 251.37 seconds' |
| | >>> |
| | </code> |
| | </WRAP> |
| | |
| | === .m4a (MPEG-4 audio ALAC/AAC-LC) === |
| | .m4a、.m4b、.m4v、.m4p、.m4r は Apple 社が決めた拡張子である。\\ |
| | <WRAP prewrap 100% #mintbl> |
| | ^ 拡張子 ^ 形式 ^ 補足 ^ |
| | | [[https://fileinfo.com/extension/m4a|.m4a]] | MPEG-4 Audio File | AAC/Apple Lossless エンコーダ, DRM保護なし | |
| | | [[https://fileinfo.com/extension/m4b|.m4b]] | MPEG-4 Audio Book File | iTunes ストア オーディオブック ファイル, Apple FairPlay DRM保護 | |
| | | [[https://fileinfo.com/extension/m4v|.m4v]] | MPEG-4 Video File | Apple FairPlay DRM保護/保護なし | |
| | | [[https://fileinfo.com/extension/m4p|.m4p]] | MPEG-4 Music Store Audio File | Apple Music, Apple FairPlay DRM保護 | |
| | | [[https://fileinfo.com/extension/m4r|.m4r]] | MPEG-4 Ringtone File | iOS 着信音ファイル | |
| | </WRAP> |
| | [[wpjp>Apple_Lossless|ALAC]] (Apple Lossless Audio Codec)\\ |
| | ※iTunes で **Apple Lossless エンコーダ** を選択して **.m4a** を生成するとこのコーデックが使用される。\\ |
| | [[wpjp>AAC|AAC]] (Advanced Audio Coding)\\ |
| | AAC-LC (AAC Low Complexity)\\ |
| | ※iTunes で **AAC エンコーダ** を選択して **.m4a** を生成するとこのコーデックが使用される。\\ |
| | \\ |
| | [[wpjp>AAC|AAC - Wikipedia]] より\\ |
| | [[wpjp>MP4|MP4 - Wikipedia]] より\\ |
| | <WRAP prewrap 100% #mincode> |
| | <code python> |
| | PS > py |
| | Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)] on win32 |
| | Type "help", "copyright", "credits" or "license" for more information. |
| | >>> import os |
| | >>> import mutagen |
| | >>> import wave |
| | |
| | >>> wf = wave.open(r"B'z\DINOSAUR\01 Dinosaur.wav", 'r') |
| | >>> wf.getparams() |
| | _wave_params(nchannels=2, sampwidth=2, framerate=48000, nframes=14940800, comptype='NONE', compname='not compressed') |
| | >>> '{:,}'.format(os.path.getsize(r"B'z\DINOSAUR\01 Dinosaur.wav")) |
| | '59,763,244' |
| | |
| | >>> ft = mutagen.File(r"B'z\DINOSAUR\01 Dinosaur.m4a") |
| | >>> ft.info.pprint() |
| | 'MPEG-4 audio (ALAC), 311.27 seconds, 972145 bps' |
| | >>> '{:,}'.format(os.path.getsize(r"B'z\DINOSAUR\01 Dinosaur.m4a")) |
| | '37,853,103' |
| | |
| | >>> ft = mutagen.File(r"B'z\054.20.2017.DINOSAUR\01 Dinosaur.m4a") |
| | >>> ft.info.pprint() |
| | 'MPEG-4 audio (AAC LC), 311.33 seconds, 320000 bps' |
| | >>> '{:,}'.format(os.path.getsize(r"B'z\054.20.2017.DINOSAUR\01 Dinosaur.m4a")) |
| | '13,562,702' |
| | >>> |
| | </code> |
| | </WRAP> |
| | ^ ^ .wav ^ .m4a(ALAC) ^ .m4a(AAC-LC) ^ |
| | ^ ビットレート | 1,536.0 kbps | 972.145 kbps | 320.0 kbps | |
| | ^ サイズ(byte) | 59,763,244\\ (100%) | 37,853,103\\ (63%) | 13,562,702\\ (22%) | |
| | ※ビットレート\\ |
| | 44100Hz × 16bit × 2ch(ステレオ) = 1,411.2kbps\\ |
| | 48000Hz x 16bit × 2ch(ステレオ) = 1,536.0kbps\\ |
| |
| ===== 参考文献 ===== | ===== 参考文献 ===== |
| | [[https://www.tunemobie.net/resources/aac-m4a-m4b-m4p-m4r.html|AAC、M4A、M4B、M4PとM4Rとは?iTunes音声形式の説明 - TuneMobie]]\\ |
| | [[https://align-centre.hatenablog.com/entry/2014/04/28/222154|デジタルオーディオの仕組み - 音声圧縮の原理 MP3, AAC, ATRAC, etc. - White croQuis]]\\ |
| | [[https://blog.goo.ne.jp/jsp_job/e/b2cbf680f1e9fbc374ecb6f0f1837237|サンプリング周波数とビットレート - Smile Engineering blog ( スマイルエンジニアリング・ブログ )]]\\ |
| | \\ |
| [[https://stackoverflow.com/questions/44895095/is-it-possible-to-add-id3-tags-to-m4a-files-using-mutagen|python - Is it possible to add ID3 tags to m4a files using mutagen? - Stack Overflow]]\\ | [[https://stackoverflow.com/questions/44895095/is-it-possible-to-add-id3-tags-to-m4a-files-using-mutagen|python - Is it possible to add ID3 tags to m4a files using mutagen? - Stack Overflow]]\\ |
| [[https://python-discid.readthedocs.io/en/latest/|python-discid 1.1 — python-discid 1.1 documentation]]\\ | [[https://python-discid.readthedocs.io/en/latest/|python-discid 1.1 — python-discid 1.1 documentation]]\\ |
| [[http://www.kuma-de.com/blog/2018-05-03/7404|[日記] CDの曲情報ってどうやって取得しているの? CDDB / TOC « きんくまデザイン]]\\ | [[http://www.kuma-de.com/blog/2018-05-03/7404|[日記] CDの曲情報ってどうやって取得しているの? CDDB / TOC « きんくまデザイン]]\\ |
| [[http://wiki.hydrogenaud.io/index.php?title=Tag_Mapping|Tag Mapping - Hydrogenaudio Knowledgebase]]\\ | \\ |
| | **ID3タグ**\\ |
| [[https://ja.wikipedia.org/wiki/ID3%E3%82%BF%E3%82%B0|ID3タグ - Wikipedia]]\\ | [[wpjp>ID3タグ|ID3タグ - Wikipedia]]\\ |
| [[http://eleken.y-lab.org/report/other/mp3tags.shtml|MP3 ファイルのタグについての解説 (id3v1, id3v2, MPEG フレームヘッダ, XING ヘッダ) - Y-Lab. Electronics]]\\ | [[http://eleken.y-lab.org/report/other/mp3tags.shtml|MP3 ファイルのタグについての解説 (id3v1, id3v2, MPEG フレームヘッダ, XING ヘッダ) - Y-Lab. Electronics]]\\ |
| | \\ |
| | **ID3 マッピングテーブル**\\ |
| | [[http://wiki.hydrogenaud.io/index.php?title=Tag_Mapping|Tag Mapping - Hydrogenaudio Knowledgebase]]\\ |
| |