TransWikia.com

Merge one audio file and one image file to create a video with ffmpeg

Stack Overflow Asked by Jerry Xiong on January 1, 2022

I first tried:

ffmpeg -y -i image.jpg -i audio.mp3 -c:a copy output.mp4

but when I uploaded to video sharing websites (bilibili.com), it says "no video track", so I tried:

ffmpeg -r 1 -loop 1 -i image.jpg -i audio.mp3 -acodec copy -r 1 -shortest output.mp4

The file was successfully uploaded, but when I watched it on the website, the image disappeared and it turned grey. I merged 6 videos and only one of them can be normally played back. (This is the URL to the video: click here, if you can visit the website you’ll see what I mean.)

What should I do?

One Answer

Problems with your command #2:

  • Frame rate is too low. Most players are unable to play 1 fps. Use 10 fps or higher for output, or set input -framerate to 10 fps or higher.
  • Chroma subsampling. Most players can only play 4:2:0, so use the format filter to force it to 4:2:0.
  • MP3 in MP4. Some players are unable to play MP3 in MP4. For highest compatibility use AAC. ffmpeg will choose AAC by default for MP4.
  • Faststart (optional). Add -movflags +faststart so MP4 can begin playback faster.

Command:

ffmpeg -framerate 1 -loop 1 -i image.jpg -i audio.mp3 -vf format=yuv420p -r 10 -shortest -movflags +faststart output.mp4

Answered by llogan on January 1, 2022

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP