'Merge one audio file and one image file to create a video with ffmpeg
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.
What should I do?
Solution 1:[1]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | llogan |