AnswerBun.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!

Related Questions

RGB to hex and hex to RGB

51  Asked on January 3, 2022 by sindar

       

Setup dictionary lazily

8  Asked on January 3, 2022

     

Iterating over directories with Gulp?

5  Asked on January 3, 2022 by nathan-rutman

   

converting a csv file to json + python with specific json format

4  Asked on January 3, 2022 by hattricknz

     

How do you create a gRPC client in .NET Framework?

2  Asked on January 3, 2022 by rich-shipley

     

How do I switch from a merged branch to an new branch?

2  Asked on January 3, 2022 by mohammad-23

   

How can i edit an array in a JSON file from node?

1  Asked on January 3, 2022 by thomas-bouasli

       

Ask a Question

Get help from others!

© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir