출처

Python 설치

bluesanta@Kubuntu:~$ sudo apt install python

Android NDK(C/C++) 다운로드, 압축 해제

bluesanta@Kubuntu:~$ wget https://dl.google.com/android/repository/android-ndk-r20b-linux-x86_64.zip
bluesanta@Kubuntu:~$ sudo mv android-ndk-r20b-linux-x86_64.zip /opt/
bluesanta@Kubuntu:~$ cd /opt/
bluesanta@Kubuntu:/opt$ sudo unzip android-ndk-r20b-linux-x86_64.zip

NDK 경로 path에 추가

bluesanta@Kubuntu:/opt$ echo 'export ANDROID_NDK_ROOT=/opt/android-ndk-r20b' | tee -a ~/.bashrc
bluesanta@Kubuntu:/opt$ echo 'export PATH=$PATH:$ANDROID_NDK_ROOT' | tee -a ~/.bashrc

.profile-ndk 파일 작성

bluesanta@Kubuntu:/opt$ vi ~/.profile_ndk

.profile-ndk 내용

export ANDROID_NDK_ROOT=/opt/android-ndk-r20b
export NDK_TOOLCHAIN_VERSION=4.8
export TOOLCHAIN=/opt/android-21-toolchain
 
export PATH=$TOOLCHAIN/bin:$PATH

.profile-ndk 실행 (NDK 빌드시 사용)

bluesanta@Kubuntu:/opt$ chmod a+x ~/.profile_ndk
bluesanta@Kubuntu:/opt$ source ~/.profile_ndk

toolchain 설치

bluesanta@Kubuntu:/opt$ sudo $ANDROID_NDK_ROOT/build/tools/make-standalone-toolchain.sh \
  --verbose \
  --install-dir=$TOOLCHAIN \
  --platform=android-21
HOST_OS=linux
HOST_EXE=
HOST_ARCH=x86_64
HOST_TAG=linux-x86_64
HOST_NUM_CPUS=4
BUILD_NUM_CPUS=8
Auto-config: --arch=arm
## COMMAND: python /opt/android-ndk-r20b/build/tools/make_standalone_toolchain.py --arch arm --api 21 --stl gnustl --install-dir=/opt/android-21-toolchain
WARNING:__main__:make_standalone_toolchain.py is no longer necessary. The
$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin directory contains target-specific scripts that perform
the same task. For example, instead of:
 
    $ python $NDK/build/tools/make_standalone_toolchain.py \
        --arch arm --api 21 --install-dir toolchain
    $ toolchain/bin/clang++ src.cpp
 
Instead use:
 
    $ $NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi21-clang++ src.cpp
 
Toolchain installed to /opt/android-21-toolchain.

toolchain 환경설정

bluesanta@Kubuntu:/opt$ echo 'export TOOLCHAIN=/opt/android-21-toolchain' | tee -a ~/.bashrc
bluesanta@Kubuntu:/opt$ echo 'export PATH=$TOOLCHAIN/bin:$PATH' | tee -a ~/.bashrc

예제

Android.mk

LOCAL_PATH := $(call my-dir)
 
include $(CLEAR_VARS)
 
LOCAL_MODULE    := hello-jni
LOCAL_SRC_FILES := hello-jni.c
 
include $(BUILD_SHARED_LIBRARY)

hello-jni.c

#include <string.h>
#include <jni.h>

JNIEXPORT jstring JNICALL
Java_com_example_hellojni_HelloJni_stringFromJNI( JNIEnv* env,
                                                  jobject thiz )
{
#if defined(__arm__)
    #if defined(__ARM_ARCH_7A__)
    #if defined(__ARM_NEON__)
      #if defined(__ARM_PCS_VFP)
        #define ABI "armeabi-v7a/NEON (hard-float)"
      #else
        #define ABI "armeabi-v7a/NEON"
      #endif
    #else
      #if defined(__ARM_PCS_VFP)
        #define ABI "armeabi-v7a (hard-float)"
      #else
        #define ABI "armeabi-v7a"
      #endif
    #endif
  #else
   #define ABI "armeabi"
  #endif
#elif defined(__i386__)
#define ABI "x86"
#elif defined(__x86_64__)
#define ABI "x86_64"
#elif defined(__mips64)  /* mips64el-* toolchain defines __mips__ too */
#define ABI "mips64"
#elif defined(__mips__)
#define ABI "mips"
#elif defined(__aarch64__)
#define ABI "arm64-v8a"
#else
#define ABI "unknown"
#endif

    return (*env)->NewStringUTF(env, "Hello from JNI !  Compiled with ABI " ABI ".");
}

