将图像添加到 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)"
请帮忙.
谢谢.
推荐答案
尝试使用以下方法从静止图像创建视频:
Try creating the video from the still image using:
ffmpeg -loop_input -vframes <num_frames> -i <input_image> <output_file>
这使您可以根据需要多次重复帧以制作非零持续时间的视频.您还可以使用 -t
以秒为单位给出视频的长度,而不是帧数.
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屋!