pydub
pydub copied to clipboard
Kernel kills Python process cause out of memory
Hi,
I wrote a Python app that fetches a m4a from YouTube, converts it to mp3 and uploads it to Podbean. It's working fine on my desktop computer (16GB RAM) but the kernel kills the process when I'm trying to convert the m4a to mp3 (atleast I assume that's when it's happening and not when loading the file) when I run the script on a Linode VPS with 1GB RAM.
From /var/log/syslog
Oct 13 17:26:42 hostname kernel: [874439.314157] Out of memory: Killed process 108073 (python3) total-vm:1303120kB, anon-rss:840864kB, file-rss:72kB, shmem-rss:0kB, UID:1000 pgtables:2592kB oom_score_adj:0
My code looks like this:
from pydub import AudioSegment
def convert_audio(filename):
audio = AudioSegment.from_file(filename, 'm4a')
audio.export(os.path.splitext(filename)[0] + '.mp3', format='mp3', codec='mp3')
return os.path.splitext(filename)[0] + '.mp3'
convert_audio('myfile.m4a')
I'm not quite sure why it's happening and I'm new to Python so not sure how much I'll be able to assist in the matter. But I thought I'd create an issue here just to raise awareness anyway.
Happy to help in any way I can.
Same issue I am facing but my code is different, any lead in it?
Unfortunately not. I resorted to ffmpeg instead.