컴파일

bluesanta@Kubuntu:/bluesanta/workspace.cmx/hello_ndk$ ndk-build NDK_PROJECT_PATH=`pwd` APP_BUILD_SCRIPT=Android.mk
Android NDK: APP_PLATFORM not set. Defaulting to minimum supported version android-16.    
[arm64-v8a] Compile        : hello-jni <= hello-jni.c
[arm64-v8a] SharedLibrary  : libhello-jni.so
[arm64-v8a] Install        : libhello-jni.so => libs/arm64-v8a/libhello-jni.so
[armeabi-v7a] Compile thumb  : hello-jni <= hello-jni.c
[armeabi-v7a] SharedLibrary  : libhello-jni.so
[armeabi-v7a] Install        : libhello-jni.so => libs/armeabi-v7a/libhello-jni.so
[x86] Compile        : hello-jni <= hello-jni.c
[x86] SharedLibrary  : libhello-jni.so
[x86] Install        : libhello-jni.so => libs/x86/libhello-jni.so
[x86_64] Compile        : hello-jni <= hello-jni.c
[x86_64] SharedLibrary  : libhello-jni.so
[x86_64] Install        : libhello-jni.so => libs/x86_64/libhello-jni.so

Java 사용 예제

package com.example.hellojni;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;

public class HelloJni extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_hello_jni);
        TextView tv = (TextView)findViewById(R.id.hello_textview);
        tv.setText( stringFromJNI() );
    }
 
    public native String  stringFromJNI();

    public native String  unimplementedStringFromJNI();

    static {
        System.loadLibrary("hello-jni");
    }
}

댓글을 달아 주세요

Raspberry Pi : 원격 데스크톱(xrdp) 설치

OS/Raspberry Pi 2021. 3. 7. 01:37 Posted by 파란크리스마스

원격 데스크톱(xrdp) 설치

pi@raspberrypi:~$ sudo apt install xrdp

KDE 설치

KDE 데스크탑 설치

pi@raspberrypi:~$ sudo apt -y install task-kde-desktop

KDE로 원격 데스크탑 실행시 설정

pi@raspberrypi:~$ cat  ~/.xsession

댓글을 달아 주세요

Tinker Board 2 : FFmpeg 컴파일, 설치

OS/Tinker Board 2021. 3. 6. 01:36 Posted by 파란크리스마스

출처

기존에 설치되어 있는 ffmpeg 삭제, ffmpeg 컴파일 관련 패키지 설치

linaro@linaro-alip:~$ sudo apt-get remove ffmpeg x264 libav-tools libvpx-dev libx264-dev
linaro@linaro-alip:~$ sudo apt-get update
linaro@linaro-alip:~$ sudo apt-get -y install autoconf automake build-essential checkinstall git libass-dev \
   libgpac-dev libopencore-amrnb-dev libopencore-amrwb-dev libspeex-dev \
   libtheora-dev libtool libvorbis-dev pkg-config texi2html zlib1g-dev

yasm 소스 다운로드, 컴파일

linaro@linaro-alip:~$ mkdir ~/workspace.ffmpeg 
linaro@linaro-alip:~$ cd ~/workspace.ffmpeg 
linaro@linaro-alip:~/workspace.ffmpeg$ wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
linaro@linaro-alip:~/workspace.ffmpeg$ tar xvfz yasm-1.3.0.tar.gz
linaro@linaro-alip:~/workspace.ffmpeg$ cd yasm-1.3.0/
linaro@linaro-alip:~/workspace.ffmpeg/yasm-1.3.0$ ./configure
linaro@linaro-alip:~/workspace.ffmpeg/yasm-1.3.0$ grep -c processor /proc/cpuinfo
6
linaro@linaro-alip:~/workspace.ffmpeg/yasm-1.3.0$ make -j6
linaro@linaro-alip:~/workspace.ffmpeg/yasm-1.3.0$ sudo make install

lame 소스 다운로드, 컴파일

