16

I have MP3 audio that I would like to turn into video, by joining the audio with a solid black background. I then want to upload the video to Youtube.

Using ffmpeg, I have tried this command, and a few adjacent variants:

ffmpeg -i 'black.png' -i 'input.mp3' -c:v libx264 -tune stillimage -c:a copy 'output.mp4'

(where black.png is a PNG file that is 640×480 pixels).

However, when uploading the video output.mp4 to Youtube via Creator's Studio, I get the error:

Processing abandoned. The video could not be processed.

What could be the reason?

4 Answers 4

13

Youtube requires a video stream but your image is a single frame. Loop it to create a stream and terminate output when audio ends by adding -shortest.

ffmpeg -loop 1 -i black.png -i 'input.mp3' -c:v libx264 -tune stillimage -shortest 'output.mp4'

I don't remember if YT accepts MP3 in MP4. If it does, you can keep -c:a copy. -pix_fmt yuv420p is usually required, but YT will re-encode anyway to that pixel format.

1
  • 2
    With -pix_fmt yuv420p per the answer below, the resulting video plays on macOS too. Commented Sep 15, 2021 at 16:18
26

Alternatively you can have ffmpeg generate the black video with the color source filter instead of making an image:

ffmpeg -f lavfi -i color=c=black:s=1280x720:r=5 -i audio.mp3 -crf 0 -c:a copy -shortest output.mp4
  • Since it is just black video this is one case with lossless mode (-crf 0) will have a smaller file size than the default lossy mode.

  • The resulting file may not play in your player or device, but it will on YouTube.

1
  • What's the -f lavfi there for?
    – minseong
    Commented Jan 9 at 15:11
2

Probably becaue pixel format is wrong, add to command: -pix_fmt yuv420p

1
  • I will add that to the command, thanks. But unfortunately it didn't help with the upload issue.
    – P A N
    Commented Feb 14, 2020 at 20:46
0

To achieve the same result, on macOS, I'm using:

ffmpeg -hwaccel videotoolbox -f lavfi -i color=c=black:s=1280x720:r=25/1 -i input_audio.mp3 -c:v h264_videotoolbox -q:v 50 -c:a aac -shortest output.mp4

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