cancel
Showing results for 
Search instead for 
Did you mean: 

Script Writer wanted, please.....

shutter
Community Veteran
Posts: 21,832
Thanks: 3,620
Fixes: 60
Registered: ‎06-11-2007

Script Writer wanted, please.....

In my thread.....

Audio GAIN equalizer for LINUX MINT
....  I was looking for a program/software to process my Music Video files.. so that they would all have the same/ or similar level of audio volume.
 
After much searching and checking out suggestions on Google,..  installing and uninstalling several progs... most of which would not do what they said.. or were so difficult to understand, I got nowhere with them... one of them did work...but was not happy with the quality of the sound... and it was "time limited" something like 1 hour, before it was "borked" so that you had to buy a "registration" for $40 usd....
Being a yokshurman.... I`m not going to do that.... however.... on an obscure forum I found by accidentally clicking something... one of the results said it could be done with AVIDEMUX.
Now I do have this program... and I have used it often for clipping bits off the ends of music vids and joining them together etc... but I cannot find how to "normalise" or "equalise" the volume level,
@Mook  has suggested that it can be done, using "scripts" .... but I have no idea of how this is done/written or made to work within the program....
so i am appealing for help, please... can someone read this... and let me know if it can be done.. and how to do it ....
 
 
 
Can you write a script, Please.....?   and... then......
 (most importantly..... )
 
a step by step approach/tutorial on how to integrate/use it....
 
 
   ( cos you know I`m thick regarding this stuff ! ! ) ..

Ideally, I would like to be able to "normalise/equalise" the volume level , based on the average, of lowest to highest .....

and to process a complete folder at a time... probably have to list them all ( copy and paste to the script )..
this would mean a "random" number of files depending on the content level of each folder       (artiste ) .

Alternative to that last bit.. would be to (say) process 20 at a time.

Processed files to be saved in a secondary folder... with the same name as the original...e.g.   Thalia  ( the orginal folder) saved to.... Thalia2  ( processed ) .
 
 
Processed files to be saved as .mpg4
24 REPLIES 24
VileReynard
Hero
Posts: 12,613
Thanks: 630
Fixes: 20
Registered: ‎01-09-2007

Re: Script Writer wanted, please.....

According to https://en.wikipedia.org/wiki/Loudness_war , where the dynamic range is deliberately reduced even to the extent of chopping transient peaks, you are in danger of of making things even worse [from the sound quality point of view].

It is likely that you would only be able to boost/cut a single track at a time.

As an alternative, you might find [some of] https://trac.ffmpeg.org/wiki/AudioVolume to be useful.

It suggests that a non-optimal solution is:-

 

ffmpeg -i input.wav -filter:a loudnorm output.wav

 

The input/output files need not be wav files - video or pretty much anything will do.

Warning! You will probably lose some metadata.

This is a CLI program.

"In The Beginning Was The Word, And The Word Was Aardvark."

shutter
Community Veteran
Posts: 21,832
Thanks: 3,620
Fixes: 60
Registered: ‎06-11-2007

Re: Script Writer wanted, please.....

@VileReynard  There is a program, called MP3Gain... which.. when you run it... you can put in any number of music files/tracks ( audio only ) .. click the "go" or "start" button, and it will analyse all the files/music tracks listed, and show which one`s are high volume and which ones are low volume levels...

Not sure if you can set a "mean" setting  between the two or not... its a long time since I used it to make audio cd`s for the car... however... after some while, it would produce all the tracks at an ambient level, ready to re-save and process on to the Audio CDrom as an album. and it does not seriously affect the sound quality

MP4Gain does the same kind of thing... with video sound.. but it costs about $50 USD.  Whereas MP3Gain was free, when I used it... not sure if it is still free....

RobPN
Hero
Posts: 4,760
Thanks: 2,472
Fixes: 13
Registered: ‎17-05-2013

Re: Script Writer wanted, please.....

@shutter 

Some car players will 'normalise' audio during playback but presumably yours doesn't have that option?

Googling I found this program which has a free version for non-commercial use which looks as if it might be suitable (no Linux version but you may be able to run the Windows version with some of your sorcery).

Normalisation is one of it's features and also batch conversion.

I haven't tried it.

https://www.nch.com.au/switch/index.html

 

Edit:  typos

shutter
Community Veteran
Posts: 21,832
Thanks: 3,620
Fixes: 60
Registered: ‎06-11-2007

Re: Script Writer wanted, please.....

Hi @RobPN .... hmm... that is an AUDIO program....( MP3 type files)  I want to "level out".. for want of a better word, the volume levels, on music VIDEO`s.... (MP4 type files).... so that when I run a playlist of Music Video`s.. they are all "about" the same volume level,...and I don`t get my eardrums blown away or strain them to hear,  depending on the variable volume levels..

Thanks for having a look for us, though...

 

 

RobPN
Hero
Posts: 4,760
Thanks: 2,472
Fixes: 13
Registered: ‎17-05-2013

Re: Script Writer wanted, please.....

Fair enough @shutter , when I caught up with the thread I started at the latest post (#3), and still being half-asleep forgot about the video requirement.  Embarrassed

VileReynard
Hero
Posts: 12,613
Thanks: 630
Fixes: 20
Registered: ‎01-09-2007

Re: Script Writer wanted, please.....

OK:- here is a [kind of] worked example of a mobile phone video [not one taken by me]:-

The important stuff is in bold. A lot of strictly ignorable output occurs...

jeremy@hector:~$ ffmpeg -i '/home/jeremy/Pavement5-6sep19.mp4' -filter:a volumedetect -f null /dev/null

[....]
[Parsed_volumedetect_0 @ 0x563b67818ac0] n_samples: 1632256
[Parsed_volumedetect_0 @ 0x563b67818ac0] mean_volume: -23.5 dB
[Parsed_volumedetect_0 @ 0x563b67818ac0] max_volume: -1.6 dB
[Parsed_volumedetect_0 @ 0x563b67818ac0] histogram_1db: 3
[Parsed_volumedetect_0 @ 0x563b67818ac0] histogram_2db: 20
[Parsed_volumedetect_0 @ 0x563b67818ac0] histogram_3db: 55
[Parsed_volumedetect_0 @ 0x563b67818ac0] histogram_4db: 109
[Parsed_volumedetect_0 @ 0x563b67818ac0] histogram_5db: 323
[Parsed_volumedetect_0 @ 0x563b67818ac0] histogram_6db: 605
[Parsed_volumedetect_0 @ 0x563b67818ac0] histogram_7db: 902

Suppose you want to boost the volume by 1.6dB so that you don't ruin the sound [this is something to play with], you would then run one of:-

ffmpeg -i '/home/jeremy/Pavement5-6sep19.mp4' -filter:a "volume=+1.6dB" output.mp4
Because this remuxes both video and sound this is not ideal - so try

ffmpeg -i '/home/jeremy/Pavement5-6sep19.mp4' -filter:a "volume=+1.6dB" -c:v copy -c:a aac output.mp4 

This will copy the video and only remux the sound - in my example it defaulted to 50kb/sec - but you can specify a decent value e.g. for 160kb/sec:-

ffmpeg -i '/home/jeremy/Pavement5-6sep19.mp4' -filter:a "volume=+1.6dB" -c:v copy -c:a aac -b:a 160k output.mp4

This will copy the video, remux the sound at 160kb/sec

It is quite feasible [easy] to script this, when you have discovered the loudness you want to aim for.

Samples below...

 

 

"In The Beginning Was The Word, And The Word Was Aardvark."

shutter
Community Veteran
Posts: 21,832
Thanks: 3,620
Fixes: 60
Registered: ‎06-11-2007

Re: Script Writer wanted, please.....

@VileReynard OK... well, I can probably mess up my laptop with that... so I `ll dig out an old Mint HDD and play with it...

Presumably I have to listen to each video sound level to decide the final level to set on the script ?

I am assuming that this only does one video at a time...  so is there any way, I could run (say) 20 video`s through the same script? or would that be a difficult ask, in light of my previous question about final levels?

VileReynard
Hero
Posts: 12,613
Thanks: 630
Fixes: 20
Registered: ‎01-09-2007

Re: Script Writer wanted, please.....

It's not necessary to listen to every one, if you've got hundreds of files...

Well I don't understand the meaning of the figures about max_level. You would have to find by trial and error what a good target to aim for would be, by trying several widely differing videos.

Importantly, you need to check that your equipment can handle the mangled output of ffmpeg [it should do].

A script could easily pick out the existing level from the ffmpeg rubbish and apply whatever rule you deem necessary, so that if you want to make all your videos to have, say a level of +3dB or whatever then the script could compute the necessary amendment.

It would be especially convenient [for the script] if you wanted to modify every MP4 file in a directory.

Obviously, keep backups!!!

"In The Beginning Was The Word, And The Word Was Aardvark."

shutter
Community Veteran
Posts: 21,832
Thanks: 3,620
Fixes: 60
Registered: ‎06-11-2007

Re: Script Writer wanted, please.....

It's not necessary to listen to every one, if you've got hundreds of files...

 

reckon I got about 300 music vids.... Cheesy

 

Well I don't understand the meaning of the figures about max_level. You would have to find by trial and error what a good target to aim for would be, by trying several widely differing videos.

 

Likewise ! ... my ears go on different measurements.... too loud.. loud.... medium loud... too soft.. and hardly hearable...  how that relates to dB measurements  I haven`t a clue ! ..Undecided

 

