将图像添加到mp3,并使用ffmpeg将其转换为视频文件 [英] Add an image to mp3, and convert it to a video file using ffmpeg
问题描述
我有以下文件:
1.一个jpeg图片
2.一段长度的mp3文件(3分钟)
I have the following files:
1. a jpeg image
2. an mp3 file of some length say (3 minutes)
我想将其转换为.3gp视频。我该怎么做?
I want to convert this to a .3gp video. How do I do it?
我尝试过以下操作:
使用jpeg图像创建零长度(时间)的视频:
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
这样做我得到一些错误消息如编解码器无法确定(视频:0x000)
On doing this I get: some error message like "Codec could not be determined(Video:0x000)"
请帮助。
谢谢。 p>
Thanks.
推荐答案
尝试从静态图像创建视频:
Try creating the video from the still image using:
ffmpeg -loop_input -vframes <num_frames> -i <input_image> <output_file>
这允许您重复帧多次,以使视频不为零持续时间。您也可以使用 -t< duration>
以秒为单位给出视频的长度,而不是帧数。
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.
另外, -f
参数指定输出格式,它不是image2,而是要使用的输出格式,如3gp。
Also, the -f
argument specifies the output format, which is not image2, but is output format you want to use, like "3gp".
您可以将视频文件的长度与mp3文件的长度相匹配,然后使用您编写的第二个命令。另外,我将在第二个命令中使用 -vcodec copy
,这样它只是复制第一步的视频数据而不执行解码/编码步骤,导致一些质量丢失。
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.
这篇关于将图像添加到mp3,并使用ffmpeg将其转换为视频文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!