Code: Select all
ffmpeg -i "$song" -af "volumedetect" -vn -sn -dn -f null /dev/null
Code: Select all
ffmpeg -i "$song" -af "volumedetect" -vn -sn -dn -f null /dev/null
AdrianTM wrote:There's no hacker in my grandma...
Where will I see it at, see below, I get an output that ends with a big read, ": No such file or directory"dilberts_left_nut wrote:You can just run this part to see what the 'volume' variable is being set toCode: Select all
ffmpeg -i "$song" -af "volumedetect" -vn -sn -dn -f null /dev/null
But if your saying I can rerun the command on the file to see where it was set, that's true but I wanted to know what the script used to normalized the file.root@lenny:/video/Music/Jazz# ffmpeg -i "$song" -af "volumedetect" -vn -sn -dn -f null /dev/null
ffmpeg version 3.2.12-1~deb9u1 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
configuration: --prefix=/usr --extra-version='1~deb9u1' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libebur128 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
libavutil 55. 34.101 / 55. 34.101
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.101 / 57. 56.101
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libavresample 3. 1. 0 / 3. 1. 0
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
: No such file or directory
AdrianTM wrote:There's no hacker in my grandma...
Ok, so volume represents the output of the first command. That makes sense except as you've seen posted, it outputs several screens of stuff.dilberts_left_nut wrote:Well, yeah, $song isn't set so you'll need to give a real filename.
My point is, you are trying to get your input value of whatever db into the volume variable.
The ouput of that piece of code is what "volume" is being set to.
Play with it so it gives you what you want.
Code: Select all
do volume=$(ffmpeg -i "$song" -af "volumedetect" -vn -sn -dn -f null /dev/null)
Code: Select all
"volume=`echo $sDBLevel`dB"
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