Pcm format extraction from python audio files

1. Environment configuration##

https://ffmpeg.org/download.html#build-windows
# Choose for the system
If it is windows directly access the connection
https://github.com/BtbN/FFmpeg-Builds/releases
Choose xxx-shared.zip
https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2020-09-27-12-31/ffmpeg-N-99395-ga3a6b56200-win64-gpl-shared.zip
# Unzip ffmpeg.exe path configuration environment variable

2. Command line execution code##

ffmpeg -i 1.mp3 -f s16be -ar 16000-ac 1-acodec pcm_s16be 1.pcm

Three. python execution code##

from ffmpy import FFmpeg

# Convert mp3 to pcm
ff =FFmpeg(inputs={r'd:\test\1.mp3':"-i"},
   outputs={r'd:\test\1.pcm':"-f s16be -ar 16000 -ac 1 -acodec pcm_s16be"})print(ff.cmd)
ff.run()

# Convert pcm to mp3
ff1 =FFmpeg(inputs={r'd:\test\1.pcm':"-f s16be -ar 16000 -ac 1 -acodec pcm_s16be"},
   outputs={r'd:\test\1.mp3':None})print(ff1.cmd)
ff1.run()

Four. Reference documents##

Parameter description: https://blog.csdn.net/weixin_33890499/article/details/88708622

Recommended Posts

Pcm format extraction from python audio files
Python renames files