[FEATURE] `Install-Dependencies.bat` fix `avformat.dll` missing
Closed this issue · 2 comments
SebiAi commented
Users on Windows might have a problem exporting the audio from Audacity® on Windows - see here: #12
The Install-Dependencies.bat
should handle this by either:
Install theGyan.FFmpeg.Shared
packet instead of the normalGyan.FFmpeg
package- Downloading the recommended ffmpeg installer from here and installing it with the
/silent
switch
Code which might help for the second solution, courtesy of @Snupai:
FOR /f "tokens=2 delims==" %%f IN ('wmic os get osarchitecture /value ^| find "="') DO SET "OS_ARCH=%%f"
IF "%OS_ARCH%"=="32-Bit" GOTO :32bit ::this no reliable
IF "%OS_ARCH%"=="64-Bit" GOTO :64bit ::this no reliable
:32bit
call :PrintInfo "32bit"
powershell -Command "Invoke-WebRequest -Uri "https://lame.buanzo.org/FFmpeg_5.0.0_for_Audacity_on_Windows_x86.exe" -OutFile "%~dp0/.tmp/FFmpeg_5.0.0_for_Audacity_on_Windows_x86.exe""
"%~dp0/.tmp/FFmpeg_5.0.0_for_Audacity_on_Windows_x86.exe" /silent
:64bit
call :PrintInfo "64bit"
powershell -Command "Invoke-WebRequest -Uri "https://lame.buanzo.org/FFmpeg_5.0.0_for_Audacity_on_Windows_x86_64.exe" -OutFile "%~dp0/.tmp/FFmpeg_5.0.0_for_Audacity_on_Windows_x86_64.exe""
"%~dp0/.tmp/FFmpeg_5.0.0_for_Audacity_on_Windows_x86_64.exe" /silent
Snupai commented
Due to Cloudflare this option seems to be unreliable/not possible.
The Install-Dependencies.bat
could handle this by:
- Install the
Gyan.FFmpeg.Shared
packet instead of the normalGyan.FFmpeg
package - Add ffmpeg to PATH
- Add
Gyan.FFmpeg.Shared
path to the Audacity config
This could be done using the following snippets:
@(
(
ffmpeg -version >nul 2>&1
) && (
call :PrintInfo "ffmpeg is already installed. Skipping..."
) || (
REM ffmpeg is not installed, install it
call :PrintInfo "Installing ffmpeg..."
winget install Gyan.FFmpeg.Shared
call :addFFmpegToPath
)
)
REM --------------------check-for-ffmpeg-key---------------------------
if /i "%install%"=="n" goto :continueHewe
:checkforRegKey
REG QUERY "HKLM\SOFTWARE\FFmpeg for Audacity" /v InstallPath
IF %ERRORLEVEL% EQU 0 (
call :PrintInfo "Key exist"
REM goto :keyWasFound
)
reg query "HKLM\Software\FFmpeg for Audacity" /v InstallPath
if %ERRORLEVEL% equ 0 (
call :PrintInfo "Key exist"
REM goto :keyWasFound
)
goto :noKeyFound
:keyWasFound
call :PrintInfo "Key found nothing to do."
goto :end
:noKeyFound
call :PrintInfo "Could not find any key trying to add Path to config"
REM ---------------------------cfg-shit--------------------------------------------------
setlocal EnableDelayedExpansion
set "root=%LOCALAPPDATA%\Microsoft\WinGet\Packages\"
for /d %%W in ("%root%Gyan.FFmpeg.Shared*") do (
for /d %%D in ("%%W\ffmpeg*") do (
if exist "%%D\bin" (
set "ffmpeg_path=%%D\bin"
if exist "!ffmpeg_path!\avformat*.dll" (
call :PrintInfo "The folder contains the required file avformat.dll."
goto :cfgShitFFmpegPathdone
)
)
)
)
call :PrintWarning "ffmpeg bin directory not found."
goto :continueHewe
:cfgShitFFmpegPathdone
set "cfg_file=%APPDATA%\audacity\audacity.cfg"
set "cfg_ffmpeg_path=!ffmpeg_path:\=//!"
echo %cfg_ffmpeg_path%
echo !ffmpeg_path!
set "parameter1=Enabled"
set "value1=1"
set "parameter2=FFmpegLibPath"
set "value2=%cfg_ffmpeg_path%"
if not exist "%APPDATA%\audacity\" (
mkdir "%APPDATA%\audacity\"
(
echo [FFmpeg]
echo %parameter1%=%value1%
echo %parameter2%=%value2%
) > "%cfg_file%"
goto :end
)
if not exist "%APPDATA%\audacity\audacity.cfg" (
call :PrintInfo "audacity.cfg does not exist and will be created."
(
echo [FFmpeg]
echo %parameter1%=%value1%
echo %parameter2%=%value2%
) > "%cfg_file%"
) else (
call :PrintWarning "audacity.cfg exists"
call :LogicForEditing
)
:continueHewe
REM ---------------------------Check for python--------------------------------------------------
:LogicForEditing
(for /f "tokens=1,* delims==" %%a in ('type "%cfg_file%"') do (
set "line=%%a"
if "!line:~0,1!"=="[" (
if "!line:~-1!"=="]" (
echo !line!
)
) else if "%%a"=="%parameter1%" (
if "%%b"=="%value1%" (
call :PrintInfo "cfg file already contains FFmpeg Enabled=1"
exit /b 0
)
echo %%a=%value1%
echo %parameter2%=%value2%
) else (
echo %%a=%%b
)
)) > "%cfg_file%.new"
move /y "%cfg_file%.new" "%cfg_file%"
exit /b 0
REM ---------------------------add-ffmpeg-to-path----------------------------------------
:addFFmpegToPath
setlocal EnableDelayedExpansion
set "root=%LOCALAPPDATA%\Microsoft\WinGet\Packages\"
for /d %%W in ("%root%Gyan.FFmpeg.Shared*") do (
for /d %%D in ("%%W\ffmpeg*") do (
if exist "%%D\bin" (
set "ffmpeg_path=%%D\bin"
setx path "%PATH%;!ffmpeg_path!"
) else (
call :PrintWarning "ffmpeg bin directory not found."
)
)
)
endlocal
exit /b 0
Also the CleanUp would need to be changed to the following:
:CleanUp
del %cfg_file%.new
rd /S /Q "%~dp0/.tmp"
exit /b 0
SebiAi commented
Since Audacity 3.4 Opus support is built in therefore we do not need the avformat.dll
.