Skip to content

Commit

Permalink
Use libcamera instead of OpenMAX IL and MMAL
Browse files Browse the repository at this point in the history
  • Loading branch information
iizukanao committed Jul 7, 2022
1 parent c6e3601 commit b8e53c6
Show file tree
Hide file tree
Showing 76 changed files with 8,624 additions and 7,028 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*.out
*.app
picam
build/

*~
*.sw[po]
31 changes: 10 additions & 21 deletions BUILDING.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
# picam build instructions

This file explains how to build picam yourself. The whole process takes under an hour on Raspberry Pi 2 or 3. For Raspberry Pi 1 or Zero users, please do [cross compiling](CROSS_COMPILING.md) instead, because build process takes too long on those hardware.
This file explains how to build picam yourself. The whole process takes under an hour on Raspberry Pi 2 or 3.


# Steps

## Install required packages

```sh
$ sudo apt-get install git libasound2-dev libssl-dev libfontconfig1-dev libharfbuzz-dev
$ sudo apt-get install git cmake libcamera-dev libharfbuzz-dev libfontconfig-dev libasound-dev libdrm-dev libegl-dev libepoxy-dev libssl-dev liblzma-dev
```

(NOTE: `$` denotes command prompt. Do not enter `$` when entering commands.)


## Build and install fdk-aac

