首页 > 解决方案 > How to add audio to specific time [ffmpeg]

问题描述

So far, I've manage to add audio to the video in ffmpeg but it is playing all along. The enable='between(t,start,end)' option is not working

I have tried googling for possible answers but my approach is different. I wanted to enable/disable the audio repeatedly in the video.

SO far I have this code:

ffmpeg -y -i cut.mp4 -i typing.mp3 -filter_complex "[0:v]drawtext=enable='between(t,0,3)':fontfile=fonts/RobotoBoldCondensed.ttf:text='Finding Nemo...':fontcolor=white:fontsize=24:x=50:y=h-h/5+20[v0]; [1:a]volume=enable='between(t,0,3)'[a3]" -vcodec libx264 -c:a libfdk_aac -map "[v0]" -map "[a3]" -preset ultrafast -async 1  output.mp4

标签: ffmpeg

解决方案


默认情况下,音量过滤器保持输入音量。因此,您应该将表达式设置为 0 并反转启用表达式。

volume=0:enable='not(between(t,0,3))'

这将使前 3 秒的音频静音。


推荐阅读