Ι 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?
You can use
ffmpeg with the compand audio filter (a port of
sox effect filter of same name) to "compress or expand the audio's dynamic range", but admittedly this is one of the more complicated audio filters.
Example from the documentation
Make music with both quiet and loud passages suitable for listening to in a noisy environment (whatever that means):
ffmpeg -i input -filter_complex \ "[0:a]compand=.3|.3:1|1:-90/-60|-60/-40|-40/-30|-20/-20:6:0:-90:0.2[audio]" \ -map 0:v -map "[audio]" -codec:v copy output
The video is stream copied (re-muxed) in this example since you probably don't want to touch the video.
You can use FFmpeg to adjust the levels in your video files. There is an answer on SU that explains how to do that: https://superuser.com/questions/323119/how-can-i-normalize-audio-using-ffmpeg
As AJ suggests, there may be ffmpeg commands to compress, but I suspect that in any case you'll need to separate the audio and video (demux), operate on the audio, and remux or re-encode. Ffmpeg, AviMux, and other tools can demux and remux most AVIs.
If there are defined sections with different levels, you can manually intervene using something like (free) Audacity to raise the levels of the quiet sections to match the louder ones. A final normalizing step, or even slight compression, could also help.