[DOCKER] Let's capture the image of the IP camera to the OKI AI edge computer "AE2100"

* This article is for "AE2100 standard container image (without OpenVINO (Ubuntu version)) (file name: AE2100_StdContainer_Ubuntu_202009.zip)".

wrap up

Introduction

Recently, various AI-based apps have been developed, including recognizing vehicles and people from images. In this article, as a first step to importing video into an AI-powered app, we will use ffmpeg to save the video stream of the IP camera as a video file on the Ubuntu container of the AE2100.

In this article, I will explain in the following order.

environment

The execution environment assumes the configuration shown in the following figure.

図1.png

Connect your Windows PC to the LAN2 network and connect your camera to the LAN1 network. Please install TeraTerm on your Windows PC in advance. The IP camera can be used by other companies as long as it supports the ONVIF protocol, but here we will use the Honeywell IP camera HDZP252DI. (Please read the IP address etc. according to your environment.)

ffmpeg download

Download ffmpeg 4.3.1 on a PC connected to the internet. Click "32-bit and 64-bit for kernel 3.2.0 and above" at https://ffmpeg.org/download.html to move to the page.

・ FFmpeg (https://ffmpeg.org/) WEB page screenshot 図2.png

If "release: 4.3.1" is written as shown below, click "ffmpeg-release-amd64-static.tar.xz" to download. If it is not "release: 4.3.1", click "old releases" to go to the past download page and download "ffmpeg-4.3.1-amd64-static.tar.xz".

・ FFmpeg (https://ffmpeg.org/) WEB page screenshot 図3.png

AE2100 container settings

Build the ubuntu base container. Use the file "ae2100_base.tar.gz" that extracted "AE2100_StdContainer_Ubuntu_202009.zip". When executing the docker build command, execute it in the directory where the Dockerfile exists, and be careful not to leak the "." At the end of the command line.

# tar xvfz ae2100_base.tar.gz
ae2100_base/
…
(abridgement)
…
ae2100_base/Dockerfile

# cd ae2100_base
# docker build -t ubuntu:ae2100_base .
…
(abridgement)
…
Successfully built xxxxxxxxxxxx
Successfully tagged ubuntu:ae2100_base

# cd ../

Transfer the files needed to run ffmpeg to the AE2100 and unzip it. Transfer the previously downloaded ffmpeg 4.3.1 file to any directory on the AE2100. Execute the decompression command after the transfer is completed.

# tar Jxvf ffmpeg-release-amd64-static.tar.xz
ffmpeg-4.3.1-amd64-static/
ffmpeg-4.3.1-amd64-static/GPLv3.txt
…
(abridgement)

Create a Dockerfile to create an image file with ffmpeg added to the base container. Describe the following in the Dockerfile.

FROM ubuntu:ae2100_base
COPY ffmpeg-4.3.1-amd64-static/ /home/ffmpeg-4.3.1-amd64-static/

Create a container image file. When executing the docker build command, execute it in the directory where the Dockerfile exists, and be careful not to leak the "." At the end of the command line.

# docker build -t ubuntu:ae2100_ffmpeg .

Create and start ubuntu container.

# docker run -dit --name rtsp_test ubuntu:ae2100_ffmpeg /bin/bash

Camera settings

Make the following settings for the IP camera, and then connect the camera to LAN1.

IP address

Please log in via the camera's WEB-UI and set in "Network Settings> TCP/IP".

item Settings Remarks
mode static Select whether to use DHCP with the button
IP version IPv4
IP address 192.168.1.120
sub-net mask 255.255.255.0

Video settings

Please log in via the camera's WEB-UI and set in the mainstream of "Camera Settings> Video".

item Settings
Formatting H.264
Smart codec off
resolution 1920*1080(1080P)
frame rate(FPS) 30
Bit rate type VBR
quality 4
bit rate 4096
I frame interval 60
SVC 1(off)

run ffmpeg

Connect to the Terminal of the running container.

# docker exec -it rtsp_test /bin/bash

Connect to the camera with ffmpeg. After about 30 seconds have passed since the command was executed, press Ctr + C to end the command.

# /home/ffmpeg-4.3.1-amd64-static/ffmpeg -rtsp_transport tcp -i rtsp://user:[email protected]:554 output_honeywell.mp4
# /home/ffmpeg-4.3.1-amd64-static/ffmpeg -rtsp_transport udp -i rtsp://user:[email protected]:554 output_honeywell.mp4

You can confirm that the video stream is being received from the execution result. It also saves the camera video stream in the output_honeywell.mp4 file. For example, the following result will be displayed on the console. From the results below, you can see that the resolution is 1920x1080 and the frame rate is 30fps according to the camera settings.

Output #0, mp4, to 'output_honeywell.mp4':
  Metadata:
    title           : Media Server
    encoder         : Lavf58.28.101
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuvj420p(pc), 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 30 fps, 15360 tbn, 30 tbc
    Metadata:
      encoder         : Lavc58.53.101 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1

Use ffprobe on the video file to make sure you are saving the camera video stream as a normal video file. From the results below, you can see that the resolution is 1920x1080 and the frame rate is 30fps according to the camera settings.

# /home/ffmpeg-4.3.1-amd64-static/ffprobe output_honeywell.mp4
...
(abridgement)
...
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'output_honeywell.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    title           : Media Presentation
    encoder         : Lavf58.45.100
  Duration: 00:00:05.17, start: 0.000000, bitrate: 2994 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 2992 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)

Summary

This time, I used ffmpeg on the Ubuntu container of AE2100 and saved the video stream of the IP camera to a video file. You can import the video to any app by changing the option of ffmpeg. You can also combine ffmpeg with the application you created to utilize the camera image, so please try it.

Recommended Posts

Let's capture the image of the IP camera to the OKI AI edge computer "AE2100"
Let's run the OpenVINO sample program on the OKI AI edge computer "AE2100" Ubuntu container version (1)
Let's run the OpenVINO sample program on the OKI AI edge computer "AE2100" Ubuntu container version (3)
Let's run the OpenVINO sample program on the OKI AI edge computer "AE2100" Ubuntu container version (2)
Mandels to create an image of the Mandelbrot set
How to judge the click of any area of the image
Let's grasp the operation image (atmosphere) of the DI container of Spring
Let's summarize how to extend the expiration date of Rails