FFMPEG混合设置音量 [英] FFMPEG set volume in amix
问题描述
我一直在尝试将音频mp3与视频mp4混合在一起,同时保留mp4音频.这与一起工作.
I've been trying to mix an audio mp3 with a video mp4 while retaining the mp4 audio. This is working with .
ffmpeg -y -i video.mp4 -i audio.mp3
-filter_complex "[0:a][1:a]amix=inputs=2:duration=longest[out]"
-map 0:v -map [out] output.mp4
我现在正在尝试调整声音文件(视频0.5,音频1)的音量,作为混音的一部分.
I'm now trying to adjust the volumes of the sound files (video 0.5, audio 1) as part of the mix.
我一直在尝试类似的事情
I've been trying things like
ffmpeg -i 020c276b-face-4bb3-9169-e8969c1232ba.mp4 -i test.mp3 -filter_complex
"[0:a]aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo,volume=0.5[a1];
[1:a]aformat=sample_fmts fltp:sample_rates=44100:channel_layouts=stereo,volume=0.8[a2];
[a1][a2]amerge,pan=stereo:c0<c0+c2:c1<c1+c3[out]"-map 1:v -map [out]
-c:v copy -c:a aac -strict -2 output2.mp4`
我收到诸如
[Parsed_aformat_2 @ 037f8620]解析示例格式时出错:sample_fmts fltp. [AVFilterGraph @ 038be620]初始化过滤器"aformat"时出错 与args'样本 _fmts fltp:sample_rates = 44100:channel_layouts = stereo'初始化复杂过滤器时出错.参数无效
[Parsed_aformat_2 @ 037f8620] Error parsing sample format: sample_fmts fltp. [AVFilterGraph @ 038be620] Error initializing filter 'aformat' with args 'sample _fmts fltp:sample_rates=44100:channel_layouts=stereo' Error initializing complex filters. Invalid argument
有人知道如何使我上面的代码可以正常工作,还可以改变输入量吗?
Does anyone know how to make the code I've code above that is working, also change the volume of the inputs?
谢谢
推荐答案
如果您想使用amix
,我建议这样使用它:
If you want to use amix
I would suggest using it like this:
ffmpeg -i video.mp4 -i audio.mp3 -filter_complex \
"[0:a]volume=0.8[a0]; \
[1:a]volume=0.8[a1]; \
[a0][a1]amix=inputs=2[a]" \
-map 0:v -map "[a]" -c:v copy -c:a aac -shortest output.mp4 ;
对于amerge
方法:
ffmpeg -i video.mp4 -i audio.mp3 -filter_complex \
"[0:a]aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo,volume=0.8[a0]; \
[1:a]aformat=sample_fmts=fltp:sample_rates=44100:channel_layouts=stereo,volume=0.8[a1]; \
[a0][a1]amerge,pan=stereo|c0<c0+c2|c1<c1+c3 [a]" \
-map 0:v -map "[a]" -c:v copy -c:a aac -strict -2 -shortest output.mp4 ;
Mulvya :
amerge
以最短的输入(总是)和amix
终止 默认情况下以最长的输入终止.所以前者会 当流的长度不同时,总是会截断.
amerge
terminates with the shortest input (always) andamix
terminates with the longest input, by default. So the former will always truncate when streams are of different length.
出于测试目的,省略了
-y
标志.
-y
flag omitted for testing purposes.
这篇关于FFMPEG混合设置音量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!