FFMPEG amix过滤器卷问题与不同持续时间的输入 [英] FFMPEG amix filter volume issue with inputs of different duration
问题描述
我注意到,在特定情况下, ffmpeg amix
过滤器不能输出良好的结果。如果输入文件具有相同的持续时间,它可以正常工作在这种情况下,音量将以恒定值降低,可以用volume = 2
固定。
I noticed that ffmpeg amix
filter doesn't output good result in specific situation. It works fine if input files have equal duration. In that case volume is dropped in constant value and could be fixed with ",volume=2"
.
我的情况我使用不同持续时间的文件。结果体积不好第一批混合流量最低,最后一次最高。您可以在图像上看到音量随时间线性增加。
In my case I'm using files with different duration. Resulted volume is not good. First mixed stream resulted in lowest volume, and last one is highest. You can see on image that volume is increased linearly withing a time.
我的命令:
ffmpeg -i temp_0.mp4 -i user_2123_10.mp4 -i user_2123_3.mp4 -i user_2123_4.mp4
-i user_2123_7.mp4 -i user_2123_5.mp4 -i user_2123_1.mp4 -i user_2123_8.mp4
-i user_2123_0.mp4 -i user_2123_6.mp4 -i user_2123_9.mp4 -i user_2123_2.mp4
-i user_2123_11.mp4 -filter_complex "[1:a]adelay=34741.0[aud1];
[2:a]adelay=18241.0[aud2];[3:a]adelay=20602.0[aud3];
[4:a]adelay=27852.0[aud4];[5:a]adelay=22941.0[aud5];
[6:a]adelay=13142.0[aud6];[7:a]adelay=29810.0[aud7];
[8:a]adelay=12.0[aud8];[9:a]adelay=25692.0[aud9];
[10:a]adelay=32143.002[aud10];[11:a]adelay=16101.0[aud11];
[12:a]adelay=40848.0[aud12];
[0:a][aud1][aud2][aud3][aud4][aud5][aud6][aud7]
[aud8][aud9][aud10][aud11]
[aud12]amix=inputs=13:duration=first:dropout_transition=0"
-vcodec copy -y temp_1.mp4
可以通过在每个剪辑的开头和结尾应用静音来修复,然后他们将具有相同的持续时间和数量将在同一水平。
That could be fixed by applying silence at the beginning and end of each clip, then they will have same duration and volume will be at the same level.
请建议我如何使用 amix
混合许多输入,并确保恒定的音量水平。
Please suggest how I can use amix
to mix many inputs and ensure constant volume level.
推荐答案
amix
输入的音量由 1 / n
其中n =否。的积极投入。对每个音频帧进行评估。所以当一个输入消失时,剩下的输入的数量被缩小了一个数量,因此它们的数量增加。
amix
scales each input's volume by 1/n
where n = no. of active inputs. This is evaluated for each audio frame. So when an input drops out, the volume of the remaining inputs is scaled by a smaller amount, hence their volumes increase.
根据建议改变所有早期输入的dropout_transition在其他答案中,是一种方法,但我认为会导致粗调量。更好的方法是在amix之后规范化音频。
Changing the dropout_transition for all earlier inputs, as suggested in other answers, is one approach, but I think it will result in coarse volume modulations. Better method is to normalize the audio after the amix.
目前,您有两个选项, loudnorm 或 dynaudnorm 过滤器。后者更快了
At present, you have two options, the loudnorm or the dynaudnorm filter. The latter is much faster
语法是在amix之后添加,所以
Syntax is to add it after the amix, so
[aud11][aud12]amix=inputs=13:duration=first:dropout_transition=0,dynaudnorm"
阅读文档,如果您想调整参数以获得最大音量或RMS模式normalization..etc
Read the documentation, if you wish to tweak parameters for maximum volume or RMS mode normalization..etc
这篇关于FFMPEG amix过滤器卷问题与不同持续时间的输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!