Skip to content

Encoding Raspberrypi Camera's Frames to H264 with LibAV and HWA of Raspberrypi

Notifications You must be signed in to change notification settings

EhsanVahab/Raspberrypi-LibAV-HWA-Encoder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

myimagetitle

Raspberrypi-LibAV-HWA-Encoder

Encoding Raspberrypi Cameras's Frame to H264 with LibAV and HWA of Raspberrypi

  1. install raspbian on your SD Card.
  2. install dependencies FFMPEG as following:
sudo sudo apt-get -y install \
    autoconf \
    automake \
    build-essential \
    cmake \
    doxygen \
    git \
    graphviz \
    imagemagick \
    libasound2-dev \
    libass-dev \
    libavcodec-dev \
    libavdevice-dev \
    libavfilter-dev \
    libavformat-dev \
    libavutil-dev \
    libdrm-dev \
    libfreetype6-dev \
    libgmp-dev \
    libmp3lame-dev \
    libopencore-amrnb-dev \
    libopencore-amrwb-dev \
    libopus-dev \
    librtmp-dev \
    libsdl2-dev \
    libsdl2-image-dev \
    libsdl2-mixer-dev \
    libsdl2-net-dev \
    libsdl2-ttf-dev \
    libsnappy-dev \
    libsoxr-dev \
    libssh-dev \
    libtool \
    libv4l-dev \
    libva-dev \
    libvdpau-dev \
    libvo-amrwbenc-dev \
    libvorbis-dev \
    libwebp-dev \
    libx264-dev \
    libx265-dev \
    libxcb-shape0-dev \
    libxcb-shm0-dev \
    libxcb-xfixes0-dev \
    libxcb1-dev \
    libxml2-dev \
    lzma-dev \
    meson \
    nasm \
    pkg-config \
    python3-dev \
    python3-pip \
    texinfo \
    wget \
    yasm \
    zlib1g-dev

To disable remove --enable-libkvazaar

git clone --depth 1 "https://github.com/ultravideo/kvazaar.git" 
     && ./autogen.sh \
     && ./configure \
     && make -j$(2) \
     && sudo make install

To disable, remove --enable-libzimg

wget https://github.com/sekrit-twc/zimg/archive/refs/tags/release-3.0.1.tar.gz
tar -xvzf release-3.0.1.tar.gz
cd zimg-release-3.0.1

    ./autogen.sh \
      && ./configure \
      && make -j$(2) \
      && sudo make install
  1. download and extract ffmpeg 4.3.1
  2. cp omx.c /yourpath/FFmpeg-n4.3.1/libavcodec/omx.c #pathing the ffmpeg bug to use HWA
  3. cd /yourpath/FFmpeg-n4.3.1 and run the following command:
./configure \
    --extra-cflags="-I/usr/local/include" \
    --extra-ldflags="-L/usr/local/lib" \
    --extra-libs="-lpthread -lm -latomic" \
    --arch=armel \
    --enable-gmp \
    --enable-gpl \
    --enable-libfreetype \
    --enable-avresample \
    --enable-libkvazaar \
    --enable-libmp3lame \
    --enable-libopencore-amrnb \
    --enable-libopencore-amrwb \
    --enable-libopus \
    --enable-librtmp \
    --enable-libsnappy \
    --enable-libsoxr \
    --enable-libvorbis \
    --enable-libv4l2 \
    --enable-libzimg \
    --enable-libwebp \
    --enable-libx264 \
    --enable-libx265 \
    --enable-libxml2 \
    --enable-mmal \
    --enable-nonfree \
    --enable-omx \
    --enable-omx-rpi \
    --enable-version3 \
    --target-os=linux \
    --enable-pthreads \
    --enable-openssl \
    --enable-shared \
    --enable-hardcoded-tables
  1. make && sudo make install
  2. sudo apt-get install libopencv-dev
  3. Install raspberrypi camera c++ library from following link https://github.com/cedricve/raspicam/
  4. git clone https://github.com/EhsanVahab/Raspberrypi-LibAV-HWA-Encoder.git
  5. cd Raspberrypi-LibAV-HWA-Encoder
  6. make
  7. ./Encoder

the file sample.h264 is ready to use

Raspberrypi 3b+ HWA Encoder Benchmark

Resolution Bit Rate CPU Usage Frame Rate
1280x960 100,000 ~21% 16
800x600 100,000 ~19% 36
640x480 100,000 ~18% 50
1280x960 200,000 ~24% 16
800x600 200,000 ~22% 36
640x480 200,000 ~20% 50

About

Encoding Raspberrypi Camera's Frames to H264 with LibAV and HWA of Raspberrypi

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published