4

i use this command to merge many mp3 files in a directory:

ffmpeg -f concat -safe 0 -i <(for f in ./*.mp3; do echo "file '$PWD/$f'"; done) -c copy ./output.mp3

and now i want to convert output.mp3 to mp4 format. i want that my TV receiver read that mp4. what can i do?

1
  • my TV receiver can read mp4 files that i downloaded from youtube and mp4 torrent files
    – Alien_xxx
    Jul 8, 2021 at 14:10

2 Answers 2

5

Using an image

ffmpeg -loop 1 -i input.jpg -i input.mp3 -vf "scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:-1:-1:color=black,setsar=1,format=yuv420p" -shortest -fflags +shortest output.mp4

This command uses the scale + pad filters to make image fit into 1920x1080, setsar filter to set a normal Sample Aspect Ratio, then the format filter sets the chroma subsampling to YUV 4:2:0 for playback compatibility.

See Resizing videos with ffmpeg to fit into specific size for more info and examples.

Generating a color background

If you want a plain color background use the color filter:

ffmpeg -f lavfi -i color=c=blue:s=1280x720 -i input.mp3 -shortest -fflags +shortest output.mp4

Adding text

You can add text with the drawtext filter:

ffmpeg -f lavfi -i color=c=blue:s=1280x720 -i input.mp3 -vf "drawtext=fontfile=/path/to/font.ttf:text='Your Text':fontcolor=white:fontsize=24:box=1:boxcolor=black@0.5:boxborderw=5:x=(w-text_w)/2:y=(h-text_h)/2" -shortest -fflags +shortest output.mp4

See Text on video using ffmpeg for many more examples.

Visualization (waveforms, etc)

See How do I turn audio into video (that is, show the waveforms in a video)?

1
  • Is there a way to use a small pre-encoded video instead of an image and loop it for the duration of MP3 file?
    – Paul
    Apr 21, 2022 at 11:48
4

Make a black image in some image editor, save it as image.jpg and use this one;

ffmpeg -loop 1 -i image.jpg -i audio.mp3 -c:a copy -c:v libx264 -shortest output.mp4

(see ffmpeg wiki)

1
  • it doesn't work.receiver after a long time said "format was not supported"
    – Alien_xxx
    Jul 10, 2021 at 12:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.