linaro@linaro-alip:~/workspace.ffmpeg/yasm-1.3.0$ cd ~/workspace.ffmpeg
linaro@linaro-alip:~/workspace.ffmpeg$ wget http://downloads.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz
linaro@linaro-alip:~/workspace.ffmpeg$ tar xzvf lame-3.100.tar.gz && cd lame-3.100
linaro@linaro-alip:~/workspace.ffmpeg/lame-3.100$ ./configure && make -j6
linaro@linaro-alip:~/workspace.ffmpeg/lame-3.100$ sudo make install

faac 소스 다운로드, 컴파일 (ffmpeg가 최신버전의 경우 불필요한 라이브러리)

linaro@linaro-alip:~/workspace.ffmpeg/lame-3.100$ cd ~/workspace.ffmpeg
linaro@linaro-alip:~/workspace.ffmpeg$ wget https://sourceforge.net/projects/faac/files/faac-src/faac-1.29/faac-1.29.9.2.tar.gz 
linaro@linaro-alip:~/workspace.ffmpeg$ tar xzvf faac-1.29.9.2.tar.gz && cd faac-1.29.9.2
linaro@linaro-alip:~/workspace.ffmpeg/faac-1.29.9.2$ ./configure && make -j6
linaro@linaro-alip:~/workspace.ffmpeg/faac-1.29.9.2$ sudo make install

fdk-aac 소스 다운로드, 컴파일

linaro@linaro-alip:~/workspace.ffmpeg/faac-1.29.9.2$ cd ~/workspace.ffmpeg
linaro@linaro-alip:~/workspace.ffmpeg$ git clone --depth 1 git://github.com/mstorsjo/fdk-aac.git
linaro@linaro-alip:~/workspace.ffmpeg$ cd fdk-aac/
linaro@linaro-alip:~/workspace.ffmpeg/fdk-aac$ autoreconf -fiv
linaro@linaro-alip:~/workspace.ffmpeg/fdk-aac$ ./configure --disable-shared
linaro@linaro-alip:~/workspace.ffmpeg/fdk-aac$ make -j6
linaro@linaro-alip:~/workspace.ffmpeg/fdk-aac$ sudo make install

H264 소스 다운로드, 컴파일

linaro@linaro-alip:~/workspace.ffmpeg/fdk-aac$ cd ~/workspace.ffmpeg
linaro@linaro-alip:~/workspace.ffmpeg$ git clone https://code.videolan.org/videolan/x264.git
linaro@linaro-alip:~/workspace.ffmpeg$ cd x264
linaro@linaro-alip:~/workspace.ffmpeg/x264$ ./configure --enable-static
linaro@linaro-alip:~/workspace.ffmpeg/x264$ make -j6
linaro@linaro-alip:~/workspace.ffmpeg/x264$ sudo make install

ffmpeg 소스 다운로드, 컴파일

linaro@linaro-alip:~/workspace.ffmpeg/x264$ cd ~/workspace.ffmpeg 
linaro@linaro-alip:~/workspace.ffmpeg$ git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg
linaro@linaro-alip:~/workspace.ffmpeg$ cd ffmpeg
linaro@linaro-alip:~/workspace.ffmpeg/ffmpeg$ git log
commit 77ce903f7ad2619fb3f420fd3e7f7b778dcb7704
Author: James Almer <jamrial@gmail.com>
Date:   Wed Mar 3 18:05:15 2021 -0300
linaro@linaro-alip:~/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" 
linaro@linaro-alip:~/workspace.ffmpeg/ffmpeg$ make -j6
linaro@linaro-alip:~/workspace.ffmpeg/ffmpeg$ sudo make install

ffmpeg 설치 버전 확인

linaro@linaro-alip:~/workspace.ffmpeg/ffmpeg$ ffmpeg -version
ffmpeg version N-101386-g77ce903f7a Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
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. 66.100 / 56. 66.100
libavcodec     58.128.100 / 58.128.100
libavformat    58. 70.100 / 58. 70.100
libavdevice    58. 12.100 / 58. 12.100
libavfilter     7.107.100 /  7.107.100
libswscale      5.  8.100 /  5.  8.100
libswresample   3.  8.100 /  3.  8.100
libpostproc    55.  8.100 / 55.  8.100

댓글을 달아 주세요

Tinker Board 2 : RASPBERRY PI CAMERA V2.1

OS/Tinker Board 2021. 3. 6. 01:21 Posted by 파란크리스마스

출처

Tinker Board 2 : Camera

카메라 모듈 확인

