VideoHelp Forum

+ Reply to Thread
Results 1 to 4 of 4
Thread
  1. Here's my script:
    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"

    for %%b in ("*.aac") do "X:\Portable Installations\ffmpeg\bin\ffmpeg.exe" -i "%%b" -vn -c:a pcm_s16le -ac 2 -ar 48000 -f wav "%%~nb.wav"



    for %%a in ("*.wav") 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"



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

    )

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

    pause
    The bold line above is taking the following 2 files and muxing them into an MKV file:

    filename.wav
    filename.h264

    The script ends up making an MKV with AAC instead of an MP4 with Wav. If I move the "del" aac line after the underlined line above then NO MP4 is made.

    It seems ffmpeg doesn't like creating MP4 files with Wav because Wav isn't part of the MP4 spec? Yet Adobe Premier and social media sites accept MP4 with Wav.
    Quote Quote  
  2. Member
    Join Date
    Mar 2008
    Location
    United States
    Search Comp PM
    WAV is not supported in mp4
    Quote Quote  
  3. Member
    Join Date
    Apr 2007
    Location
    Australia
    Search Comp PM
    At the end of your script; this should work.
    Code:
    del *.gain0 *.h264 *.aac *.wav X:\Temp\gain.m4a
    for %%a in ("*.wav") 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"
    Should that line end in .mkv

    "X:\Portable Installations\ffmpeg\bin\ffmpeg.exe" -i "X:\Temp\gain.m4a" -map 0:0 -vn -c:a copy "%%~da%%~pa%%~na.aac"
    .m4a files can just be renamed. At least that's what I do with tracks out of Audacity, which uses ffmpeg.
    Code:
    ren *.m4a *.aac
    Cheers.
    Last edited by pcspeak; 1st Aug 2021 at 20:08.
    Quote Quote  
  4. Member
    Join Date
    Apr 2007
    Location
    Australia
    Search Comp PM
    @VideoFanatic.
    To boost audio this is what I've used for several years.

    https://github.com/lordmulder/DynamicAudioNormalizer

    It can be stand alone, but the library is compiled into most recent editions of ffmpeg.
    I've always thought it good value.

    Some more info.
    https://www.videohelp.com/software/Dynamic-Audio-Normalizer.

    I've cobbled this together.
    The batch file runs ffmpeg against all MKV & MP4 videos in a folder and subfolders.
    The Destination root path needs to be set. It's lines 5 & 6 in the batch file.
    It can be the same drive, different path. For safety' sake.

    WARNING: There may be bugs.

    Cheers.

    Audio Boost with dynaudnorm v01.cmd
    Code:
    @echo off
    if exist videolist.txt del /q videolist.txt
    
    :: Set a root folder for the output.
    if not exist D:\newvids md D:\newvids
    set outdrv=D:\newvids
    
    :: create an input list of videos
    for /F "usebackq delims=" %%a in (`dir *.mkv *.mp4 /B /S`) do echo %%~dpnxa>> VideoList.txt
    
    :: Process the list
    for /f "delims=" %%a in (videolist.txt) do call :process "%%~da" "%%~pa" "%%~nxa"
    goto :end
    
    :process
    :: Set the variables
    set indrv=%~1
    set videopath=%~2
    set video=%~3
    Title "%~3"
    :: Create the destination folder
    if not exist "%outdrv%%videopath%" md "%outdrv%%videopath%"
    ffmpeg.exe -hide_banner -i "%indrv%%videopath%%video%" -c:v copy -c:a aac -af dynaudnorm -ar 48000 -threads 0 -y "%outdrv%%videopath%%video%"
    goto :eof
    
    :end
    Quote Quote  



Similar Threads