기본 콘텐츠로 건너뛰기

라즈베리파이3B ffmpeg 하드웨어 가속

라즈베리파이3B ffmpeg 하드웨어 가속..

일단.. 혹시 깔려 있을지 모르는 ffmpeg 를 제거 하자
sudo apt remove ffmpeg


git 설치
sudo apt install git build-essential

h264 라이브러리 설치
git clone git://git.videolan.org/x264
cd x264
./configure --host=arm-unknown-linux-gnueabi --enable-static --disable-opencl
make -j4
sudo make install

ffmpeg 설치
sudo git clone https://github.com/FFmpeg/FFmpeg.git
cd FFmpeg
./configure --arch=armel --target-os=linux --enable-gpl --enable-omx --enable-omx-rpi --enable-nonfree --enable-mmal
make -j4
sudo make install

시간이 엄청나게 걸린다..
그리고 cpu 온도 80도 넘어가니 주의 할것 ㅎㅎ

이제 라즈베리파이에서 h264_mmal / h264_omx 사용가능

그러면 teheadend 에서 트랜스코딩 가능

프로파일에 있는 트렌스코딩이 아니라 우선 코딩해서 넘기는 방식

사용법은

vim transcoding.sh

#!/bin/sh
ffmpeg -c:v h264_mmal -i $1 -c:v h264_omx -preset ultrafast -f mpegts pipe:1

파일하나 만들고

m3u파일에
pipe:///home/pi/transcoding.sh rtp://xxx.xxx.xxx.xxx:5000

이런식으로 사용
라즈베리파이로도 tvheadend 트랜스 코딩이 가능!

동시 시청 2~3대 까지는 가능하다.
^^v

-- 추가 --
약간 쾌적하게 트랜스코딩 하는 방법 추가 했습니다.
https://nbspcrop.blogspot.com/2019/04/blog-post.html

댓글

  1. 혹시 rtp가 아니고 udp면 사용이 안되는건가요? 알려주신대로 셋팅을 다 했는데
    mux idle에서 모두 fail이 뜨네요...

    답글삭제
  2. 제 생각엔 가능할 것 같은데요.. fail이 뜨신다니.. 이상하네요..

    답글삭제
    답글
    1. ffmpeg 설치할 때
      ./configure --arch=armel --target-os=linux --enable-gpl --enable-omx --enable-omx-rpi --enable-nonfree --enable-mmal

      에서

      ./configure: 4063: ./configure: cannot create ffbuild/config.log: Permission denied
      ./configure: 4064: ./configure: cannot create ffbuild/config.log: Permission denied


      오류가 나서 root권한으로 그 이후로 계속해서 설치했구요.

      알려주신 방법대로하면 끝까지하면

      spawn: /home/pi/transcoding.sh: 2: /home/pi/transcoding.sh: ffmpeg: not found

      이렇게 tvheadend에서 오류가 뜹니다.

      ffmpeg 설치시 문제가 생긴걸까요...

      삭제
  3. root 권한으로 그러니까 su 하시고 하신건가요? sudo 하신건가요? 경로가 /home/ 인데 su 하셨으면 /root/ 경로로 잡힌게 아닐까 싶은데요..
    ffmpeg가 설치가 안되었거나 경로상의 문제인듯 합니다.

    https://askubuntu.com/questions/699502/ffmpeg-command-not-found
    참고해보세요.

    답글삭제
  4. sudo를 하였지만
    /root/ 경로에는 따로 ffmpeg가 없습니다.
    pi@서버 상태에서는 ./transcoding.sh 를 하면


    ffmpeg version N-93397-gf8075b2c91 Copyright (c) 2000-2019 the FFmpeg developers
    built with gcc 6.3.0 (Raspbian 6.3.0-18+rpi1+deb9u1) 20170516
    configuration: --arch=armel --target-os=linux --enable-gpl --enable-omx --enable-omx-rpi --enable-nonfree --enable-mmal
    libavutil 56. 26.100 / 56. 26.100
    libavcodec 58. 47.103 / 58. 47.103
    libavformat 58. 26.101 / 58. 26.101
    libavdevice 58. 6.101 / 58. 6.101
    libavfilter 7. 48.100 / 7. 48.100
    libswscale 5. 4.100 / 5. 4.100
    libswresample 3. 4.100 / 3. 4.100
    libpostproc 55. 4.100 / 55. 4.100
    Output #0, mpegts, to 'pipe:1':
    Output file #0 does not contain any stream


    이렇게 작동이 되는데,

    tvheadend에 넣어서 하면 not found가 뜨네요. 댓글 감사합니다. 저 방법으로 시도해보겠습니다~

    답글삭제
  5. 성공했습니다. 감사합니다.
    sudo apt-get install ffmpeg 설치하고
    h264도
    sudo apt-get install x264로 설치했습니다.
    그리고 가장 중요한게 gpu 메모리 설정이었습니다. 최대로 설정해주니 작동하네요... 감사합니다~

    답글삭제
  6. 성공하셨다니 다행이네요~^^
    축하드려요!!

    답글삭제
  7. 은인이십니다. 나노파이-m4를 이용해서 omv 서버 구동중에 하드웨어인코딩을 반드시 해야만 했었는데 큰도움이 되었습니다.

    답글삭제
  8. 감사합니다^^ 도움이되셨다니 다행이네요

    답글삭제

