I found a thread with this subject, but was 2 years old, so thought best I start a new one.

I have several video files with DTS audio, which my TV won’t play, have tried a couple of scripts to convert them to AC3

The first one uses two folders in the same directory, and worked perfectly yesterday, but today I get errors, that is confusing
The second offering was written for me, so I could use different directories for source and target, but that gives errors before running.

I don’t know enough to correct these, I hope someone on here can help me.

First script

$source = Get-ChildItem -path "F:\Convert*" -Recurse -Include *.mkv


$ffpath = "C:\ProgramData\chocolatey\lib\ffmpeg\tools\ffmpeg\bin\ffmpeg.exe"


$DirOut = "F:\Converted"
$output = Join-Path $DirOut -ChildPath ((Get-Item $source).basename + "_out.mkv")


& $ffpath -i $source -map 0 -vcodec copy -scodec copy -acodec ac3 -b:a 640k $output -loglevel 8 -stats


Second script

:: convert all mkv files in a source Folder to mkv with AC3 using ffmpeg
:: eg. source T:\Old mkvs and eg.destination D:\New mkvs

:-----------------------------------------------------------------------------------------------------------------------------------
:: first edit the two Directory values for the Source and Destination "and" the path of ffmpeg
:-----------------------------------------------------------------------------------------------------------------------------------

SET Source_Files_Dir=T:\Old mkvs
SET Converted_Files_Dir=D:\New mkvs
SET ffmpeg=C:\mp4v\ffmpeg\ffmpeg.exe

cd /d %Converted_Files_Dir%
for /F "delims=" %%a in ('dir /b /s "%Source_Files_Dir%"\*.mkv') do (
"%ffmpeg%" -i "%%a" -map 0 -an -vcodec copy -scodec copy -acodec ac3 -b:a 640k "%%~na_out.mkv" -loglevel 8 -stats
)
pause
exit