Download [fdk-aac-2.0.1.tar.gz](https://sourceforge.net/projects/opencore-amr/files/fdk-aac/) (or the latest version) and run the following commands.
Install [fdk-aac](https://sourceforge.net/projects/opencore-amr/files/fdk-aac/) with the following commands.

```sh
$ tar zxvf fdk-aac-2.0.1.tar.gz
$ cd fdk-aac-2.0.1
$ wget https://downloads.sourceforge.net/project/opencore-amr/fdk-aac/fdk-aac-2.0.2.tar.gz
$ tar zxvf fdk-aac-2.0.2.tar.gz
$ cd fdk-aac-2.0.2
$ ./configure
$ make -j4
(takes 3-4 minutes)
Expand All @@ -37,18 +38,11 @@ Download ffmpeg source and configure it:
```sh
$ git clone https://git.ffmpeg.org/ffmpeg.git
$ cd ffmpeg
# NOTE: for extra hw acceleration, include these flags in your ./configure below:
# --enable-mmal
# --enable-omx
# --enable-omx-rpi
$ ./configure --enable-libfdk-aac
(takes about one minute)
```

In the output of `configure`, make sure that:

- There is `alsa` in `Enabled indevs`
- There is `libfdk_aac` in `Enabled encoders`
In the output of `configure`, make sure that there is `libfdk_aac` in `Enabled encoders`.

Run the following commands to build and install ffmpeg.

Expand All @@ -65,19 +59,14 @@ $ sudo ldconfig
```


## Build libilclient

```sh
$ cd /opt/vc/src/hello_pi/libs/ilclient
$ make
```


## Build picam

```sh
$ git clone https://github.com/iizukanao/picam.git
$ cd picam
$ mkdir build
$ cd build
$ cmake ..
$ make -j4
```

Expand Down
37 changes: 37 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,43 @@
Change Log
==========

Version 2.0.0 *(2022-07-07)*
----------------------------

- Built with libcamera
- Stopped using legacy camera libraries (OpenMAX IL and MMAL).
- Added support for higher video resolutions up to 1920x1080 at 30 fps.
- Changed the default values for the following options:
+ `-w, --width` default is `1920` (previously `1280`)
+ `-h, --height` default is `1080` (previously `720`)
+ `-v, --videobitrate` default is `4500000` (previously `2000000`)
+ `--avcprofile` default is `baseline` (previously `constrained_baseline`)
+ `--avclevel` default is `4.1` (previously `3.1`)
- Added command line option `--hdmi` which selects HDMI port for video preview. Only works in console mode.
- Removed the following options due to technical limitations:
+ `--rotation` (For 180 degree rotation, use `--hflip --vflip` instead)
+ `--qpmin`
+ `--qpmax`
+ `--qpinit`
+ `--dquant`
+ `--aperture`
+ `--iso`
+ `--opacity`
+ `--blank`
+ `--mode`
- Changed the values for the following options. For the available values, please run `picam --help`.
+ `--ex`
+ `--wb`
+ `--metering`
- For NoIR camera users, `--wb greyworld` option is no longer available. Instead, pass `LIBCAMERA_RPI_TUNING_FILE` environment variable to picam like this: `LIBCAMERA_RPI_TUNING_FILE=/usr/share/libcamera/ipa/raspberrypi/ov5647_noir.json ./picam`

### Known issues

- There are some noise in audio preview (`--audiopreview` option) if video resolution is 1920x1080.
- If X Window System (desktop environment) is running, video fps will drop due to system load.
- EGL preview does not work on Raspberry Pi 3.
- Some problems may occur in the EGL preview.

Version 1.4.11 *(2021-04-29)*
-----------------------------

Expand Down
76 changes: 76 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
cmake_minimum_required(VERSION 3.6)

# set the project name
project(picam)

if (NOT EXISTS ${CMAKE_BINARY_DIR}/CMakeCache.txt)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
message(STATUS "No previous build - default to Release build")
endif()
endif()

set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")

set (CMAKE_EXPORT_COMPILE_COMMANDS ON)
set (CMAKE_CXX_STANDARD 17)
#add_compile_options(-Wall -Wextra -pedantic -Wno-unused-parameter -faligned-new -Werror -Wfatal-errors)
add_compile_options(-Wall -Wextra -pedantic -Wno-unused-parameter -Werror -Wfatal-errors)
add_definitions(-D_FILE_OFFSET_BITS=64)

if (CMAKE_COMPILER_IS_GNUCXX)
add_compile_options(-Wno-psabi)
endif()

option(BUILD_SHARED_LIBS "Build using shared libraries" ON)

IF (NOT ENABLE_COMPILE_FLAGS_FOR_TARGET)
# On a Pi this will give us armhf or arm64.
execute_process(COMMAND dpkg-architecture -qDEB_HOST_ARCH
OUTPUT_VARIABLE ENABLE_COMPILE_FLAGS_FOR_TARGET OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
message(STATUS "Platform: ${ENABLE_COMPILE_FLAGS_FOR_TARGET}")
if ("${ENABLE_COMPILE_FLAGS_FOR_TARGET}" STREQUAL "arm64")
# 64-bit binaries can be fully optimised.
add_definitions(-ftree-vectorize)
elseif ("${ENABLE_COMPILE_FLAGS_FOR_TARGET}" STREQUAL "armv8-neon")
# Only build with 32-bit Pi 3/4 specific optimisations if requested on the command line.
add_definitions(-mfpu=neon-fp-armv8 -ftree-vectorize)
endif()

# Source package generation setup.
set(CPACK_GENERATOR "TXZ")
set(CPACK_PACKAGE_FILE_NAME "libcamera-apps-build")
set(CPACK_SOURCE_GENERATOR "TXZ")
set(CPACK_INSTALL_SCRIPTS ${CMAKE_SOURCE_DIR}/package.cmake)
set(CPACK_SOURCE_PACKAGE_FILE_NAME "libcamera-apps-src")
set(CPACK_SOURCE_IGNORE_FILES "/\.git*;/build;")
include(CPack)

find_package(PkgConfig REQUIRED)

pkg_check_modules(LIBCAMERA REQUIRED libcamera)
message(STATUS "libcamera library found:")
message(STATUS " version: ${LIBCAMERA_VERSION}")
message(STATUS " libraries: ${LIBCAMERA_LINK_LIBRARIES}")
message(STATUS " include path: ${LIBCAMERA_INCLUDE_DIRS}")
include_directories(${CMAKE_SOURCE_DIR} ${LIBCAMERA_INCLUDE_DIRS} /usr/include/freetype2 /usr/include/harfbuzz /usr/include/fontconfig)

#add_subdirectory(core)
add_subdirectory(video_encoder)
add_subdirectory(preview)
add_subdirectory(text)
add_subdirectory(subtitle)
add_subdirectory(timestamp)
add_subdirectory(log)
add_subdirectory(httplivestreaming)
add_subdirectory(mpegts)
add_subdirectory(audio)
add_subdirectory(muxer)
add_subdirectory(libstate)
add_subdirectory(libhook)
add_subdirectory(picam_option)
add_subdirectory(libpicam)
#add_subdirectory(dispmanx)
add_subdirectory(rtsp)
Loading

0 comments on commit b8e53c6

Please sign in to comment.