linaro@linaro-alip:~$ dmesg | grep video
[    1.147528] Linux video capture interface: v2.00
[    3.711002] usbcore: registered new interface driver uvcvideo

카메라 모듈 확인

linaro@linaro-alip:~$ v4l2-ctl -V
Format Video Capture Multiplanar:
        Width/Height      : 1920/1080
        Pixel Format      : 'YUYV'
        Field             : None
        Number of planes  : 1
        Flags             : 
        Colorspace        : Default
        Transfer Function : Default
        YCbCr Encoding    : Default
        Quantization      : Full Range
        Plane 0           :
           Bytes per Line : 3840
           Size Image     : 4147200

카메라 모듈 확인

linaro@linaro-alip:~$ media-ctl -p
Media controller API version 0.1.0
 
Media device information
------------------------
driver          rkisp1
model           rkisp1
serial          
bus info        
hw revision     0x0
driver version  0.0.0
 
Device topology
- entity 1: rkisp1-isp-subdev (4 pads, 6 links)
            type V4L2 subdev subtype Unknown flags 0
            device node name /dev/v4l-subdev0
        pad0: Sink
                [fmt:SRGGB10_1X10/1920x1080 field:none
                 crop.bounds:(0,0)/1920x1080
                 crop:(0,0)/1920x1080]
                <- "rkisp1_dmapath":0 []
                <- "rockchip-mipi-dphy-rx":1 [ENABLED]
        pad1: Sink
                <- "rkisp1-input-params":0 [ENABLED]
        pad2: Source
                [fmt:YUYV8_2X8/1920x1080 field:none
                 crop.bounds:(0,0)/1920x1080
                 crop:(0,0)/1920x1080]
                -> "rkisp1_selfpath":0 [ENABLED]
                -> "rkisp1_mainpath":0 [ENABLED]
        pad3: Source
                -> "rkisp1-statistics":0 [ENABLED]
 
- entity 2: rkisp1_mainpath (1 pad, 1 link)
            type Node subtype V4L flags 0
            device node name /dev/video0
        pad0: Sink
                <- "rkisp1-isp-subdev":2 [ENABLED]
 
- entity 3: rkisp1_selfpath (1 pad, 1 link)
            type Node subtype V4L flags 0
            device node name /dev/video1
        pad0: Sink
                <- "rkisp1-isp-subdev":2 [ENABLED]
 
- entity 4: rkisp1_dmapath (1 pad, 1 link)
            type Node subtype V4L flags 0
            device node name /dev/video2
        pad0: Source
                -> "rkisp1-isp-subdev":0 []
 
- entity 5: rkisp1-statistics (1 pad, 1 link)
            type Node subtype V4L flags 0
            device node name /dev/video3
        pad0: Sink
                <- "rkisp1-isp-subdev":3 [ENABLED]
 
- entity 6: rkisp1-input-params (1 pad, 1 link)
            type Node subtype V4L flags 0
            device node name /dev/video4
        pad0: Source
                -> "rkisp1-isp-subdev":1 [ENABLED]
 
- entity 7: rockchip-mipi-dphy-rx (2 pads, 2 links)
            type V4L2 subdev subtype Unknown flags 0
            device node name /dev/v4l-subdev1
        pad0: Sink
                [fmt:SRGGB10_1X10/1920x1080 field:none]
                <- "m00_b_imx219 1-0010":0 [ENABLED]
        pad1: Source
                [fmt:SRGGB10_1X10/1920x1080 field:none]
                -> "rkisp1-isp-subdev":0 [ENABLED]
 
- entity 8: m00_b_imx219 1-0010 (1 pad, 1 link)
            type V4L2 subdev subtype Sensor flags 0
            device node name /dev/v4l-subdev2
        pad0: Source
                [fmt:SRGGB10_1X10/1920x1080 field:none]
                -> "rockchip-mipi-dphy-rx":0 [ENABLED]

Image sensors at the i2c ports 1 & 2

