FFMPEG:转换图像+到MP4 60fps的音频,包括Fadein / vadeout和覆盖
这是我要实现的目标:
- 输入是mp3或wav,图像(jpg或png)
- 输出应为带有MP3音频的MP4视频,在60fps处,以在/淡入/淡出中非常平滑。在视频(每个)(每个)上(每个)耗尽(黑色),
我努力使这种淡入 /淡入淡出。 这是我所拥有的:
ffmpeg -r 1 -loop 1 -i image.jpg -i audio.mp3 -acodec copy -r 60 -shortest -vf fade=in:0:01 -pix_fmt yuv420p output.mp4
我的Fadein是静态的,是黑色的图像,然后是我的视频,不流畅。 如何获得平滑的60fps淡出?
我也有另一个请求,假设我有一个覆盖视频,我想加入视频。如果我将视频连接到现有视频中,那么覆盖层也将在不正确的淡入淡出的顶部,该如何实现?太感谢了。
Here is what I'm trying to achieve:
- Inputs are an MP3 or WAV, and an image (JPG or PNG)
- The output should be an MP4 video with the MP3 audio with the image, at 60FPS for a very smooth fade in/fade out (black) on the video (1s each)
I strugguling to make this fade in / fade out.
Here is what I have:
ffmpeg -r 1 -loop 1 -i image.jpg -i audio.mp3 -acodec copy -r 60 -shortest -vf fade=in:0:01 -pix_fmt yuv420p output.mp4
My fadein is static, so black image and then my video, not smooth.
How do I get a smooth 60FPS fade?
I also have another request, let's say I have an overlay video that I want to concatenate to my video. If I concatenate a video to the existing video, the overlay will also be on top of the fades which is not right, how can I achieve this? Thank you so much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在设置
nb_frame = 1
使用过滤器选项in:0:01
。如果您希望淡入持续时间,则需要指定选项名称:in:duration = 1
(start_time = 0
选项不必要,因为0是默认值)。对于vadeout,您需要指定
start_time
选项,因此首先运行ffprobe
首先获取MP3文件的持续时间。至于覆盖层,您必须在褪色之前进行。您的过滤链应看起来像
[0:v] [1:V]覆盖,淡入:in,vade:out
[addendum]褪色效果需要帧才能实现它,在滤波器
vade :
[0:v] [1:v]覆盖,fps = 60,vade:in,fade:out
。并从输出选项中删除-r 60
(或将其放入,因为它无论如何都不应该做任何事情)。You're setting
nb_frame=1
with your filter optionsin:0:01
. If you wish to fade duration, you need to specify the option name:in:duration=1
(start_time=0
option is unnecessary as 0 is the default).For fadeout, you need to specify the
start_time
option so runffprobe
first to get the duration of the mp3 file.As for the overlay, you must do it before fading. Your filterchain should look like
[0:v][1:v]overlay,fade:in,fade:out
[addendum] Fading effect requires frames to realize it, increase the framerate before the filter
fade
:[0:v][1:v]overlay,fps=60,fade:in,fade:out
. And remove-r 60
from the output option (or leave it in as it shouldn't do anything anyway).