免费A级毛片无码专区网站-成人国产精品视频一区二区-啊 日出水了 用力乖乖在线-国产黑色丝袜在线观看下-天天操美女夜夜操美女-日韩网站在线观看中文字幕-AV高清hd片XXX国产-亚洲av中文字字幕乱码综合-搬开女人下面使劲插视频

python3使用mutagen進(jìn)行音頻元數(shù)據(jù)處理

python版本:python 3.9  
mutagen版本:1.46.0
mutagen是一個(gè)處理音頻元數(shù)據(jù)的python模塊,支持多種音頻格式,是一個(gè)純粹的python庫(kù),僅依賴(lài)python標(biāo)準(zhǔn)庫(kù),可在Python 3.7及以上版本運(yùn)行,支持Linux、Windows 和 macOS系統(tǒng) 。
github地址:https://github.com/quodlibet/mutagen
幫助文檔地址:https://mutagen.readthedocs.io/en/latest/
pypi地址:https://pypi.org/project/mutagen/

python3使用mutagen進(jìn)行音頻元數(shù)據(jù)處理

文章插圖
python3使用mutagen進(jìn)行音頻元數(shù)據(jù)處理

文章插圖
python3使用mutagen進(jìn)行音頻元數(shù)據(jù)處理

文章插圖
一、安裝1、在線(xiàn)安裝直接使用pip進(jìn)行安裝:
pip install mutagen
默認(rèn)安裝最新版本 。
2、離線(xiàn)安裝2.1 下載離線(xiàn)安裝文件
可以在pypi頁(yè)面源代碼或whl文件 。
python3使用mutagen進(jìn)行音頻元數(shù)據(jù)處理

文章插圖
2.2  執(zhí)行離線(xiàn)安裝操作
1) 可以使用源碼進(jìn)行安裝
tar zxf mutagen-1.46.0.tar.gzcd mutagen-1.46.0python setup.py install
python3使用mutagen進(jìn)行音頻元數(shù)據(jù)處理

文章插圖
2)也可以使用pip install 進(jìn)行離線(xiàn)安裝
pip install mutagen-1.46.0-py3-none-any.whl
python3使用mutagen進(jìn)行音頻元數(shù)據(jù)處理

文章插圖
二、基礎(chǔ)用法1、獲取音頻文件元數(shù)據(jù)import mutagenf = mutagen.File(r"d:\tmp\1.mp3")f.values()f.pprint().split('\n')print(f.get('TXXX:Band').text)效果如下:
python3使用mutagen進(jìn)行音頻元數(shù)據(jù)處理

文章插圖
2、添加(修改)音頻元數(shù)據(jù)不存在添加,如果存在則修改 。
示例:
from mutagen.id3 import TALBf.tags.add(TALB(encoding=0, text=['some_album']))f.save()
python3使用mutagen進(jìn)行音頻元數(shù)據(jù)處理

文章插圖
3、刪除音頻元數(shù)據(jù)可使用 .tags.pop 刪除:
import mutagenf = mutagen.File(r"d:\tmp\1.mp3")f.tags.values()f.tags.pop('TXXX:Band')f.save()f.tags.values()效果如下:
python3使用mutagen進(jìn)行音頻元數(shù)據(jù)處理

文章插圖
4、獲取音頻屬性獲取音頻時(shí)長(zhǎng)、碼率、聲道信息等 。
示例:
f.info.pprint()print(f.info.sample_rate)print(f.info.channels)print(f.info.length) # secondsprint(278//60,278%60)
python3使用mutagen進(jìn)行音頻元數(shù)據(jù)處理

文章插圖
三、資源下載本文涉及源代碼及安裝文件,可從百度網(wǎng)盤(pán)獲取:
https://pan.baidu.com/s/1-vKILG3SlvKGxZe50Zo-ew
python3使用mutagen進(jìn)行音頻元數(shù)據(jù)處理

文章插圖
關(guān)注微信公眾號(hào)(聊聊博文,文末可掃碼)后回復(fù) 2022102401 獲取 。
【python3使用mutagen進(jìn)行音頻元數(shù)據(jù)處理】

    經(jīng)驗(yàn)總結(jié)擴(kuò)展閱讀