linaro@linaro-alip:~$ ls -l /sys/class/video4linux/
total 0
lrwxrwxrwx 1 root root 0 Nov  3  2016 v4l-subdev0 -> ../../devices/platform/ff910000.rkisp1/video4linux/v4l-subdev0
lrwxrwxrwx 1 root root 0 Nov  3  2016 v4l-subdev1 -> ../../devices/platform/ff910000.rkisp1/video4linux/v4l-subdev1
lrwxrwxrwx 1 root root 0 Nov  3  2016 v4l-subdev2 -> ../../devices/platform/ff910000.rkisp1/video4linux/v4l-subdev2
lrwxrwxrwx 1 root root 0 Nov  3  2016 video0 -> ../../devices/platform/ff910000.rkisp1/video4linux/video0
lrwxrwxrwx 1 root root 0 Nov  3  2016 video1 -> ../../devices/platform/ff910000.rkisp1/video4linux/video1
lrwxrwxrwx 1 root root 0 Nov  3  2016 video2 -> ../../devices/platform/ff910000.rkisp1/video4linux/video2
lrwxrwxrwx 1 root root 0 Nov  3  2016 video3 -> ../../devices/platform/ff910000.rkisp1/video4linux/video3
lrwxrwxrwx 1 root root 0 Nov  3  2016 video4 -> ../../devices/platform/ff910000.rkisp1/video4linux/video4

테스트

linaro@linaro-alip:~$ gst-launch-1.0 v4l2src device=/dev/video1 num-buffers=100 ! video/x-raw,format=NV12,width=1920,height=1080,framerate=30/1 ! videoconvert ! rkximagesink

 

댓글을 달아 주세요

Tinker Board 2

OS/Tinker Board 2021. 3. 4. 00:35 Posted by 파란크리스마스

출처

ASUS Tinker Board 2

ASUS Tinker Board 2 스펙 ( 출처 : ASUS Tinker Board 2 : VIP@youyeetoo.com)

기본 사용자, 암호

linaro / linaro

리눅스 정보 확인

CPU 정보 확인

linaro@linaro-alip:~$ cat /proc/cpuinfo
processor       : 0
BogoMIPS        : 48.00
Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4
 
... 생략 ...
 
processor       : 5
BogoMIPS        : 48.00
Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd08
CPU revision    : 2
 
Serial          : 1adae4c508fdff72

instruction set architecture (ISA)

linaro@linaro-alip:~$ uname -m
aarch64

커널에 대한 정보

linaro@linaro-alip:~$ uname -a
Linux linaro-alip 4.4.194 #25 SMP Wed Jan 13 07:02:28 UTC 2021 aarch64 GNU/Linux

OS버전에 대한 정보

linaro@linaro-alip:~$ cat /etc/issue
Debian GNU/Linux 9 \n \l

리눅스 배포판 버전 확인

