- FFmpeg는 멀티미디어 파일을 처리하기 위한 무료 및 오픈 소스 도구 모음
- libavcodec, libavformat 및 libavutil과 같은 공유 오디오 및 비디오 라이브러리 세트가 포함
- FFmpeg를 사용하면 다양한 비디오와 오디오 형식을 변환하고 샘플링 속도를 설정하고 스트리밍 오디오/비디오를 캡처하고 비디오 크기를 조정할 수 있음
1. CentOS 7에서 FFmpeg 설치
1.1. YUM으로 FFmpeg 설치
- FFmpeg는 CentOS 7 핵심 리포지토리에서 사용할 수 없음
- FFmpeg 도구를 원본에서 작성하거나 타사 Yum 저장소에서 Yum을 통해 설치 필요 → RPM Fusion 저장소에서 설치
- RPM Fusion 저장소는 EPEL 소프트웨어 저장소에 따라 다름 → 시스템에서 EPEL이 활성화되지 않은 경우 다음을 입력하여 EPEL을 활성화
$ yum install epel-release -y
- NUX 저장소를 추가
$ rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
- FFmpeg를 설치
$ yum install ffmpeg ffmpeg-devel -y
- 버전을 확인하여 FFmpeg 설치를 확인
$ ffmpeg -version ffmpeg -version ffmpeg version 2.8.15 Copyright (c) 2000-2018 the FFmpeg developers built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-36) ### 생략 ### libavutil 54. 31.100 / 54. 31.100 libavcodec 56. 60.100 / 56. 60.100 libavformat 56. 40.101 / 56. 40.101 libavdevice 56. 4.100 / 56. 4.100 libavfilter 5. 40.101 / 5. 40.101 libavresample 2. 1. 0 / 2. 1. 0 libswscale 3. 1.101 / 3. 1.101 libswresample 1. 2.101 / 1. 2.101 libpostproc 53. 3.100 / 53. 3.100
1.2. FFmpeg 컴파일된 버전으로 설치
- ffmpeg-install을 통해 컴파일된 버전을 설치
- 참고 자료 : GitHub - q3aql/ffmpeg-builds: MOVED: https://gitlab.com/q3aql/ffmpeg-builds
- 저장소로부터 다운로드하기 → git clone을 통해서 저장소로부터 파일을 다운로드
$ cd $ git clone https://github.com/q3aql/ffmpeg-install.git Cloning into 'ffmpeg-install'... remote: Enumerating objects: 297, done. remote: Counting objects: 100% (40/40), done. remote: Compressing objects: 100% (27/27), done. remote: Total 297 (delta 27), reused 26 (delta 13), pack-reused 257 Receiving objects: 100% (297/297), 103.02 KiB | 0 bytes/s, done. Resolving deltas: 100% (172/172), done.
- ffmpeg-install 디렉토리 내로 이동
$ cd /root/ffmpeg-install/ $ ls apt-cyg ffmpeg-shared-build-cywin64.sh ffmpeg-static-build-linux64.sh cygwin_fix_strsafe.h ffmpeg-static-build-linux32-native.sh LICENSE.txt ffmpeg-installer.sh ffmpeg-static-build-linux32.sh README.md ffmpeg-shared-build-cywin32.sh ffmpeg-static-build-linux64-native.sh
- ffmpeg-install.sh 스크립트 실행
### -h 옵션을 통해서 옵션 확인 $ source ffmpeg-installer.sh -h * ffmpeg-install v2.0 (270321) (GPL v2.0) * Script: q3aql (q3aql@protonmail.ch) * Builds: John Van Sickle (john.vansickle@gmail.com) + Syntax: $ ffmpeg-install --install --> Install FFmpeg (Git version) $ ffmpeg-install --install release --> Install FFmpeg (Stable version) $ ffmpeg-install --update --> Update FFmpeg (Git version) $ ffmpeg-install --update release --> Update FFmpeg (Stable version) $ ffmpeg-install --uninstall --> Uninstall FFmpeg previously installed $ ffmpeg-install --help --> Show help ### 안정적인 stable 버전을 설치 $ source ffmpeg-installer.sh --install release ### ...생략... ‘ffmpeg’ -> ‘/usr/bin/ffmpeg’ ‘ffprobe’ -> ‘/usr/bin/ffprobe’ * Finished!
- 설치 확인 → ffmpeg 명령어를 통해서 버전화 설치 사항을 확인
$ ffmpeg -version ffmpeg version 6.0-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2023 the FFmpeg developers built with gcc 8 (Debian 8.3.0-6) ### 생략 ### libavutil 58. 2.100 / 58. 2.100 libavcodec 60. 3.100 / 60. 3.100 libavformat 60. 3.100 / 60. 3.100 libavdevice 60. 1.100 / 60. 1.100 libavfilter 9. 3.100 / 9. 3.100 libswscale 7. 1.100 / 7. 1.100 libswresample 4. 10.100 / 4. 10.100 libpostproc 57. 1.100 / 57. 1.100
2. FFmpeg 예제 → mp4을 m4a으로 기본 변환
- ffmpeg를 사용하여 오디오 및 비디오 파일을 변환할 때 입력 및 출력 형식을 지정할 필요가 없음
- 입력 파일 형식이 자동으로 검색되고 출력 형식은 파일 확장자에서 추측
- 비디오 파일을 mp4에서 m4a으로 변환
$ ffmpeg -i izone_test.mp4 izone_test.m4a ffmpeg version 2.8.15 Copyright (c) 2000-2018 the FFmpeg developers built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-36) ### 생략 ### libavutil 54. 31.100 / 54. 31.100 libavcodec 56. 60.100 / 56. 60.100 libavformat 56. 40.101 / 56. 40.101 libavdevice 56. 4.100 / 56. 4.100 libavfilter 5. 40.101 / 5. 40.101 libavresample 2. 1. 0 / 2. 1. 0 libswscale 3. 1.101 / 3. 1.101 libswresample 1. 2.101 / 1. 2.101 libpostproc 53. 3.100 / 53. 3.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'izone_test.mp4': Metadata: major_brand : mp42 minor_version : 0 compatible_brands: isommp42 creation_time : 2021-03-26 14:37:06 Duration: 00:42:52.49, start: 0.000000, bitrate: 2432 kb/s Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 2300 kb/s, 29.95 fps, 29.95 tbr, 11982 tbn, 59.91 tbc (default) Metadata: creation_time : 2021-03-26 14:37:06 handler_name : ISO Media file produced by Google Inc. Created on: 03/26/2021. Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default) Metadata: creation_time : 2021-03-26 14:37:06 handler_name : ISO Media file produced by Google Inc. Created on: 03/26/2021. [libx264 @ 0x20e05e0] using SAR=1/1 [libx264 @ 0x20e05e0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX [libx264 @ 0x20e05e0] profile High, level 3.1 [libx264 @ 0x20e05e0] 264 - core 142 r2495 6a301b6 - H.264/MPEG-4 AVC codec ### 생략 ### Output #0, ipod, to 'izone_test.m4a': Metadata: major_brand : mp42 minor_version : 0 compatible_brands: isommp42 encoder : Lavf56.40.101 Stream #0:0(und): Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR1:1 DAR 16:9], q=-1--1, 29.95 fps, 11982 tbn, 29.96 tbc (default) Metadata: creation_time : 2021-03-26 14:37:06 handler_name : ISO Media file produced by Google Inc. Created on: 03/26/2021. encoder : Lavc56.60.100 libx264 Stream #0:1(und): Audio: aac (libfdk_aac) (mp4a / 0x6134706D), 44100 Hz, stereo, s16, 128 kb/s (default) Metadata: creation_time : 2021-03-26 14:37:06 handler_name : ISO Media file produced by Google Inc. Created on: 03/26/2021. encoder : Lavc56.60.100 libfdk_aac Stream mapping: Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264)) Stream #0:1 -> #0:1 (aac (native) -> aac (libfdk_aac)) Press [q] to stop, [?] for help frame=70406 fps= 63 q=29.0 size= 1321080kB time=00:39:10.37 bitrate=4604.5kbits/s
참고 자료
- https://jjeongil.tistory.com/1479
- https://engineeringcode.tistory.com/137
- 리눅스(CentOS, Ubuntu 등)에서 ffmpeg-install 을 통해서 FFMPEG 쉽게 설치하기 (logger.one)
'Media(미디어) > FFmpeg' 카테고리의 다른 글
FFMPEG 옵션 (0) | 2023.09.25 |
---|---|
FFmpeg(fast forward mpeg)란 (0) | 2023.09.24 |