-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvideoToWav.cmd
More file actions
77 lines (63 loc) · 2.37 KB
/
videoToWav.cmd
File metadata and controls
77 lines (63 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
@echo off
setlocal enabledelayedexpansion
echo ###################################################
echo # Description: Video to audio format 16/44.1 wav
echo # Usage: videoToWav.cmd /path/to/video.mp4 [custom args]
echo # videoToWav.cmd /path/to/videos/ [custom args]
echo # Param 1: Video file or directory containing video files
echo # Param 2+ [Optional]: Custom args for ffmpeg audio conversion
echo # Requires: ffmpeg
echo ###################################################
echo.
@REM ################################################################################
@REM # check parameters & set defaults
@REM ################################################################################
set userArgs=%*
set defaultArgs=-af aformat=s16:44100
@REM set defaultArgs=-vn -acodec pcm_s16le -ar 44100 -ac 2
@REM Check 1st arg
IF "%1"=="" (
echo Error: 1st arg must be a video file or directory
exit /b 1
)
set inputPath=%1
@REM Get remaining args for ffmpeg
set ffmpegArgs=
if "%2"=="" (
@REM Check optional 2nd arg and provide default value
set ffmpegArgs=%defaultArgs%
echo ### Using default args: %defaultArgs%
) else (
@REM Use all arguments after the first one
set "allArgs=%*"
for /f "tokens=1,* delims= " %%a in ("!allArgs!") do set "ffmpegArgs=%%b"
echo ### Using user-defined args: !ffmpegArgs!
)
@REM ################################################################################
@REM Check if path is a directory or a file
@REM ################################################################################
if exist "%inputPath%\" (
@REM Process directory
echo.
echo Processing all video files in directory: %inputPath%
@REM Process all video files in the directory
for %%F in ("%inputPath%\*.mp4" "%inputPath%\*.mov" "%inputPath%\*.avi" "%inputPath%\*.mkv" "%inputPath%\*.wmv" "%inputPath%\*.webm") do (
echo.
echo Processing: %%F
CALL :ProcessFile "%%F"
)
echo.
echo Finished extracting audio from all videos in directory: %inputPath%
) else (
@REM Process single file
CALL :ProcessFile "%inputPath%"
)
exit /b 0
:ProcessFile
@REM Process a single video file
set "filename=%~1"
set "outputFile=%~dpn1.wav"
echo Extracting audio from video: %filename%
@REM Do conversion
ffmpeg -i "%filename%" %ffmpegArgs% "%outputFile%"
echo Success: Extracted audio to 16/44.1 wav: %outputFile%