티스토리 뷰
728x90
출처
- Build FFMPEG, x264 and FDK-AAC
- Raspberry Pi Camera Live Streaming
- How to install FFMPEG, Libx264, LibRTMP, LibAACPlus, LibVPX on the Raspberry Pi (Debian “Wheezy” ARMHF)
- ffmpeg native build - my experience
- Installing FFMPEG for Raspberry Pi
- 파이카메라 활용강좌 : RTMP를 이용한 웹으로 H264 영상전송
- FFmpeg CompilationGuide/RaspberryPi
- Raspberry Pi - Troubleshooting
기존에 설치되어 있는 ffmpeg 삭제, ffmpeg 컴파일 관련 패키지 설치
pi@raspberrypi:~$ sudo apt-get remove ffmpeg x264 libav-tools libvpx-dev libx264-dev yasm pi@raspberrypi:~$ sudo apt-get update pi@raspberrypi:~$ sudo apt-get -y install autoconf automake build-essential checkinstall git libass-dev \ libgpac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libspeex-dev \ libtheora-dev libtool libvorbis-dev pkg-config texi2html zlib1g-dev
yasm 소스 다운로드, 컴파일
pi@raspberrypi:~$ mkdir ~/workspace.ffmpeg pi@raspberrypi:~$ cd ~/workspace.ffmpeg pi@raspberrypi:~/workspace.ffmpeg$ wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz pi@raspberrypi:~/workspace.ffmpeg$ tar xzvf yasm-1.2.0.tar.gz && cd yasm-1.2.0 pi@raspberrypi:~/workspace.ffmpeg/yasm-1.2.0$ ./configure && make pi@raspberrypi:~/workspace.ffmpeg/yasm-1.2.0$ sudo make install
lame 소스 다운로드, 컴파일
pi@raspberrypi:~$ cd ~/workspace.ffmpeg pi@raspberrypi:~/workspace.ffmpeg$ wget http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.tar.gz pi@raspberrypi:~/workspace.ffmpeg$ tar xzvf lame-3.99.tar.gz && cd lame-3.99 pi@raspberrypi:~/workspace.ffmpeg/lame-3.99$ ./configure && make pi@raspberrypi:~/workspace.ffmpeg/lame-3.99$ sudo make install
faac 소스 다운로드, 컴파일 (ffmpeg가 최신버전의 경우 불필요한 라이브러리)
pi@raspberrypi:~$ cd ~/workspace.ffmpeg pi@raspberrypi:~/workspace.ffmpeg$ wget https://sourceforge.net/projects/faac/files/faac-src/faac-1.29/faac-1.29.9.2.tar.gz pi@raspberrypi:~/workspace.ffmpeg$ tar xzvf faac-1.29.9.2.tar.gz && cd faac-1.29.9.2 pi@raspberrypi:~/workspace.ffmpeg/faac-1.29.9.2$ ./configure && make pi@raspberrypi:~/workspace.ffmpeg/faac-1.29.9.2$ sudo make install
fdk-aac 소스 다운로드, 컴파일
pi@raspberrypi:~$ cd ~/workspace.ffmpeg pi@raspberrypi:~/workspace.ffmpeg$ git clone --depth 1 git://github.com/mstorsjo/fdk-aac.git pi@raspberrypi:~/workspace.ffmpeg$ cd fdk-aac/ pi@raspberrypi:~/workspace.ffmpeg/fdk-aac$ autoreconf -fiv pi@raspberrypi:~/workspace.ffmpeg/fdk-aac$ ./configure --disable-shared pi@raspberrypi:~/workspace.ffmpeg/fdk-aac$ make pi@raspberrypi:~/workspace.ffmpeg/fdk-aac$ sudo make install
H264 소스 다운로드, 컴파일
pi@raspberrypi:~$ cd ~/workspace.ffmpeg pi@raspberrypi:~/workspace.ffmpeg$ git clone https://code.videolan.org/videolan/x264.git pi@raspberrypi:~/workspace.ffmpeg$ cd x264 pi@raspberrypi:~/workspace.ffmpeg/x264$ ./configure --enable-static platform: ARM byte order: little-endian system: LINUX cli: yes libx264: internal shared: no static: yes bashcompletion: yes asm: yes interlaced: yes avs: avxsynth lavf: no ffms: no mp4: no gpl: yes thread: posix opencl: yes filters: crop select_every lto: no debug: no gprof: no strip: no PIC: no bit depth: all chroma format: all You can run 'make' or 'make fprofiled' now. pi@raspberrypi:~/workspace.ffmpeg/x264$ make pi@raspberrypi:~/workspace.ffmpeg/x264$ sudo make install install -d /usr/local/bin install x264 /usr/local/bin install -d /usr/local/include /usr/local/lib/pkgconfig install -m 644 ./x264.h x264_config.h /usr/local/include install -m 644 x264.pc /usr/local/lib/pkgconfig install -d /usr/local/lib install -m 644 libx264.a /usr/local/lib gcc-ranlib /usr/local/lib/libx264.a install -d /usr/share/bash-completion/completions install -m 644 -T ./tools/bash-autocomplete.sh /usr/share/bash-completion/completions/x264
ffmpeg 소스 다운로드, 컴파일
pi@raspberrypi:~$ cd ~/workspace.ffmpeg pi@raspberrypi:~/workspace.ffmpeg$ git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg pi@raspberrypi:~/workspace.ffmpeg$ cd ffmpeg pi@raspberrypi:~/workspace.ffmpeg/ffmpeg$ ./configure --extra-libs="-ldl" --enable-gpl --enable-libass --enable-libfdk-aac \ --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libspeex --enable-libtheora \ --enable-libvorbis --enable-libx264 --enable-nonfree --enable-version3 --extra-ldflags="-latomic" pi@raspberrypi:~/workspace.ffmpeg/ffmpeg$ make pi@raspberrypi:~/workspace.ffmpeg/ffmpeg$ sudo make install
ffmpeg 명령 - 이미지 추출
pi@raspberrypi:~$ ffmpeg -f video4linux2 -i /dev/video0 -r 10 -f image2 camera%03d.jpg ffmpeg version N-99456-g45070eec4c Copyright (c) 2000-2020 the FFmpeg developers built with gcc 8 (Raspbian 8.3.0-6+rpi1) configuration: --extra-libs=-ldl --enable-gpl --enable-libass --enable-libfdk-aac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libx264 --enable-nonfree --enable-version3 --extra-ldflags=-latomic libavutil 56. 60.100 / 56. 60.100 libavcodec 58.108.100 / 58.108.100 libavformat 58. 59.100 / 58. 59.100 libavdevice 58. 11.102 / 58. 11.102 libavfilter 7. 87.100 / 7. 87.100 libswscale 5. 8.100 / 5. 8.100 libswresample 3. 8.100 / 3. 8.100 libpostproc 55. 8.100 / 55. 8.100 Input #0, video4linux2,v4l2, from '/dev/video0': Duration: N/A, start: 48460.801672, bitrate: 36864 kb/s Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 640x480, 36864 kb/s, 10 fps, 10 tbr, 1000k tbn, 1000k tbc Stream mapping: Stream #0:0 -> #0:0 (rawvideo (native) -> mjpeg (native)) Press [q] to stop, [?] for help [swscaler @ 0x2944ec0] deprecated pixel format used, make sure you did set range correctly Output #0, image2, to 'camera%03d.jpg': Metadata: encoder : Lavf58.59.100 Stream #0:0: Video: mjpeg, yuvj420p(pc), 640x480, q=2-31, 200 kb/s, 10 fps, 10 tbn, 10 tbc Metadata: encoder : Lavc58.108.100 mjpeg Side data: cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A frame= 24 fps= 10 q=24.8 Lsize=N/A time=00:00:02.40 bitrate=N/A speed=1.02x video:404kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown Exiting normally, received signal 2.
확인
pi@raspberrypi:~$ ls camera*.jpg camera001.jpg camera005.jpg camera009.jpg camera013.jpg camera017.jpg camera021.jpg camera002.jpg camera006.jpg camera010.jpg camera014.jpg camera018.jpg camera022.jpg camera003.jpg camera007.jpg camera011.jpg camera015.jpg camera019.jpg camera023.jpg camera004.jpg camera008.jpg camera012.jpg camera016.jpg camera020.jpg camera024.jpg
ffmpeg 명령 - flv 포멧으로 동영상 저장
pi@raspberrypi:~$ ffmpeg -f video4linux2 -i /dev/video0 -f flv out.flv ffmpeg version N-99456-g45070eec4c Copyright (c) 2000-2020 the FFmpeg developers built with gcc 8 (Raspbian 8.3.0-6+rpi1) configuration: --extra-libs=-ldl --enable-gpl --enable-libass --enable-libfdk-aac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libx264 --enable-nonfree --enable-version3 --extra-ldflags=-latomic libavutil 56. 60.100 / 56. 60.100 libavcodec 58.108.100 / 58.108.100 libavformat 58. 59.100 / 58. 59.100 libavdevice 58. 11.102 / 58. 11.102 libavfilter 7. 87.100 / 7. 87.100 libswscale 5. 8.100 / 5. 8.100 libswresample 3. 8.100 / 3. 8.100 libpostproc 55. 8.100 / 55. 8.100 Input #0, video4linux2,v4l2, from '/dev/video0': Duration: N/A, start: 48635.919862, bitrate: 36864 kb/s Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 640x480, 36864 kb/s, 10 fps, 10 tbr, 1000k tbn, 1000k tbc Stream mapping: Stream #0:0 -> #0:0 (rawvideo (native) -> flv1 (flv)) Press [q] to stop, [?] for help Output #0, flv, to 'out.flv': Metadata: encoder : Lavf58.59.100 Stream #0:0: Video: flv1 (flv) ([2][0][0][0] / 0x0002), yuv420p, 640x480, q=2-31, 200 kb/s, 10 fps, 1k tbn, 10 tbc Metadata: encoder : Lavc58.108.100 flv Side data: cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A frame= 46 fps= 10 q=14.1 size= 256kB time=00:00:04.50 bitrate= 465.9kbits/s speed=0.988x frame= 51 fps= 10 q=19.0 size= 256kB time=00:00:05.00 bitrate= 419.3kbits/s speed=0.989x frame= 54 fps= 10 q=20.0 Lsize= 346kB time=00:00:05.30 bitrate= 535.2kbits/s speed=0.989x video:345kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.304310% Exiting normally, received signal 2.
ffmpeg 명령 - mp4 파일로 저장
pi@raspberrypi:~$ ffmpeg -f video4linux2 -i /dev/video0 -s 640x480 -r 25 -f mpeg out.mp4 ffmpeg version N-99456-g45070eec4c Copyright (c) 2000-2020 the FFmpeg developers built with gcc 8 (Raspbian 8.3.0-6+rpi1) configuration: --extra-libs=-ldl --enable-gpl --enable-libass --enable-libfdk-aac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libx264 --enable-nonfree --enable-version3 --extra-ldflags=-latomic libavutil 56. 60.100 / 56. 60.100 libavcodec 58.108.100 / 58.108.100 libavformat 58. 59.100 / 58. 59.100 libavdevice 58. 11.102 / 58. 11.102 libavfilter 7. 87.100 / 7. 87.100 libswscale 5. 8.100 / 5. 8.100 libswresample 3. 8.100 / 3. 8.100 libpostproc 55. 8.100 / 55. 8.100 Input #0, video4linux2,v4l2, from '/dev/video0': Duration: N/A, start: 49109.741243, bitrate: 36864 kb/s Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 640x480, 36864 kb/s, 10 fps, 10 tbr, 1000k tbn, 1000k tbc Stream mapping: Stream #0:0 -> #0:0 (rawvideo (native) -> mpeg1video (native)) Press [q] to stop, [?] for help [mpeg @ 0x22224d0] VBV buffer size not set, using default size of 230KB If you want the mpeg file to be compliant to some specification Like DVD, VCD or others, make sure you set the correct buffer size Output #0, mpeg, to 'out.mp4': Metadata: encoder : Lavf58.59.100 Stream #0:0: Video: mpeg1video, yuv420p, 640x480, q=2-31, 200 kb/s, 25 fps, 90k tbn, 25 tbc Metadata: encoder : Lavc58.108.100 mpeg1video Side data: cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A frame= 14 fps=0.0 q=8.3 size= 130kB time=00:00:00.44 bitrate=2420.3kbits/s dup=8 drop=0 speframe= 27 fps= 26 q=8.1 size= 162kB time=00:00:00.96 bitrate=1382.4kbits/s dup=16 drop=0 spframe= 39 fps= 25 q=10.5 size= 192kB time=00:00:01.44 bitrate=1092.3kbits/s dup=23 drop=0 sframe= 52 fps= 25 q=11.9 size= 224kB time=00:00:01.96 bitrate= 936.2kbits/s dup=31 drop=0 sframe= 59 fps= 25 q=9.8 Lsize= 232kB time=00:00:02.28 bitrate= 833.6kbits/s dup=35 drop=0 speed=0.948x video:229kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.153889% Exiting normally, received signal 2.
댓글
300x250
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- ffmpeg
- 튜닝쇼 2008
- Linux
- 일본여행
- flex
- 전예희
- 동경
- Mac
- Xcode
- ubuntu
- BPI-M4
- KOBA
- Spring MVC
- 송주경
- 지스타2007
- oracle
- sas2009
- 레이싱모델 익스트림 포토 페스티벌
- android
- Delphi
- 서울오토살롱
- ble
- MySQL
- SAS
- JavaScript
- koba2010
- Delphi Tip
- Spring
- NDK
- Java
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함