I have an mp3 live radio stream, which i write locally to an mp3 file using ffmpeg and subprocess Popen (the ffmpeg).
After i open this file with pydub and i wrote the raw_data to pyaudio for hearing the stream.
Now after all, i want to record some parts of the mp3 to an extra mp3 file.
Is it possible to write on demand, the pydub.AudioSegments to an extra file?
I try:
self.record_file.write(slice.raw_data)
where slice is the pydub.AudioSegment (which previously i wrote to pyaudio stream) and self.record_file is the record file which i created. I used "wb", but windows media player can't open this file.
if i try:
self.record_file.write(chunk)
where chunk is bytes i read from the ffmpeg download file, then i can hear but there is a repeat many times after the chunk end.