简体   繁体   English

使用FFmpeg将音频输入和视频混合到特定位置

[英]Mix audio input with video to specific location with FFmpeg

I created small video editing tool with which you can put some overlay images to the video and show them at specific locations and durations (filter: overlay=enabled(from, to...), etc.). 我创建了一个小型视频编辑工具,您可以使用该工具将一些重叠图像添加到视频中,并在特定的位置和持续时间显示它们(过滤器:overlay = enabled(from,to ...)等)。 Now I also want to add some short audio sounds on the same way like pictures -> adding them to a specific time in the video. 现在,我还想以与图片相同的方式添加一些简短的音频声音->将它们添加到视频中的特定时间。 That means that overlays and audio sounds should be in one command if possible. 这意味着如果可能的话,叠加和音频声音应该在一个命令中。 I am using amix to merge all sound channels (video.mp4 and sound.mp3) but the thing is that they both start at the beginning. 我正在使用amix合并所有声音通道(video.mp4和sound.mp3),但事实是它们都从头开始。 I tried with adelay=1500 but then I actually delay one channel that means I hear duplicate sounds with 1.5 sec delay. 我尝试使用adelay = 1500,但实际上我延迟了一个声道,这意味着我以1.5秒的延迟听到重复的声音。 So I would like to delay only sound.mp3 input. 所以我只想延迟sound.mp3输入。 Am I doing something wrong? 难道我做错了什么?

My try was that: 我的尝试是:

-i video.mp4 -i sound.mp3 -filter_complex amix -preset ultrafast -vcodec libx264 -r 24 -profile:v baseline -threads 14 video_output.mp4

Thank you very much! 非常感谢你!

I'm still fairly new to using FFMPEG but i've used "-ss 0.3 -i INPUT" to fix offset/latency on mixing of two audio files. 我对使用FFMPEG还是很陌生,但是我使用了“ -ss 0.3 -i INPUT”来解决两个音频文件混合时的偏移/延迟。

Try this: 尝试这个:

    -i video.mp4 -ss 0.015 -i sound.mp3 -filter_complex amix -preset ultrafast -vcodec libx264 -r 24 -profile:v baseline -threads 14 video_output.mp4

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM