简体   繁体   中英

How to convert the sample rate with ffmpeg-python

I'm using ffmpeg-python . I would like to change the sample rate of the audio file.

In ffmpeg-, it seems that you can change the sample rate as follows.

ffmpeg -i" movie.mp3 "-y" movie.flac "-ar 44100

-ar is sample rate.

How do I change the sample rate by ffmpeg-python?

This is my source code that is currently being written.

stream = ffmpeg.input(input_file_path)
audio = stream.audio
stream = ffmpeg.output(audio, output_file_path)
ffmpeg.run(stream, capture_stdout=True, capture_stderr=True)

I soleved.

I can set **kwargs like this.

stream = ffmpeg.output(audio, output_file_path, **{'ar': '16000','acodec':'flac'})

** is important. If you remove it, you got an error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM