Try trimming down the output to just what you want, by piping it ( with a | ) to some other commands, namely grep and cut.
Code: Select all
command -param1 -param2 blah | grep something | cut -d" " -f2
Code: Select all
command -param1 -param2 blah | grep something | cut -d" " -f2
AdrianTM wrote:There's no hacker in my grandma...
Ah yes, very well done for spotting my, er, deliberate mistake there, you learn fast!Soapm wrote:I had to add quotes around $song variable to account for files with spaces in their names.
Oh dear, how `awk`wardsoapm wrote:the full output of the command
Code: Select all
#!/bin/sh
for song in *.mp3
do volume=$(ffmpeg -i "$song" -af "volumedetect" -vn -sn -dn -f null /dev/null | awk '/max_volume/{gsub("-","");print $5}')
ffmpeg -i "$song" -af "volume=${volume}dB" Jazz2/"$song"
done
Thanks again, I forgot to tell you that I'm getting the below error with the second line. I have to remove dB to make the error go away so the command will complete. It seems to run but I don't know what value it's using for "volume=xxdB", only that it isn't normalized to the max_volume of 0.Head_on_a_Stick wrote:Let's try:Code: Select all
#!/bin/sh for song in *.mp3 do volume=$(ffmpeg -i "$song" -af "volumedetect" -vn -sn -dn -f null /dev/null | awk '/max_volume/{gsub("-","");print $5}') ffmpeg -i "$song" -af "volume=${volume}dB" Jazz2/"$song" done
Code: Select all
[Parsed_volume_0 @ 0x560265e9b900] [Eval @ 0x7ffed564d720] Undefined constant or missing '(' in 'dB'
[Parsed_volume_0 @ 0x560265e9b900] Error when evaluating the volume expression 'dB'
[AVFilterGraph @ 0x560265e75a60] Error initializing filter 'volume' with args 'dB'
Error opening filters!
Just run the command contained within $( and ), that is what is being stored as $volumeSoapm wrote:It would be nice if I knew what value it was using for volume in the second line so I at least know what value it's picking. Anyway to make it log or output the value it's using for volume?
Code: Select all
ffmpeg -i "$song" -af "volumedetect" -vn -sn -dn -f null /dev/null | awk '/max_volume/{gsub("-","");print $5}'
Yes, sorry, terribly bad form on my part that, the urge to show off is always bubbling up...Soapm wrote:that awk line will take me a year to decipher ROFL...
I pasted that line onto the CLI, of course with the name of a song in the $song field. It seemed to run like normal??? Where will I see the output?Head_on_a_Stick wrote:Sowill show the output that will be stored as $volume for $song, if that makes sense.Code: Select all
ffmpeg -i "$song" -af "volumedetect" -vn -sn -dn -f null /dev/null | awk '/max_volume/{gsub("-","");print $5}'
Keep showing off, I love out of the box thinking and learning new things... It's just when I went to the man page, my eyes crossed and my mind drifted because it was all Hebrew after the third word.Head_on_a_Stick wrote:Yes, sorry, terribly bad form on my part that, the urge to show off is always bubbling up...Soapm wrote:that awk line will take me a year to decipher ROFL...
In brief, the /max_volume/ bit searches for all lines containing that expression then gsub swaps all minus signs for nothing ("") and print spews out the fifth column. Hth.
Code: Select all
null /dev/null
Code: Select all
ffmpeg -i "$song" -af "volumedetect" -vn -sn -dn -f null /dev/null 2>&1 | awk '/max_volume/{gsub("-","");print $5}'
Perfect, it came back with 6.6 which was the max_volume of the file I was testing. Let me give it a try in the script...Head_on_a_Stick wrote:Turns out that ffmpeg outputs to stderr rather than stdout so try:Code: Select all
ffmpeg -i "$song" -af "volumedetect" -vn -sn -dn -f null /dev/null 2>&1 | awk '/max_volume/{gsub("-","");print $5}'
Code: Select all
#!/bin/sh
for song in *.mp3
do volume=$(ffmpeg -i "$song" -af "volumedetect" -vn -sn -dn -f null /dev/null 2>&1 | awk '/max_volume/{gsub("-","");print $5}')
ffmpeg -i "$song" -af "volume=${volume}dB" Jazz2/"$song"
done
Ah, thank you for the very kind offer but we already have a feckless proto-teen in the household so I think the position is takenSoapm wrote:The offer is still good for my first born, he's fat, lazy, a huge grocery bill and a chip off the ole block...
This is true to a limited extent. The audio editor I've been using for almost 20 years (Cool Edit 2000), in its help files, recommends not expanding/recompressing music files more than three times (IIRC). And unless you are young and have very good and well-trained hearing, I doubt you'll hear the artifacts generated this way. Since the OP indicated the whole process was intended for listening in a car, it's inconcievable the degradation would be heard at all. Maybe in my home office/sound studio, but I doubt it, certainly not by my 60+ year-old ears. It's more of a good-standard-practice sort of a thing, like shutting down all your running programs before hitting the power switch.sunrat wrote:Do you realise using ffmpeg-normalize will destroy some quality of your music? It has to decode the file first and then re-encode after normalization.
Perhaps the OP has a decent car with a decent audio system, for example:kevinthefixer wrote:Since the OP indicated the whole process was intended for listening in a car, it's inconcievable the degradation would be heard at all