1

How to convert .mp3 to .ogg and save it locally? I need to convert a local file and save it locally

I try: Ffmpeg - it doesn't work because it gives an error in almost all cases when used. And I cannot use this method because I will upload the program to the server where it will not be possible to fix this problem

Pydub - can't save because this method works with online files. Tried according to the instructions

Ftransc - works only through the terminal and often conflicts with audio files

I need a way that will work on all systems without any changes. For example ffmoeg requires a change in the system. And I use a free server that doesn’t have the ability to change settings

Andreas
  • 31
  • 3
  • If ffmpeg gives an error in almost all cases, why don't you use it in the cases where it doesn't give an error? – mkrieger1 Feb 11 '23 at 17:35
  • What you linked to wasn't an error that ffmpeg gave, it was an error from the operating system because it couldn't find ffmpeg. – mkrieger1 Feb 11 '23 at 17:37
  • @mkrieger1 I know that it was necessary to register it in the system. I installed via pip - not enough to use. But I will not be able to register ffmpeg on the server, because I use it for free and it is unlikely that administrators will want to bother with me – Andreas Feb 11 '23 at 17:43
  • I'm not sure why you think you can't use pydub. According to the other question you have linked it seems like it can do exactly what you are asking for. – mkrieger1 Feb 11 '23 at 17:43
  • Note that you'll get much worse quality creating an ogg from an mp3 than if you made it directly from the original wav. Combine two different perceptual algorithms and you get the worst of both worlds, because you're throwing away the data mp3 thinks is unnecessary and also the data ogg thinks is unnecessary, so you end up with less of the original data than you would have gotten from either algorithm on its own. – Charles Duffy Feb 11 '23 at 18:05
  • 1
    The python ffmpeg package just executes the ffmpeg utility that you must install externally. I'm confused about how you want to save locally but it won't work because you want to upload the program to the server. Do you want to put all of this code on a server? And it doesn't have ffmpeg? This seems like a question for superuser.com, not python. The python part is working. – tdelaney Feb 11 '23 at 18:24

1 Answers1

0

I had the same problem while I was trying to export a .mp3 file using pydub. You can actually use pydub to manipulate and edit local audio files.

Example of converting .mp3 to .ogg :

from pydub import AudioSegment
sound = AudioSegment.from_file("your\\file\\path\\example.mp3", format="mp3")
sound.export("your\\output\\path\\example.ogg", format="ogg")

By the way, pydub uses ffmpeg. So you will have to add these files to your project in order for pydub to execute properly :

  • ffmpeg.exe
  • ffplay.exe
  • ffprobe.exe

You can search for these files in the "ffmpeg" folder you downloaded.