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?

6,634

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

Share:
6,634

Related videos on Youtube

Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    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
      whs about 9 years
      MP3 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
    Redi over 8 years
    First linux command worked fine for me, however I needed to change -loop_input to -loop 1. I'm running Linux Mint 17. Thanks.
  • firo
    firo over 7 years
    On Fedora 25, ffmpeg works without -loop_input -i image.jpg.
  • Ivan Marjanovic
    Ivan Marjanovic about 4 years
    -loop_input is deprecated use -loop 1 instead