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
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.