具有不同持续时间的输入的 FFMPEG amix 过滤器音量问题 [英] FFMPEG amix filter volume issue with inputs of different duration

查看:157
本文介绍了具有不同持续时间的输入的 FFMPEG amix 过滤器音量问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到 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.

推荐答案

amix1/n 缩放每个输入的音量,其中 n = no.有源输入.这是针对每个音频帧进行评估的.因此,当一个输入丢失时,剩余输入的音量会缩小一个较小的量,因此它们的音量会增加.

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 是一种方法,但我认为这会导致粗略的音量调制.更好的方法是将混音后的音频归一化.

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.

目前,您有两种选择,loudnormdynaudnorm 过滤器.后者要快得多

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 模式归一化的参数..等

Read the documentation, if you wish to tweak parameters for maximum volume or RMS mode normalization..etc

这篇关于具有不同持续时间的输入的 FFMPEG amix 过滤器音量问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