VideoHelp Forum

Our website is made possible by displaying online advertisements to our visitors. Consider supporting us by disable your adblocker or Try ConvertXtoDVD and convert all your movies to DVD. Free trial ! :)
+ Reply to Thread
Results 1 to 7 of 7
Thread
  1. Member hydra3333's Avatar
    Join Date
    Oct 2009
    Location
    Australia
    Search Comp PM
    I gather that ffmpeg "-vol" option is deprecated and ffmepg has new audio options, eg http://ffmpeg.mplayerhq.hu/ffmpeg-filters.html#volume
    • volumedetect
    • volume=volume=+3.1dB

    but neither googling nor the ffmpeg documentation show me how to use these new options (in windows) to normalize audio volume.

    I hope someone can show me how to do something broadly along the lines:
    Code:
    ffmpeg -i a.mpg [audio parsing options to establish normalization value]
    ffmpeg -i a.mpg [video conversion options] [audio conversion options] -af "volume=+[?normalization increase?]dB" out.mp4
    Sample scripts and advice would be most welcome.

    ... if worst comes to worst, then I guess I will need to extract the audio and normalize in separate steps, similar to
    http://superuser.com/questions/323119/how-can-i-normalize-audio-using-ffmpeg
    and
    http://1024.gr/blog/normalize-audio-movies-using-ffmpeg-and-sox-windows
    and use something this to recode/mux the video and normalized audio at the same time:
    Code:
    ffmpeg -i a.mpg -i a_normalized.wav -map 0:v -map 1:a [video conversion options] [audio conversion options] out.mp4
    (I gather -map 0:v excludes the audio from the first input file, since we need to discard that un-normalized audio ?)


    PS also, is this still true of the current version of ffmpeg ? :
    http://ffmpeg.org/trac/ffmpeg/ticket/720
    -af was never integrated in the main repository,
    and using -vf for audio filters i evidently wrong,
    so the only way to use audio filtering is through the lavfi input device.
    You use it this way:
    ffmpeg -f lavfi -i "amovie=INFILE,volume=0.1" OUTFILE
    edit: https://forum.videohelp.com/threads/352047-Increasing-audio-volume-on-an-MPG?p=2209366&...=1#post2209366 show -af works OK

    PPS if anyone knows how to compress the audio range at the same time, some hints would be handy
    Quote Quote  
  2. 1. run volumedetect:
    Code:
    ffmpeg -i "h:\TestClips&Co\test.avi" -af volumedetect -f null -
    and decide how much you want to boost the audio.
    2. process audio & video (assuming your source only has one audio&video stream)
    Code:
    ffmpeg -i "path to input file" -c:v libx264 -preset slow -crf 22 -ab 128k -acodec aac -af volume=0.6 -f mp4 "Path to output file"
    "-ab 48k -c:a aac" is ment to reencode the audio to 128kBit/s aac audio
    "-af volume=0.6" is ment to boost the audio volume by 0.6dB
    "-c:v libx264 -preset slow -crf 22" is ment to reencode the video with x264, preset slow and crf 22

    I gather -map 0:v excludes the audio from the first input file, since we need to discard that un-normalized audio ?
    yes, with -map 0:v you are only using the video from source 0 and with -map 1:a you load the audio from source 1, then you process the selected inputs. this is only needed in the example since audio and video come from different sources.

    if anyone knows how to compress the audio range at the same time, some hints would be handy
    Assuming your input audio stream is supported through ffmpeg drc routines you can use -drc-scale to influence the drc values. ffmpeg has no audio filter to apply drc during processing other than during the decoding stage.

    other than that see https://forum.videohelp.com/threads/349883-Remixing-DTS-5-1-to-good-AC3-5-1-track?p=220...=1#post2202882 about dynamic range compression through sox.


    ----

    As a side note:
    - I would not encourage to use ffmpegs aac encoders (they are all not really good).
    - I would prefer soxs audio processing over ffmpegs on any day
    - I would use a GUI to do all that,... (e.g. Hybrid or other tools which support drc&co)

    Cu Selur
    Quote Quote  
  3. Member hydra3333's Avatar
    Join Date
    Oct 2009
    Location
    Australia
    Search Comp PM
    Thanks for your help.

    I hoped to automate the normalization, so ffmpeg "-af volumedetect" and manual adjustment probably isn't going to work for me by the looks.

    If ffmpeg's aac isn't great, what would you recommend ?

    I settled on this windows script to convert PAL TV captures (interlaced) for playback on Samsung Tab2 10.1 tablet):
    Code:
    @echo on
    REM assumes input is interlaced, output is interlaced !!!
    
    rem http://ffmpeg.org/trac/ffmpeg/wiki/x264EncodingGuide
    rem "%ffmpegEXE%" -h full > z.txt
    rem "%ffmpegEXE%" -formats >> z.txt
    rem "%ffmpegEXE%" -codecs >> z.txt
    
    set fINPUT=%~1%
    set fOUTPUT=%~dpn1%.mp4
    set fOUTPUTunnormalized=%~dpn1%.unnormalized.wav
    set fOUTPUTnormalized=%~dpn1%.normalized.wav
    set audiofreq=44100
    set audiobitrate=192k
    set crf=20
    set FieldFirst=1
    REM TFF
    
    REM --------------------------------------------
    DEL "%fOUTPUTunnormalized%"
    DEL "%fOUTPUTnormalized%"
    REM --------------------------------------------
    REM "%ffmpegEXE%" -i "%fINPUT%" -c:a pcm_s32le -ac 2 -ab "%audiobitrate%" -ar %audiofreq% -f wav -y "%fOUTPUTunnormalized%"
    "%ffmpegEXE%" -i "%fINPUT%" -c:a pcm_s32le -ac 2 -f wav -y "%fOUTPUTunnormalized%"
    REM --------------------------------------------
    REM --------------------------------------------
    REM careful: dynamic range compression (compand) can make hiss more audible
    REM-----
    REM COMPAND values from https://forum.videohelp.com/threads/349883-Remixing-DTS-5-1-to-good-AC3-5-1-track?p=2202882&viewfull=1#post2202882
    REM Film Standard
    REM "%soxEXE%" "%fOUTPUTunnormalized%"     "%fOUTPUTnormalized%" --clobber --show-progress gain -h rate 44100 compand 0.1,0.3 -90,-90,-70,-64,-43,-37,-31,-31,-21,-21,0,-20 0 0 0.1 gain -n -3
    REM Film Light
    REM "%soxEXE%" "%fOUTPUTunnormalized%"     "%fOUTPUTnormalized%" --clobber --show-progress gain -h rate 44100 compand 0.1,0.3 -90,-90,-70,-64,-53,-47,-41,-41,-21,-21,0,-20 0 0 0.1 gain -n -3
    REM Music Standard
    REM "%soxEXE%" "%fOUTPUTunnormalized%"     "%fOUTPUTnormalized%" --clobber --show-progress gain -h rate 44100 compand 0.1,0.3 -90,-90,-70,-58,-55,-43,-31,-31,-21,-21,0,-20 0 0 0.1 gain -n -3
    REM Music Light
    REM "%soxEXE%" "%fOUTPUTunnormalized%"     "%fOUTPUTnormalized%" --clobber --show-progress gain -h rate 44100 compand 0.1,0.3 -90,-90,-70,-58,-65,-53,-41,-41,-21,-21,0,-11 0 0 0.1 gain -n -3
    REM Speech
    REM "%soxEXE%" "%fOUTPUTunnormalized%"     "%fOUTPUTnormalized%" --clobber --show-progress gain -h rate 44100 compand 0.1,0.3 -90,-90,-70,-55,-50,-35,-31,-31,-21,-21,0,-20 0 0 0.1 gain -n -3
    REM 54db Range / 5db Limit
    REM "%soxEXE%" "%fOUTPUTunnormalized%"     "%fOUTPUTnormalized%" --clobber --show-progress gain -h rate 44100 compand 0.3,1 5:-80,-79,-54 -5 -90 0.2 gain -n -3
    REM 50db Range / 6db Limit
    REM "%soxEXE%" "%fOUTPUTunnormalized%"     "%fOUTPUTnormalized%" --clobber --show-progress gain -h rate 44100 compand 0.3,1 5:-80,-79,-50 -6 -90 0.2 gain -n -3
    REM 46db Range / 7db Limit
    REM "%soxEXE%" "%fOUTPUTunnormalized%"     "%fOUTPUTnormalized%" --clobber --show-progress gain -h rate 44100 compand 0.3,1 5:-80,-79,-46 -7 -90 0.2 gain -n -3
    REM 42db Range / 8db Limit
    REM "%soxEXE%" "%fOUTPUTunnormalized%"     "%fOUTPUTnormalized%" --clobber --show-progress gain -h rate 44100 compand 0.3,1 5:-80,-79,-42 -8 -90 0.2 gain -n -3
    REM 38db Range / 9db Limit
    REM "%soxEXE%" "%fOUTPUTunnormalized%"     "%fOUTPUTnormalized%" --clobber --show-progress gain -h rate 44100 compand 0.3,1 5:-80,-79,-38 -9 -90 0.2 gain -n -3
    REM 34db Range / 10db Limit
    REM "%soxEXE%" "%fOUTPUTunnormalized%"     "%fOUTPUTnormalized%" --clobber --show-progress gain -h rate 44100 compand 0.3,1 5:-80,-79,-34 -10 -90 0.2 gain -n -3
    REM 30db Range / 11db Limit
    REM "%soxEXE%" "%fOUTPUTunnormalized%"     "%fOUTPUTnormalized%" --clobber --show-progress gain -h rate 44100 compand 0.3,1 5:-80,-79,-30 -11 -90 0.2 gain -n -3
    REM 66db Range / 4db Limit
    REM "%soxEXE%" "%fOUTPUTunnormalized%"     "%fOUTPUTnormalized%" --clobber --show-progress gain -h rate 44100 compand 0.3,1 5:-80,-79,-66 -4 -90 0.2 gain -n -3
    REM 70db Range / 4db Limit
    REM "%soxEXE%" "%fOUTPUTunnormalized%"     "%fOUTPUTnormalized%" --clobber --show-progress gain -h rate 44100 compand 0.3,1 5:-80,-79,-70 -4 -90 0.2 gain -n -3`
    REM-----
    REM https://forum.videohelp.com/threads/349883-Remixing-DTS-5-1-to-good-AC3-5-1-track?p=2209539&viewfull=1#post2209539
    REM Film Standard closer to Dolby
    REM "%soxEXE%" "%fOUTPUTunnormalized%"     "%fOUTPUTnormalized%" --clobber --show-progress gain -h rate 44100 compand 0.1,0.3 -90,-84,-43,-37,-31,-31,-26,-26,-16,-21,0,-20.25 0 0 0.1 gain -n -3
    REM-----
    REM lightest to heaviest dynamic range compression 
    REM "%soxEXE%" "%fOUTPUTunnormalized%"     "%fOUTPUTnormalized%" --clobber --show-progress gain -h rate 44100 compand 0.3,1 5:-70,-60,-48 -5 -90 0.2 gain -n -3
    REM "%soxEXE%" "%fOUTPUTunnormalized%"     "%fOUTPUTnormalized%" --clobber --show-progress gain -h rate 44100 compand 0.3,1 5:-70,-60,-44 -6 -90 0.2 gain -n -3
    REM "%soxEXE%" "%fOUTPUTunnormalized%"     "%fOUTPUTnormalized%" --clobber --show-progress gain -h rate 44100 compand 0.3,1 5:-70,-60,-40 -6 -90 0.2 gain -n -3
    REM "%soxEXE%" "%fOUTPUTunnormalized%"     "%fOUTPUTnormalized%" --clobber --show-progress gain -h rate 44100 compand 0.3,1 5:-70,-60,-36 -7 -90 0.2 gain -n -3
    REM "%soxEXE%" "%fOUTPUTunnormalized%"     "%fOUTPUTnormalized%" --clobber --show-progress gain -h rate 44100 compand 0.3,1 5:-70,-60,-32 -8 -90 0.2 gain -n -3
    REM lightest to heaviest dynamic range compression 
    REM "%soxEXE%" "%fOUTPUTunnormalized%"     "%fOUTPUTnormalized%" --clobber --show-progress gain -h rate 44100 compand 0.3,1 5:-80,-79,-70 -4 -90 0.2 gain -n -3
    REM "%soxEXE%" "%fOUTPUTunnormalized%"     "%fOUTPUTnormalized%" --clobber --show-progress gain -h rate 44100 compand 0.3,1 5:-80,-79,-66 -4 -90 0.2 gain -n -3
    REM "%soxEXE%" "%fOUTPUTunnormalized%"     "%fOUTPUTnormalized%" --clobber --show-progress gain -h rate 44100 compand 0.3,1 5:-80,-79,-54 -5 -90 0.2 gain -n -3
    "%soxEXE%" "%fOUTPUTunnormalized%"     "%fOUTPUTnormalized%" --clobber --show-progress gain -h rate 44100 compand 0.3,1 5:-80,-79,-50 -6 -90 0.2 gain -n -3
    REM "%soxEXE%" "%fOUTPUTunnormalized%"     "%fOUTPUTnormalized%" --clobber --show-progress gain -h rate 44100 compand 0.3,1 5:-80,-79,-46 -7 -90 0.2 gain -n -3
    REM "%soxEXE%" "%fOUTPUTunnormalized%"     "%fOUTPUTnormalized%" --clobber --show-progress gain -h rate 44100 compand 0.3,1 5:-80,-79,-42 -8 -90 0.2 gain -n -3
    REM "%soxEXE%" "%fOUTPUTunnormalized%"     "%fOUTPUTnormalized%" --clobber --show-progress gain -h rate 44100 compand 0.3,1 5:-80,-79,-38 -9 -90 0.2 gain -n -3
    REM "%soxEXE%" "%fOUTPUTunnormalized%"     "%fOUTPUTnormalized%" --clobber --show-progress gain -h rate 44100 compand 0.3,1 5:-80,-79,-34 -10 -90 0.2 gain -n -3
    REM "%soxEXE%" "%fOUTPUTunnormalized%"     "%fOUTPUTnormalized%" --clobber --show-progress gain -h rate 44100 compand 0.3,1 5:-80,-79,-30 -11 -90 0.2 gain -n -3
    REM normalize without DRC
    REM "%soxEXE%" "%fOUTPUTunnormalized%"     "%fOUTPUTnormalized%" --clobber --show-progress gain -h rate 44100 gain -n 0
    REM "%soxEXE%" "%fOUTPUTunnormalized%"     "%fOUTPUTnormalized%" --clobber --show-progress gain -h rate 44100 gain -n -1
    REM "%soxEXE%" "%fOUTPUTunnormalized%"     "%fOUTPUTnormalized%" --clobber --show-progress gain -h rate 44100 gain -n -3
    REM "%soxEXE%" "%fOUTPUTunnormalized%"     "%fOUTPUTnormalized%" --clobber --show-progress gain -h rate 44100 gain -n -6
    REM COPY "%fOUTPUTunnormalized%"     "%fOUTPUTnormalized%
    
    REM -------------------------------------------- interlaced
    "%ffmpegEXE%" -i "%fINPUT%" -i "%fOUTPUTnormalized%" -map 0:v -map 1:a -c:v h264 -preset fast -flags +ildct+ilme -ildctcmp satd -top %FieldFirst% -profile:v high -level 3.2 -crf %crf% -coder 0 -c:a libvo_aacenc -ab %audiobitrate% -y "%fOUTPUT%"
    REM --------------------------------------------
    DEL "%fOUTPUTunnormalized%"
    DEL "%fOUTPUTnormalized%"
    REM --------------------------------------------
    pause
    exit


    edit: updated the script with the values in your link https://forum.videohelp.com/threads/349883-Remixing-DTS-5-1-to-good-AC3-5-1-track?p=220...=1#post2202882 )

    Cheers
    Last edited by hydra3333; 31st Dec 2012 at 19:21.
    Quote Quote  
  4. If ffmpeg's aac isn't great, what would you recommend ?
    On Windows: QAAC (= Interface to Quicktimes AAC Encoder), FHG (= interface to Frauenhofers Encoder) or NeroAacEnc (= Neros AAC Encoder).
    Quote Quote  
  5. Member hydra3333's Avatar
    Join Date
    Oct 2009
    Location
    Australia
    Search Comp PM
    OK Thanks. I have NeroAacEnc (= Neros AAC Encoder) so I must look at its CLI options then.
    Quote Quote  
  6. Extraction seems better.

    Indeed, some audio codec allow lossless normalisation (for example mp3 and use MP3Gain).

    I doubt ffmpeg 1.1 would do a lossless normalisation.
    Quote Quote  
  7. Member hydra3333's Avatar
    Join Date
    Oct 2009
    Location
    Australia
    Search Comp PM
    Pointer to continuation in a similar thread:
    https://forum.videohelp.com/threads/355502-FFMPEG-Audio-Volume-Command?p=2285229&viewfu...=1#post2285229

    ffmpeg ebur128 is available with an "integrated Loudness" number.
    I'm not really sure whether to use it or the max loudness number from "-af volumedetect"
    Quote Quote  



Similar Threads