This repository has been archived by the owner on Jun 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvlcmp3.bat
102 lines (91 loc) · 3.21 KB
/
vlcmp3.bat
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
@echo off
rem -----------------------------------------------------------------
rem Conversion script to extract MP3 audio from MP4 video files
rem using VLC.
rem -----------------------------------------------------------------
rem -----------------------------------------------------------------
rem IMPORTANT!!! Set VLC_HOME to the directory containing vlc.exe
rem -----------------------------------------------------------------
set VLC_HOME=C:\PortableApps\PortableApps\VLCPortable\App\vlc
rem -----------------------------------------------------------------
rem -----------------------------------------------------------------
rem Temp files for use in conversion
rem Defaults to directory in which this batch file is called
rem May be changed, if desired
rem -----------------------------------------------------------------
set INPUT=in.mp4
set OUTPUT=out.mp3
rem -----------------------------------------------------------------
rem -----------------------------------------------------------------
rem Start of normal processing
rem -----------------------------------------------------------------
rem Clean-up from previous run
if exist "%INPUT%" (
@echo.
@echo WARNING! "%INPUT%" exists, deleting.
@echo.
del /q /f "%INPUT%"
)
if exist "%OUTPUT%" (
@echo.
@echo WARNING! "%OUTPUT%" exists, deleting.
@echo.
del /q /f "%OUTPUT%"
)
set SOURCE="%~1"
rem Handle any special characters
setlocal enabledelayedexpansion
rem Remove extra quotes
set SOURCE="!SOURCE:~1,-1!"
set TARGET=!SOURCE:.mp4=.mp3!
rem Create temp-input file to avoid dealing further with special characters
@echo Creating copy of !SOURCE! as "!INPUT!"...
copy /v /y /b !SOURCE! "!INPUT!"
if not exist "!INPUT!" (
@echo.
@echo ERROR^^! Cannot proceed: creation of "!INPUT!" from !SOURCE! failed^^!
@echo.
goto:eof
)
rem Create one backup of the intended target, just in case of re-run
if exist !TARGET! (
if exist !BACKUP! (
@echo.
@echo ERROR^^! Cannot run: !TARGET! exists with 1 backup
@echo.
goto:eof
) else (
@echo.
@echo WARNING^^! !TARGET! exists, moving to !BACKUP!
@echo.
move /y !TARGET! !BACKUP!
)
)
rem Run VLC...
"%VLC_HOME%\vlc.exe" --qt-start-minimized --no-qt-privacy-ask !INPUT! :sout=#transcode{vcodec=none,acodec=mp3,ab=224,channels=2,samplerate=44100}:std{access=file{no-overwrite},mux=wav,dst=!OUTPUT! } vlc://quit
rem Post-run clean-up of temp-input file
if exist "%INPUT%" (
del /q /f "%INPUT%"
)
rem Rename temp-output file to target name
if exist "!OUTPUT!" (
@echo Renaming "!OUTPUT!" to !TARGET!...
move /y "!OUTPUT!" !TARGET!
) else (
@echo.
@echo WARNING^^! "!OUTPUT!" does not exist^^!
@echo VLC did not convert !SOURCE! successfully.
@echo.
)
goto:eof
rem -----------------------------------------------------------------
rem End of normal processing
rem -----------------------------------------------------------------
rem -----------------------------------------------------------------
:USEERR
@echo.
@echo ERROR^^! Usage: %0 [/f] SOURCE.mp4 [/f]
@echo /f optional force deletion of existing backup file
@echo.
goto:eof
rem -----------------------------------------------------------------