Difference between revisions of "Video"

From HiveTool
Jump to: navigation, search
(Pi Cam)
(HiveTool Image 0.8.4)
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
==Introduction==
+
==Uses==
 +
 
 +
*Visually monitor the bees
 +
*Measure of hive activity
 +
*Visual Bee Counter
 +
 
 +
==Streaming Encoded Video==
  
 
Most cameras will output "raw video" but special media players may be needed to view it. For streaming, video is encoded into a format like mpeg or h.264 and wrapped in a container like avi, swf, or mp4.  The container may include other streams (eg audio, captioning, subtitles) Encoding includes compression so the video doesn't consume huge amounts of bandwidth or disk space.  Encoding the video can consume considerable processing power (40 to 100% CPU utilization).  Underpowered machines are limited to low frame rates (5 fps) and resolutions (320x240) resulting in slow, jerky video.  The Pi's core has encoder hardware but enabling it requires payment of a licensing fee.
 
Most cameras will output "raw video" but special media players may be needed to view it. For streaming, video is encoded into a format like mpeg or h.264 and wrapped in a container like avi, swf, or mp4.  The container may include other streams (eg audio, captioning, subtitles) Encoding includes compression so the video doesn't consume huge amounts of bandwidth or disk space.  Encoding the video can consume considerable processing power (40 to 100% CPU utilization).  Underpowered machines are limited to low frame rates (5 fps) and resolutions (320x240) resulting in slow, jerky video.  The Pi's core has encoder hardware but enabling it requires payment of a licensing fee.
Line 6: Line 12:
  
 
==Pi Cam==
 
==Pi Cam==
 +
===HiveTool Image 0.8.4===
 +
The RPi-Cam-Web-Interface is installed on Image 0.8.4.  This software only works with the Raspberry Pi cameras, and WILL NOT WORK WITH USB cameras. USB cameras can still be streamed using methods described below.
 +
 +
To start streaming, simply plug in a Raspberry Pi camera or clone and enable the camera in the Pi setup.
 +
 +
RPi-Cam-Web-Interface has many features: time lapse, scheduled recording, motion detection, video controls such as brightness, contrast, white balance, frame rate, image size, bit rate, etc.  Please see the [https://elinux.org/RPi-Cam-Web-Interface#Usage RPi-Cam-Web-Interface website] for detailed instructions.
  
 +
===HiveTool Image 0.7.3===
 
The hivetool image ver 0.73 is set to stream raw video from the Pi Cam using raspivid and cvlc.  Raspivid uses the GPU so CPU utilization is very low.
 
The hivetool image ver 0.73 is set to stream raw video from the Pi Cam using raspivid and cvlc.  Raspivid uses the GPU so CPU utilization is very low.
  
Line 14: Line 27:
 
  /home/hivetool/stream_video.sh
 
  /home/hivetool/stream_video.sh
  
To start streaming automatically after boot, remove the comment from the line in /etc/rc.local that calls stream_video.shn so it looks like this:
+
To start streaming automatically after boot, remove the comment from the line in /etc/rc.local that calls stream_video.sh so it looks like this:
  
 
  # start video stream
 
  # start video stream

Latest revision as of 05:39, 14 February 2020

Uses

  • Visually monitor the bees
  • Measure of hive activity
  • Visual Bee Counter

Streaming Encoded Video

Most cameras will output "raw video" but special media players may be needed to view it. For streaming, video is encoded into a format like mpeg or h.264 and wrapped in a container like avi, swf, or mp4. The container may include other streams (eg audio, captioning, subtitles) Encoding includes compression so the video doesn't consume huge amounts of bandwidth or disk space. Encoding the video can consume considerable processing power (40 to 100% CPU utilization). Underpowered machines are limited to low frame rates (5 fps) and resolutions (320x240) resulting in slow, jerky video. The Pi's core has encoder hardware but enabling it requires payment of a licensing fee.

Some cameras have hardware encoders built into the camera and in addition to raw video, can also stream encoded video. The Logitech HD920 has mpeg and h.264 encoders. If the camera will stream encoded video, essentially all the computer has to do is copy the video stream from the camera to the network interface which results in 2 to 5% CPU utilization.

Pi Cam

HiveTool Image 0.8.4

The RPi-Cam-Web-Interface is installed on Image 0.8.4. This software only works with the Raspberry Pi cameras, and WILL NOT WORK WITH USB cameras. USB cameras can still be streamed using methods described below.

To start streaming, simply plug in a Raspberry Pi camera or clone and enable the camera in the Pi setup.

RPi-Cam-Web-Interface has many features: time lapse, scheduled recording, motion detection, video controls such as brightness, contrast, white balance, frame rate, image size, bit rate, etc. Please see the RPi-Cam-Web-Interface website for detailed instructions.

HiveTool Image 0.7.3

The hivetool image ver 0.73 is set to stream raw video from the Pi Cam using raspivid and cvlc. Raspivid uses the GPU so CPU utilization is very low.

  1. Enable Camera in raspi-config
  2. Run
/home/hivetool/stream_video.sh

To start streaming automatically after boot, remove the comment from the line in /etc/rc.local that calls stream_video.sh so it looks like this:

# start video stream
su pi /home/hivetool/stream_video.sh

To view the stream, run VLC media player and open media stream from the hive ip port 8554 using real time streaming protocol like:

rtsp://192.168.1.1:8554
rtsp://localhost:8554

Note that VLC Media Player running on another computer can be used to encode and re-stream the video.

/home/hivetool/stream_video.sh consists of piping the output of raspivid to cvlc:

/usr/bin/raspivid -n -o - -t 0 -w 800 -h 400 -fps 24 |sudo -H -u pi /usr/bin/cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554}' :demux=h264

USB Web Cam

Display camera modes

Video4Linux can be used to find out what formats the camera supports and to control the camera.

To install Video4Linux on the Pi:

apt-get install v4l-utils v4l-conf

To display the video formats the camera supports:

v4l2-ctl --list-formats

If the camera is fixed, auto focus can be turned off and the camera focused manually.

To turn auto focus off and manually set the focus:

/usr/bin/v4l2-ctl --verbose --set-ctrl=focus_auto=0
/usr/bin/v4l2-ctl -d 0 -c focus_absolute=25


Install ffmpeg on the Pi

These instructions are old and probably out of date.

FFmpeg is one program to encode or copy video and/or audio streams.

1. Install h.264 library libx264 if h.264 encoding will be used.

git clone git://git.videolan.org/x264.git
cd x264
./configure --enable-static --enable-shared *See Note 1 below.
make
make install
ldconfig

2. Install ffmpeg

git clone git://source.ffmpeg.org/ffmpeg.git
cd ffmpeg
./configure --enable-gpl --enable-libx264  --enable-libfreetype *See Note 2
make
make install
ldconfig

NOTES:
1. Disable the assembler when compiling on the Pi[1]:

./configure --disable-asm --enable-shared

2. Disable mmx when compiling on the Pi

./configure --enable-shared --enable-gpl  --enable-libx264   --enable-libfreetype --disable-mmx

Configure ffserver

ffmpeg