For those Windows users, I have created a batch script to Extract but not Convert a video file to its related MP3 or M4A audio file, depending on the video encoding.
This method does not lose or change the original audio quality because there is no Re-encoding so, it's really fast!
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
:: Check if a path is provided as a command line argument
IF "%~1"=="" (
SET "WORKING_DIR=%CD%"
) ELSE (
SET "WORKING_DIR=%~1"
)
:: Change to the working directory
PUSHD "%WORKING_DIR%"
:: Extracts the audio track including all metatags from the video file
FOR %%I in (".mp4") DO (
:: Retrieve the input video file audio codec
FOR /F "tokens=" %%J IN ('"ffprobe -v error -select_streams a:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 "%%I""') DO SET "codec=%%J"
IF "!codec!"=="aac" (
ffmpeg -hide_banner -i "%%I" -movflags use_metadata_tags -map 0:a -c copy "%%~nI.m4a"
) ELSE (
ffmpeg -hide_banner -i "%%I" -movflags use_metadata_tags -map 0:a -c copy "%%~nI.mp3"
)
)
:: Return to the original directory
POPD
EXIT /B
Example:
VideoToAudio.cmd "D:\Source\MySummer Videos\"
If you don't define the running path (omit the parameter) and just run VideoToAudio.cmd, it starts to convert all mp4 files inside the current path.
Note:
You must have the "ffmpeg.exe" and "ffprobe.exe" files in the running path or beside the VideoToAudio.cmd script file.
You can download FFMPEG tools from here: Get Windows Executable Files