댓글 쓰기

이 블로그의 인기 게시물

MTConnect 로 fanuc 의 facus 이용하기

참으로.. 국내 자료는 거의 없다.. 삽질에 삽질에 살집에... 거의 2주 넘게 삽질의 연속.. 먼저 1. cnc 에 facas 설정 2. cnc에 컴퓨터 하나 lan으로 연결해주고 mtconnect adapter 설치 3. 서버용으로 컴터 하나 맞춘후 mtconnect agent 설치 대략 30대 adapter 동시에 돌려보니 서버(agent)에 cpu 사용률 2% 안쪽.. 자세한 정보는 담지 않았지만 나중에 시간되면 자세하게 다루자.. 지원 가능 모델 0i, 32i, 21i 등등.. 거의 모든 i모델은 다되는듯.. cnc, mct 등..

라즈베리파이 키오스크 모드(Kiosk mode)

부팅시 화면 회전 sudo vi /boot/config.txt add display_rotate=3 ( 이와 같이 작성하면 화면이 시계 방향으로 90도 회전 ) 터치스크린까지 바꿀려면.. add lcd_rotate=3 disable_overscan=1 overscan_left=-150 overscan_right=-150 부팅 로그 감추기 sudo vi /boot/cmdline.txt 부팅 이미지 표시하기 sudo apt-get install fbi vi asplashscreen 아래 do_start 부분에서 이미지 경로를 원하는 이미지로 변경한다. #! /bin/sh ### BEGIN INIT INFO # Provides:          asplashscreen # Required-Start: # Required-Stop: # Should-Start:      # Default-Start:     S # Default-Stop: # Short-Description: Show custom splashscreen # Description:       Show custom splashscreen ### END INIT INFO do_start () {     /usr/bin/fbi -T 1 -noverbose -a /etc/sample.png        exit 0 } case "$1" in   start|"")     do_start     ;;   restart|reload|force-reload)     echo "Error: argument '$1' not supported" >&2     exit 3     ;;   stop)     # No-op     ;;   status)     exit 0     ;;   *)     echo "Usage: asplashscreen [sta

라즈베리파이 조금더 쾌적한 트랜스코딩방법..

- ffmpeg 다운로드 $ git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg $ cd ffmpeg $ mkdir dependencies $ cd dependencies/ $ mkdir output - ffmpeg 컴파일 $ git clone http://git.videolan.org/git/x264.git $ cd x264/ $ ./configure --enable-static --prefix=/home/pi/ffmpeg/dependencies/output/ $ make -j4 (컴파일 문제 혹은 코어4개 사용 안할땐 make -j) $ make install $ cd .. -  ALSA 다운로드 $ wget ftp://ftp.alsa-project.org/pub/lib/alsa-lib-1.1.1.tar.bz2 -  ALSA 컴파일 $ tar xjf alsa-lib-1.1.1.tar.bz2 $ cd alsa-lib-1.1.1/ $ ./configure --prefix=/home/pi/ffmpeg/dependencies/output $ make -j4 $ make install $ cd .. - FDK-AAC 다운로드 $ sudo apt-get install pkg-config autoconf automake libtool $ git clone https://github.com/mstorsjo/fdk-aac.git - FDK-AAC 컴파일 $ cd fdk-aac $ ./autogen.sh $ ./configure --enable-shared --enable-static $ make -j4 $ sudo make install $ sudo ldconfig $ cd .. - OMX_core.h 설치 sudo apt-get install libomxil-bellagio-dev - FFMPEG 컴파일 $ cd .. $ ./configure --pref