Libav-tools
리눅스에서 명령어방식으로 동영상을 변환하기 위한 도구이다.
Libav는 변환, 조작 및 멀티미디어 형식과 프로토콜의 넓은 범위를 스트리밍하는 크로스 플랫폼 툴과 라이브러리를 제공한다. Libav는 구성 옵션의 선택에 따라 LGPL 또는 GPL 하에서 허가 된 무료 소프트웨어이다.
설치
sudo apt-get install libav-tools
(설치)
h.264로 encoding하기 위해서는 -codec:v libx264를 사용해야 하는데 기본 패키지에는 없고 다른 패키지로 대치해야 한다. 아마도 특허 문제를 피하기 위해서라고 생각한다. 해결 방법은 간단하다.
sudo apt-get install libavcodec-extra-53
(추가코덱 설치)
혹시 음성 aac 코덱이 없다고 나오면 설치한다.
sudo apt-get install libvo-aacenc-dev
이것은 개발자 버전이므로 -strict experimental
옵션이 추가로 필요하다.
정보
avprobe Game.of.Thrones.S06E01.720p.HDTV.x264-SVA.mp4
변환
한개 변환
avconv -i '두개의 느낌.avi' -c:v libx264 -c:a aac -strict experimental '두개의 느낌.mp4'
다중변환
- wmv2mp4
# WMV -> MP4 # 비트레이트는 2M # 소리는 aac for f in *.wmv; do avconv -i "$f" -c:v libx264 -c:a aac \ -b:v 2M -strict experimental "${f%.wmv}.mp4"; done
rename 's/ /_/g' *;for f in *.wmv; do avconv -i "$f" -c:v libx264 -c:a aac -b:v 2000k -strict experimental "${f%}.mp4"; done
(다중 변환.. *.wmv → *.mp4)
rename 's/ /_/g' *;for f in *.avi; do avconv -i "$f" -c:v libx264 -c:a aac -b:v 2000k -strict experimental ${f%}.mp4; done
(다중 변환.. *.avi → *.mp4)
rename 's/ /_/g' *;for f in *.mkv; do avconv -i "$f" -c:v libx264 -c:a aac -b:v 2000k -s 1280x720 -strict experimental "${f%}.mp4"; done
- 비트레이트 설정
-b:v 2000k
추가 - 쓰레드 설정
-threads 2
추가 1) - 크기 설정
-s 1280x720
To have a constant quality (but a variable bitrate), use the option ’-qscale n’ when ’n’ is between 1 (excellent quality) and 31 (worst quality).
Parameter | Description | Example Value |
b:v | Video Bitrate | 150k |
b:a | Audio Bitrate | 192k |
ac | Set Number of Audio Channels | 2 |
crf | Constant Rate Factor | 23 |
qscale | Constant Quality Scale. {1,30} | 20 |
prefwidth | Preferred Width | 640 |
prefheight | Preferred Height | 480 |
vcodec | Video Codec | libx264 |
acodec | Audio Codec | libfaac |
preset | Provides a certain encoding speed to compression ratio | medium |
threads | Set the Thread Count | 2 |
b | Set Bitrate (Output, Audio, Video) | 200k |
vpre | Loads vpre preset file (Legacy) | |
fpre | Loads fpre preset file (Legacy) | |
fps | Desired Output Framerate | 30 |
ab | Audio Bitrate | 192k |
ar | Set Audio Sampling Rate (in Hz) | 44100 |
setpts | Change the PTS (presentation timestamp) of the input video frames | 10 |
scaledownonly | Prevents scaling width and height greater than original video size | true |
참조
- FFmpeg - The FFmpeg tool and associated libraries (as of Natty, Ubuntu has switched from FFmpeg to the libav fork) is the premier video decoding and encoding system on Linux (and in computing in general).
누구나 수정할 수 있다. 위키 사용법 참고하라. |
---|
1)
libx264에서 쓰레드 설정을 안하는 것이 더 빠르다는 글이 있다.