Importantly, you need to check that your equipment can handle the mangled output of ffmpeg [it should do].

 

Yep... I reckon it could... Most of the vids are "acceptable" as they are... .. so it may well be... making a list when I make up a playlist, and make notes of the "less loud" ones, to process at a later date..

 

A script could easily pick out the existing level from the ffmpeg rubbish and apply whatever rule you deem necessary, so that if you want to make all your videos to have, say a level of +3dB or whatever then the script could compute the necessary amendment.

would the +3dB level be applied to the existing level of the music volume... or would that be an arbitrary  point that all files will be reset to +3dB  ( or whatever is deemed the acceptable loudness level) 

 

It would be especially convenient [for the script] if you wanted to modify every MP4 file in a directory.

Yep... that would, indeed, be especially conveneint too !...

 

 

Obviously, keep backups!!!

 

Always.... but sometimes its fun to live dangerously !   ( fall back on re -downloading from You tube !)

VileReynard
Hero
Posts: 12,613
Thanks: 630
Fixes: 20
Registered: ‎01-09-2007

Re: Script Writer wanted, please.....

If it was me... 😀

I'd find several videos of widely differing loudness's and run the ffmpeg measure phase against each one.

Compare bits of the quiet ones against bits of ones with good sound quality, because some might be too loud and have horrible things done to the sound quality.

This ought to lead to some kind of optimal target to aim for, by processing each file.

The script could do the calculations for you since it can measure each files current loudness value and you would provide some target value.

BTW I tried this on Citizen Kane - 2GB [from the BBC] and it took about 10 minutes to decide that:-

max_volume: -4.4 dB 🙄

"In The Beginning Was The Word, And The Word Was Aardvark."

shutter
Community Veteran
Posts: 21,832
Thanks: 3,620
Fixes: 60
Registered: ‎06-11-2007

Re: Script Writer wanted, please.....

@VileReynard   OK>.. thanks for that explanation... I`ll give it a go, sometime tomorrow, maybe, meanwhile. I am posting another "trivial" problem , perhaps you may have some solution to that one !

shutter
Community Veteran
Posts: 21,832
Thanks: 3,620
Fixes: 60
Registered: ‎06-11-2007

Re: Script Writer wanted, please.....

@VileReynard  

OK.. SO ...  I found a video, to run a test on, and this is how it went.....

I first got the "properties" and copied  the location.....

 

P1100202.JPG

 

Then I started a Terminal screen... and "modified" your line below....

ffmpeg -i ' *************************************************' -filter:a "volume=+1.6dB" -c:v copy -c:a aac -b:a 160k output.mp4

Using the above "location" as a "copy and paste" so that I would not make a typo in the location.

 

here are two pics... ( cos the screen could not accommodate it all in one run ! )

 

of the terminal result....

 

P1100200.JPG

P1100201.JPG

 

 

all of which means absolutely nothing to me....  .... wot am I doing wrong ? ? ? ? Huh Huh  am I supposed to run this on the terminal by itself... or within another app/program ?

 

MisterW
Superuser
Superuser
Posts: 11,113
Thanks: 3,397
Fixes: 260
Registered: ‎30-07-2007

Re: Script Writer wanted, please.....

You didn't give it the correct filename. You just gave the location(directory) but didn't put the name of the file on the end.

Superusers are not staff, but they do have a direct line of communication into the business in order to raise issues, concerns and feedback from the community.

shutter
Community Veteran
Posts: 21,832
Thanks: 3,620
Fixes: 60
Registered: ‎06-11-2007

Re: Script Writer wanted, please.....

Ah... !   OK>. will give that a go... Cheesy