标准化AVI文件中的音频 [英] Normalize audio in an avi file

查看:78
本文介绍了标准化AVI文件中的音频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有不同音频级别的avi文件.有没有一种方法可以在需要的地方使用ffmpeg适当地减少和增加音频?

I have an avi file that has different levels of audio. Is there a way to decrease and increase appropriately where needed the audio of my file using ffmpeg?

推荐答案

在ffmpeg中,您可以使用音量过滤器更改曲目的音量.确保您下载了该程序的最新版本.

In ffmpeg you can use the volume filter to change the volume of a track. Make sure you download a recent version of the program.

找出要申请的收益

首先,您需要分析音频流的最大音量,以查看归一化是否还可以得到回报:

First you need to analyze the audio stream for the maximum volume to see if normalizing would even pay off:

ffmpeg -i video.avi -af "volumedetect" -f null /dev/null

在Windows上用NUL替换/dev/null.这将输出如下内容:

Replace /dev/null with NUL on Windows. This will output something like the following:

[Parsed_volumedetect_0 @ 0x7f8ba1c121a0] mean_volume: -16.0 dB
[Parsed_volumedetect_0 @ 0x7f8ba1c121a0] max_volume: -5.0 dB
[Parsed_volumedetect_0 @ 0x7f8ba1c121a0] histogram_0db: 87861

如您所见,我们的最大音量为-5.0 dB,因此我们可以应用5 dB的增益.如果您获得0 dB的值,则无需标准化音频.

As you can see, our maximum volume is -5.0 dB, so we can apply 5 dB gain. If you get a value of 0 dB, then you don't need to normalize the audio.

应用音量过滤器:

现在,我们将音量过滤器应用于音频文件.请注意,应用过滤器意味着我们将不得不对音频流进行重新编码.当然,您想要哪种音频编解码器取决于原始格式.以下是一些示例:

Now we apply the volume filter to an audio file. Note that applying the filter means we will have to re-encode the audio stream. What codec you want for audio depends on the original format, of course. Here are some examples:

纯音频文件:只需使用所需的编码器对文件进行编码:

Plain audio file: Just encode the file with whatever encoder you need:

ffmpeg -i input.wav -af "volume=5dB" output.mp3

当然,您的选择非常广泛.

Your options are very broad, of course.

AVI格式:通常在AVI容器中带有视频的MP3音频:

AVI format: Usually there's MP3 audio with video that comes in an AVI container:

ffmpeg -i video.avi -af "volume=5dB" -c:v copy -c:a libmp3lame -q:a 2 output.avi

在这里,我们选择质量等级2.值的范围是0–9,较低的值表示更好.有关设置质量的更多信息,请参阅MP3 VBR指南.例如,您还可以使用-b:a 192k设置固定的比特率.

Here we chose quality level 2. Values range from 0–9 and lower means better. Check the MP3 VBR guide for more info on setting the quality. You can also set a fixed bitrate with -b:a 192k, for example.

MP4格式:使用MP4容器时,通常会找到AAC音频.我们可以使用ffmpeg的内置AAC编码器.

MP4 format: With an MP4 container, you will typically find AAC audio. We can use ffmpeg's build-in AAC encoder.

ffmpeg -i video.mp4 -af "volume=5dB" -c:v copy -c:a aac -strict experimental -b:a 192k output.mp4

在这里您还可以使用其他AAC编码器.其中一些也支持VBR.有关一些提示,请参见此答案和AAC编码指南.

Here you can also use other AAC encoders. Some of them support VBR, too. See this answer and the AAC encoding guide for some tips.

在以上示例中,将使用-c:v copy复制视频流.如果输入文件中有字幕或多个视频流,请在输出文件名前使用-map 0选项.

In the above examples, the video stream will be copied over using -c:v copy. If there are subtitles in your input file, or multiple video streams, use the option -map 0 before the output filename.

作者的信息是 Jon Skarpeteig .Questions/323119/how-i-can-i-normalize-audio-using-ffmpeg> SuperUser

The author's info is: Jon Skarpeteig in SuperUser

这篇关于标准化AVI文件中的音频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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