잡동사니

FFmpeg 여러 파일 변환 사용법

Jo_Wick 2024. 4. 30. 03:47

1. 설치

먼저, FFmpeg 사이트에 들어가서 자신의 환경에 맞는 파일을 다운받아주면 된다.

참고로 저는 git 마스터 버전이 아닌 released-essentials 버전을 다운 받았다.

https://ffmpeg.org/download.html

 

Download FFmpeg

If you find FFmpeg useful, you are welcome to contribute by donating. More downloading options Git Repositories Since FFmpeg is developed with Git, multiple repositories from developers and groups of developers are available. Release Verification All FFmpe

ffmpeg.org

 

zip 파일을 다운 받은 후 바탕화면 아무곳에나 압축해제를 시켜주면 된다.

 

그리고 가장 중요한 환경변수 설정을 해주어야 한다.

자신이 압축해제한 경로를 지정하여, 환경변수를 만들어주면 된다.

 

예시) C:\Desktop\ffmpeg-7.0-essentials_build\ffmpeg-7.0-essentials_build\bin

 

2. Bat 파일 만들기

참고: https://vesselor.tistory.com/69

 

ffmpeg 동영상 여러개 동시 변환 - 윈도우10

유튜브 영상을 다운받아서 개인적으로 저장하다보면, mp4, mkv로 주로 변환되는데 가끔 webm으로 다운받는 경우가 있다. 이럴 때 webm 파일만 별도로 mp4로 바꿔서 저장하려는데, 동영상 변환기들이

vesselor.tistory.com

 

 

@echo off
mkdir target
for %%A in (*.mp4) do ffmpeg -i "%%A" "target/%%A".webm
pause
exit

 

텍스트 파일을 열고 위 내용을 입력한뒤 저장을 할때 모든 파일로 설정하고 encoding.bat이라고 저장을 하면된다.

이 텍스트 파일의 뜻은 bat 실행파일과 같은 폴더 내의 모든 mp4 파일을 webm으로 바꾸겠다는 뜻이다.

그리고 mkdir target으로 target이란 폴더를 생성하여 인코딩한 webm들을 모두 새로 만들어진 target 폴더 안에 저장한다.

 

아래 bat 내용은 조금 더 최적화(?) 로 encoding하는 명령어이다.

@echo off
mkdir target
for %%A in (*.mp4) do ffmpeg -i "%%A" -c:v libvpx-vp9 -crf 30 -b:v 2000k "target/%%A".webm
pause
exit

참고: https://trac.ffmpeg.org/wiki/Encode/VP9

 

Encode/VP9 – FFmpeg

FFmpeg and VP9 Encoding Guide libvpx-vp9 is the VP9 video encoder for ​WebM, an open, royalty-free media file format. libvpx-vp9 can save about 20–50% bitrate compared to libx264 (the default H.264 encoder), while retaining the same visual quality. To

trac.ffmpeg.org

위 명령줄은 각자의 목적에 맞게 바꿔 사용하면 된다. 구글에 FFmpeg 명령 관련해서 검색하면 많은 내용이 나온다.