Coverting webm to wav with ffmpeg

前端 未结 2 815
猫巷女王i
猫巷女王i 2021-01-27 01:57

I\'ve succesfully used ffmpeg in Python to convert mp3-files into wav so I can post them to Google Speech-To-Text. Now I have same situation with webm files and the old function

2条回答
  •  盖世英雄少女心
    2021-01-27 02:13

    No need to convert to WAV then do a separate command to segment. Just remove -c copy and do it all in one command:

    def convert_and_split(filename):
        command = ['ffmpeg', '-i', filename, '-f', 'segment', '-segment_time', '15', 'out%09d.wav']
        subprocess.run(command,stdout=subprocess.PIPE,stdin=subprocess.PIPE)
    

    -c copy enables stream copy mode. It is like a copy and paste, but you can't put Opus audio into WAV. Removing -c copy will allow ffmpeg to convert Opus to WAV.

提交回复
热议问题