Add an image to mp3, and convert it to a video fil

2020-02-09 05:11发布

I have the following files:
1. a jpeg image
2. an mp3 file of some length say (3 minutes)

I want to convert this to a .3gp video. How do I do it?

I've tried the following:
Created a video of zero length(time) using the jpeg image:

ffmpeg -f image2 -i temp_img.jpg temp_video.mpg

Then, I tried to mix the video and audio streams as:

ffmpeg -i temp_sound.mp3 -i temp_video.mpg -vcodec mpeg video_finale.mpg

On doing this I get: some error message like "Codec could not be determined(Video:0x000)"

Please help.

Thanks.

标签: ffmpeg
2条回答
2楼-- · 2020-02-09 05:32

Try creating the video from the still image using:

ffmpeg -loop_input -vframes <num_frames> -i <input_image> <output_file>

This allows you to repeat the frame as many times as you want to make a video that is not zero duration. You can also use -t <duration> to give the length of the video in seconds instead of number of frames.

Also, the -f argument specifies the output format, which is not image2, but is output format you want to use, like "3gp".

You can match the length of the video file up to the length of the mp3 file and then use the second command you wrote. Also, I would use -vcodec copy in the second command so that it just copies the video data from the first step without performing a decode/encode step causing some quality to be lost.

查看更多
Emotional °昔
3楼-- · 2020-02-09 05:41

http://www.catswhocode.com/blog/19-ffmpeg-commands-for-all-needs

A love these commands but have not used them in a while so looked it up for you as it should be help full.

查看更多
登录 后发表回答