How do I use command line to make an mp3 file an Mp4 file with visualisations? Is it possible to batch convert a folder with MP3's into videos?
General solution
Use a program created for video editing:
for example, you may want to check AVIdemux, a free video editor designed for simple cutting, filtering and encoding tasks. that you can download from here for Linux, Windows, Mac...
There's even a tutorial on Create video from still image and from audio file.
By command line:
you can download ffmpeg
and use it from command line. It exists for Linux, Mac and Windows.
Bash solution (Linux / Mac)
If we suppose that you are under Linux and you have all the needed packages and codec installed you can try something like:
ffmpeg -loop_input -i image.jpg -i sound.mp3 -shortest -b 1000k -acodec copy out.mp4
or
ffmpeg -loop_input -i image.jpg -i sound.mp3 -shortest -vcodec libx264 -vpre default -acodec copy out.mp4
To convert your sound.mp3
file in out.mp4
with the image image.jpg
.
When you find the right combination of codec/options that you want, then you can do a script to read each file in the directory, strip the extension (.mp3)from the name and add the new extension (.mp4, NewName=$(basename $MyFile .mp3).mp4
), select the image you want to put inside and execute the command that you have just found...
How to do the script is another question :-) and you can have some hint looking at Filename Expansion, or to this question or to this one. Please try to avoid to = parse the output of ls
, use solution with find
instead...
Windows
It's possible to create a script too, or you can use some freeware or shareware software, among all AVIdemux or Video Editor... or whatever the net will offer you.
References
- Internet your preferred search engine
- ffmpeg
- Create video from still image and from audio file
- Creating Youtube (mp4) from mp3 and image
- How to Convert MP3 to MP4
Related videos on Youtube
Admin
Updated on September 18, 2022Comments
-
Admin over 1 year
I have a folder filled with mp3 files. I would like to render them as mp4 video files with music visualisations - is there a way to do this though command line?
-
whs about 9 yearsMP3 files are music files without pictures. Where do you figure the video part will come from. And forget the command line for such a conversion.
-
-
Redi over 8 yearsFirst linux command worked fine for me, however I needed to change
-loop_input
to-loop 1
. I'm running Linux Mint 17. Thanks. -
firo over 7 yearsOn Fedora 25, ffmpeg works without -loop_input -i image.jpg.
-
Ivan Marjanovic about 4 years-loop_input is deprecated use -loop 1 instead