현재 폴더 내의 모든 wav 파일들을 mp3형식으로 변환하는 도스 명령어

for %%f in (*.wav) do ffmpeg -i "%%f" "%%~nf.mp3"

- %%f는 발견된 파일명입니다.

- %%~nf는 파일의 이름 부분만 추출합니다.

- 긴파일에 대비해서 파일명에는 따옴표를 넣어줘야 합니다.

- ffmpeg.exe 가 현재 폴더에 있거나 실행 가능한 경로에 있어야 합니다.

 

음질을 고음질로 유지하는 옵션은 아래와 같습니다. 44100Hz, 2채널, 192Kbps CBR 옵션입니다.

for %%f in (*.wav) do ffmpeg -y -i "%%f" -ar 44100 -ac 2 -b:a 192k "%%~nf.mp3"

비디오 제거, 44100Hz, 2채널, 190~250Kbps VBR 옵션입니다. => 참고

for %%f in (*.wav) do ffmpeg -y -i "%%f" -vn -ar 44100 -ac 2 -q:a 1 "%%~nf.mp3"

 

 

For 명령어 도움말

https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-xp/bb490909(v=technet.10)?redirectedfrom=MSDN 

 

 

Variable with modifierDescription

%~I Expands %I which removes any surrounding quotation marks ("").
%~fI Expands %I to a fully qualified path name.
%~dI Expands %I to a drive letter only.
%~pI Expands %I to a path only.
%~nI Expands %I to a file name only.
%~xI Expands %I to a file extension only.
%~sI Expands path to contain short names only.
%~aI Expands %I to the file attributes of file.
%~tI Expands %I to the date and time of file.
%~zI Expands %I to the size of file.
%~$PATH:I Searches the directories listed in the PATH environment variable and expands %I to the fully qualified name of the first one found. If the environment variable name is not defined or the file is not found by the search, this modifier expands to the empty string.

ex) 예를 들어 %%f 에서 확장자만 가져오려면 %%~xf 라고 하면 됩니다.

 

Variable with combined modifiersDescription

%~dpI Expands %I to a drive letter and path only.
%~nxI Expands %I to a file name and extension only.
%~fsI Expands %I to a full path name with short names only.
%~dp$PATH:I Searches the directories listed in the PATH environment variable for %I and expands to the drive letter and path of the first one found.
%~ftzaI Expands %I to an output line that is like dir.

 

추가)

ffmpeg은 자막을 추가하거나

mp3파일을 합치는 것도 가능합니다.

 

다음 명령은 01.mp3에 앞부분.mp3를 앞에 붙이고 합친 오디오를 wav파일로 변환합니다.

ffmpeg -y -i "concat:앞부분.mp3|01.mp3" 01\01.wav

 

추가)

다음 명령은 영상에서 일정간격마다 프레임을 추출하는 명령입니다.

 

ffmpeg -ss [시작시간] -i [동영상파일] -vf fps=1/[초] [저장할 이미지파일패턴과 확장자(%04d.jpg)] 와 같은 식입니다. 아래 명령은 10초에 1컷씩 프레임을 0001.jpg, 0002.jpg, 0003.jpg... 로 추출합니다.

ffmpeg -ss 00:00:00 -i in.mp4 -vf fps=1/10 %04d.jpg
ffmpeg -ss 00:00:00 -i in.mp4 -r 1/10 %04d.jpg

 

추가)

다음 명령은 비디오 2배속, 오디오 2배속으로 변환합니다.

ffmpeg  -i in.mp4 -filter:v "setpts=0.5*PTS" -filter:a "atempo=2.0" out.mp4