問題描述
我對精確提取 PCM WAV 文件的各個部分感興趣,直到樣本級別.大多數音頻模塊似乎都依賴于特定于平臺的音頻庫.我想做這個跨平臺,速度不是問題,有沒有原生的python音頻模塊可以做到這一點?
I'm interested in precisely extracting portions of a PCM WAV file, down to the sample level. Most audio modules seem to rely on platform-specific audio libraries. I want to make this cross platform and speed is not an issue, are there any native python audio modules that can do this?
如果沒有,我將不得不解釋 PCM 二進制文件.雖然我確信我可以相當容易地挖掘 PCM 規范,并且原始格式很容易理解,但我以前從未真正用 Python 處理過二進制數據.有沒有很好的資源可以解釋如何做到這一點?專門與音頻相關的只是錦上添花.
If not, I'll have to interpret the PCM binary. While I'm sure I can dig up the PCM specs fairly easily, and raw formats are easy enough to walk, I've never actually dealt with binary data in Python before. Are there any good resources that explain how to do this? Specifically relating to audio would just be icing.
推薦答案
我看了問題和答案,我覺得我一定遺漏了一些非常明顯的東西,因為沒有人提到以下兩個模塊:
I read the question and the answers and I feel that I must be missing something completely obvious, because nobody mentioned the following two modules:
- audioop:操作原始音頻數據
- wave:讀寫WAV文件
- audioop: manipulate raw audio data
- wave: read and write WAV files
也許我來自平行宇宙,Guido 的時間機器實際上是一個時空機器 :)
Perhaps I come from a parallel universe and Guido's time machine is actually a space-time machine :)
如果您需要示例代碼,請隨時詢問.
Should you need example code, feel free to ask.
PS 假設 48kHz 采樣率,24/1.001==23.976023976... fps 的視頻幀長度為 2002 個音頻樣本,而 25fps 的視頻幀長度為 1920 個音頻樣本.
PS Assuming 48kHz sampling rate, a video frame at 24/1.001==23.976023976… fps is 2002 audio samples long, and at 25fps it's 1920 audio samples long.
這篇關于如何在沒有音頻庫的情況下編輯原始 PCM 音頻數據?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!