linaro@linaro-alip:~$ grep . /etc/*-release
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
VERSION_CODENAME=stretch
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

논리 코어 수 확인

linaro@linaro-alip:~$ grep -c processor /proc/cpuinfo
6

IP 확인

linaro@linaro-alip:~$ ip addr

Pythone 버전 확인

linaro@linaro-alip:~$ python --version
Python 2.7.13
linaro@linaro-alip:~$ python3 --version
Python 3.5.3

GPIO 확인

linaro@linaro-alip:~$ gpio readall
 +-----+-----+---------+------+---+--Tinker--+---+------+---------+-----+-----+
 | CPU | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | CPU |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 |     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |
 |  73 |   8 | GPIO2B1 |   IN | 1 |  3 || 4  |   |      | 5v      |     |     |
 |  74 |   9 | GPIO2B2 |   IN | 1 |  5 || 6  |   |      | 0v      |     |     |
 |   8 |   7 | CLKOUT2 |  CLK | 0 |  7 || 8  | 1 | IN   | GPIO2C1 | 15  | 81  |
 |     |     |      0v |      |   |  9 || 10 | 1 | IN   | GPIO2C0 | 16  | 80  |
 |  83 |   0 | GPIO2C3 |   IN | 1 | 11 || 12 | 0 | IN   | GPIO3D0 | 1   | 120 |
 |  85 |   2 | GPIO2C5 |   IN | 0 | 13 || 14 |   |      | 0v      |     |     |
 |  84 |   3 | GPIO2C4 |   IN | 0 | 15 || 16 | 0 | IN   | GPIO2C6 | 4   | 86  |
 |     |     |    3.3v |      |   | 17 || 18 | 0 | IN   | GPIO2C7 | 5   | 87  |
 |  40 |  12 | GPIO1B0 |   IN | 1 | 19 || 20 |   |      | 0v      |     |     |
 |  39 |  13 | GPIO1A7 |   IN | 1 | 21 || 22 | 0 | IN   | GPIO3D4 | 6   | 124 |
 |  41 |  14 | GPIO1B1 |   IN | 1 | 23 || 24 | 1 | IN   | GPIO1B2 | 10  | 42  |
 |     |     |      0v |      |   | 25 || 26 | 0 | IN   | GPIO0A6 | 11  | 6   |
 |  71 |  30 | GPIO2A7 |   IN | 1 | 27 || 28 | 1 | IN   | GPIO2B0 | 31  | 72  |
 | 126 |  21 | GPIO3D6 |   IN | 0 | 29 || 30 |   |      | 0v      |     |     |
 | 125 |  22 | GPIO3D5 |   IN | 0 | 31 || 32 | 0 | IN   | GPIO4C2 | 26  | 146 |
 | 150 |  23 | GPIO4C6 |  OUT | 1 | 33 || 34 |   |      | 0v      |     |     |
 | 121 |  24 | GPIO3D1 |   IN | 0 | 35 || 36 | 1 | IN   | GPIO2C2 | 27  | 82  |
 | 149 |  25 | GPIO4C5 |   IN | 0 | 37 || 38 | 0 | IN   | GPIO3D3 | 28  | 123 |
 |     |     |      0v |      |   | 39 || 40 | 0 | IN   | GPIO3D7 | 29  | 127 |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 | CPU | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | CPU |
 +-----+-----+---------+------+---+--Tinker--+---+------+---------+-----+-----+

댓글을 달아 주세요

NanoPi M4V2 : GStreamer HLS 스트리밍 서버 구축

OS/NanoPi 2021. 3. 1. 15:32 Posted by 파란크리스마스

출처

임시 디렉토리 생성

GStreamer HLS 관련 임시 파일 생성을 위한 디렉토리 생성합니다.

pi@NanoPi-M4v2:~$ mkdir hlstest

GStreamer 실행

playlist-root 옵션은 playlist.m3u8 파일 내 호출 주소를 전달 하기 위해서 외부 플레이어에서 접근 가능한 주소를 설정하고, location 옵션은 hls 관련 파일이 생성될 임시 작업 폴더를 지정합니다.

pi@NanoPi-M4v2:~$ gst-launch-1.0 rkisp device=/dev/video1 io-mode=4 ! video/x-raw,format=NV12,width=1280,height=720,framerate=30/1 \
  ! videoconvert ! clockoverlay ! x264enc tune=zerolatency ! mpegtsmux \
  ! hlssink playlist-root=http://192.168.0.5:8080 location=/home/pi/hlstest/segment_%05d.ts target-duration=5 max-files=5
Setting pipeline to PAUSED ...
media get entity by name: lens is null
XCAM ERROR v4l2_device.cpp:254: VIDIOC_QUERYCAP returned: -1 (Inappropriate ioctl for device)
XCAM ERROR v4l2_device.cpp:254: VIDIOC_QUERYCAP returned: -1 (Inappropriate ioctl for device)
XCAM ERROR rkisp_control_loop_impl.cpp:99: failed to get camera module info
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
XCAM ERROR rkisp_device.cpp:72: atomisp device(/dev/video1) try subdev format failed
Redistribute latency...
 
(gst-launch-1.0:2254): GStreamer-CRITICAL **: 09:06:59.673: gst_object_unref: assertion 'object != NULL' failed

윕서버 실행

HLS는 웹 스트리밍 프로토콜로 웹서버를 통해서 스트리밍 관련 파일을 전달하는데 GStreamer는 웹서버 기능이 없어서 python으로 웹서버를 이용하게 됩니다. 웹서비스 root 디렉토리로 이동하고 간이 웹서버를 실행합니다.

pi@NanoPi-M4v2:~$ cd hlstest/
pi@NanoPi-M4v2:~/hlstest$ python --version
Python 2.7.17
pi@NanoPi-M4v2:~/hlstest$ python -m SimpleHTTPServer 8080
Serving HTTP on 0.0.0.0 port 8080 ...

hls 주소

http://192.168.0.5:8080/playlist.m3u8

hls 재생

임시 디렉토리 목록 조회

pi@NanoPi-M4v2:~/hlstest$ ls 
playlist.m3u8 segment_00180.ts segment_00181.ts segment_00182.ts segment_00183.ts segment_00184.ts

댓글을 달아 주세요