VideoHelp Forum

+ Reply to Thread
Results 1 to 7 of 7
Thread
  1. I use this script to demux MKVs in the current directory they are in then normalize the AAC audio then remux as MKV

    for %%a in ("*.mkv") do (

    "X:\Portable Installations\MKV Toolnix\mkvextract.exe" --ui-language en tracks "%%a" 0:"%%~na.h264" 1:"%%~na.gain0"

    for %%b in ("*.gain0") do "X:\Portable Installations\ffmpeg\bin\ffmpeg.exe" -i "%%b" -vn -c:a copy -absf aac_adtstoasc "X:\Temp\gain.m4a"

    "X:\Portable Installations\AAC Gain 1.9\aacgain.exe" -r -k -m 0 "X:\Temp\gain.m4a"

    "X:\Portable Installations\ffmpeg\bin\ffmpeg.exe" -i "X:\Temp\gain.m4a" -map 0:0 -vn -c:a copy "%%~da%%~pa%%~na.aac"

    "X:\Portable Installations\MKV Toolnix\mkvmerge.exe" -o "%%~da%%~pa%%~na.AAC.mkv" "--forced-track" "0:no" "-d" "0" "-A" "-S" "-T" "--no-global-tags" "--no-chapters" "(" "%%~na.h264" ")" "--language" "0:eng" "--forced-track" "0:no" "-a" "0" "-D" "-S" "-T" "--no-global-tags" "--no-chapters" "(" "%%~da%%~pa%%~na.aac" ")" "--track-order" "0:0,1:0"

    del "*.gain0"
    del "*.h264"
    del "*.aac"
    del "X:\Temp\gain.m4a"

    )

    "X:\Sounds\VideoRedo Completed Sound Short.WAV"

    pause

    Does anybody have a script for doing the same for MP4 with Wav files?
    Last edited by VideoFanatic; 30th Jul 2021 at 15:40.
    Quote Quote  
  2. Member
    Join Date
    Apr 2007
    Location
    Australia
    Search Comp PM
    Hi.

    This is my script for creating .aac from .wav files.
    Code:
    for %%a in ("*.wav") do "C:\qaac_2.71\qaac64.exe" -c 0 -q 0 --limiter --rate keep --ignorelength --verbose "%%a" -o "%%~na.aac"
    This is my script for replacing the .wav audio with the .aac
    Code:
    for %%a in ("*.aac") do if exist "%%~na.mp4" ffmpeg.exe -i "%%~na.mp4" -i "%%a" -map 0:v -map 1:a -c:v copy -c:a copy -y "NEW-%%~na.mp4"
    Might help.

    Cheers.
    Last edited by pcspeak; 30th Jul 2021 at 14:44.
    Quote Quote  
  3. I was hoping I would be able to normalise the Wav files without re-encoding to AAC and losing quality. Does such a thing exist which can be used in a script?
    Quote Quote  
  4. Member
    Join Date
    Apr 2007
    Location
    Australia
    Search Comp PM
    Ah, I slightly misunderstood.

    This is somewhat old. I've no idea about the quality of the results.
    The program modifies the original wav file. You have plenty of backups?
    WaveGain v1.3.1
    2011-12-16
    https://www.rarewares.org/files/others/wavegains-1.3.1.zip

    The command line:
    Code:
    wavegain.exe -r -n -c -l -f WGLog.txt audio.wav
    Best to unzip and use the frontend which is included.

    aac, at the highest quality. I cannot tell the difference between that and the wav file, using a very good set of Senheisser headphones.
    Mind you, my hearing ability may be part of the result.

    Cheers
    Quote Quote  
  5. Thanks. Can I still use that as part of my video muxing script? Does it normalize to the same volume as AAC Gain?

    Is it re-encoding the audio or is it just changing the volume like AAC gain?
    Quote Quote  
  6. Member
    Join Date
    Apr 2007
    Location
    Australia
    Search Comp PM
    Originally Posted by VideoFanatic View Post
    Thanks. Can I still use that as part of my video muxing script? Does it normalize to the same volume as AAC Gain?
    I don't know what you're trying to re-encode so I have no answers. Testing is the best way.
    Drop the normalized wav and the normalized aac into Audacity and view the spectrograms.
    This will give some visible evidence. I'm not sure how much it will help, but that's what I'd do.
    I feel they will be very close to the same. Audio codecs are quite mature and results are amazing.
    I stick by my first choice. Switch to highest quality aac audio.

    A test mkv I have has these streams.
    Code:
    C:\aa>ffmpeg -i 5.mkv
    Input #0, matroska,webm, from '5.mkv':
    Metadata:
    encoder         : libebml v1.4.2 + libmatroska v1.6.4
    creation_time   : 2021-06-16T04:39:14.000000Z
    Duration: 00:00:19.72, start: 0.000000, bitrate: 1398 kb/s
    Chapters:
    Chapter #0:0: start 0.000000, end 19.720000
    Stream #0:0: Video: h264 (Main), yuv420p(tv, smpte170m/bt470bg/bt709, progressive), 718x430 [SAR 64:45 DAR 22976:9675].........
    Stream #0:1(eng): Audio: aac (LC), 48000 Hz, stereo, fltp (default)
    Stream #0:2(eng): Subtitle: dvd_subtitle, 720x576 (default)
    Stream #0:3(fre): Audio: aac (LC), 48000 Hz, stereo, fltp (default)
    Stream #0:4(fre): Subtitle: dvd_subtitle, 720x576 (default)
    Stream #0:5(spa): Audio: aac (LC), 48000 Hz, stereo, fltp (default)
    Stream #0:6(spa): Subtitle: dvd_subtitle, 720x576 (default)
    
    C:\aa>
    How your script handles a video with the streams:
    1 Video
    3 Audio
    3 Subtitle
    1 Chapters
    I have no idea.

    With a bit of work, it could possibly be done with ffmpeg.exe.
    Perhaps a forum member has a script using MKVMerge.exe to extract individual audio streams.

    Is it re-encoding the audio or is it just changing the volume like AAC gain?
    It takes it's parameters from the input file by default. Although these can be changed according to the doco.
    The original file is changed. No output file is created. My thought is it's re-encoding.
    You'll need to do some searching and reading on the web.

    Cheers.
    Quote Quote  
  7. Thanks. I've used your MP4 muxing line in another script below. My file has AAC to start off with so I might as well use AACGain in my script and then convert to Wav however at the moment there's no point in me doing that or using wavegain in my script because FFMPEG won't create an MP4 with Wav:

    https://forum.videohelp.com/threads/402656-Can-t-get-FFMPEG-Script-to-Remux-to-MP4-wit...KV#post2627142
    Quote Quote  



Similar Threads