[Tutor] Mp3 to MP4 using pyhon
Roel Schroeven
roel at roelschroeven.net
Thu Sep 30 05:07:19 EDT 2021
Op 30/09/2021 om 10:52 schreef Alan Gauld via Tutor:
> On 30/09/2021 02:48, Rajesh Koot wrote:
> > Hello,
> > I just wanted to know if there is some method to convert MP3 file into MP4
> > using coding(running script)in python in automation.
> > Please reply ASAP
>
>
> I'd suggest a wrapper around ffmpeg to set the various options.
>
> A simple command alias could do the same job but a Python script
> could do more in the way of user friendliness and intelligent
> argument validation.
>
> As far as I can recall ffmpeg is available on Windows, Mac
> and Linux.
Yep, ffmpeg is the common workhorse for all kinds of audio and/or video
conversions. Get it from https://ffmpeg.org/download.html or from your
OS's package manager. Ffmpeg is very versatile, with the disadvantage
that it can be quite a chore to figure out the correct command line for
your use case. In this case, you'll probably need something like this
(from https://stackoverflow.com/a/16376637/59122):
ffmpeg -i Kalimba.mp3 -c:a aac -vn Kalimba.m4a
(for auto MP4 files, .m4a is commonly used as the file extension)
To execute ffmpeg from your Python script, use the subprocess module.
--
"Il semble que la perfection soit atteinte non quand il n'y a plus rien à
ajouter, mais quand il n'y a plus rien à retrancher."
"Perfectie is niet bereikt als er niets meer toe te voegen is, maar als er
niets meer weg te nemen is."
-- Antoine de Saint-Exupéry
More information about the Tutor
mailing list