TECHNICAL SPECS

Deep-dive technical documentation detailing stream probe parsing, subroutines, dynamic variable export, and FFmpeg execution flags.

FFprobe Metadata Extraction Engine

Audio Track Extractor issues a specialized ffprobe execution call to query key audio metadata streams into a temporary probe file:

ffprobe.exe -v error -select_streams a -show_entries stream=index,codec_name,sample_rate,channel_layout,bit_rate,bits_per_sample:stream_tags=language,title -of default=noprint_wrappers=1 "%filepath%" <nul > "%stq%"
Flag / Parameter Technical Purpose
-v error Restricts diagnostic output strictly to fatal errors, ensuring clean metadata streams.
-select_streams a Filters out video, subtitle, and attachment streams, parsing audio streams only.
-show_entries stream=... Requests index, codec name, sample rate, channels, bit rate, quantization bit-depth, ISO language tags, and track title.
-of default=noprint_wrappers=1 Outputs structured KEY=VALUE plain-text keypairs for easy line-by-line parsing inside Batch for /f loops.

FFmpeg Execution Routine

Once an audio stream index is selected by the user, the script executes direct bitstream extraction:

ffmpeg.exe -nostdin -hide_banner -loglevel error -i "%filepath%" -map 0:%final_idx% -c:a %acodec% -map_metadata 0 -fflags +bitexact "%out%" -y <nul
Flag Functionality
-nostdin <nul Prevents FFmpeg from hijacking Command Prompt standard input during batch execution.
-map 0:%final_idx% Selects the exact target stream index chosen by the user in the UI menu.
-c:a copy / -c:a pcm_s24le Enforces raw stream copy (or exact quantization for uncompressed DVD/Blu-Ray PCM).
-map_metadata 0 Preserves global container metadata tags (album, title, commentary).
-fflags +bitexact Suppresses Lavf/Lavc timestamp signatures for clean, bit-exact header creation.

Batch Subroutine Scope Management

The script uses isolated variable scope routines to parse metadata safely without risking command injection or variable pollution:

:parse_stream_data
set /a count+=1

setlocal enabledelayedexpansion
set "d=!cur_codec!"
if defined cur_bps if "!cur_bps!" neq "0" if "!cur_bps!" neq "N/A" set "d=!d! !cur_bps!bit"
...
for /f "delims=" %%X in ("!d!") do (
    endlocal
    set "stream_%count%_display=%%X"
)
set "stream_%count%_idx=%cur_idx%"
set "stream_%count%_codec=%cur_codec%"
set "stream_%count%_bps=%cur_bps%"
goto :eof

This approach uses setlocal enabledelayedexpansion inside the parsing routine to calculate human-readable bit rates (kbps) and sample rates (kHz), then safely exports generated output strings back to main script execution scope prior to endlocal.