Difference between revisions of "PineCube"

Jump to navigation Jump to search
(→‎Armbian: add iperf3 tests: with and without WireGuard)
(→‎Armbian: Add example gstreamer pipeline and simple http web server with python3 to stream HLS)
Line 197: Line 197:
  [  5]  0.00-60.14  sec  246 MBytes  34.3 Mbits/sec    7            sender
  [  5]  0.00-60.14  sec  246 MBytes  34.3 Mbits/sec    7            sender
  [  5]  0.00-60.00  sec  245 MBytes  34.2 Mbits/sec                  receiver
  [  5]  0.00-60.00  sec  245 MBytes  34.2 Mbits/sec                  receiver
==== Streaming the camera to the network ====
To stream to web browsers with HLS and x264 encoding, we'll use a tmpfs file system to not write any data to the sdcard in the PineCube. We'll also need a very basic web page in tmpfs, a program to write HLS data to the tmpfs, and finally a webserver to serve the files.
Create the hls directory to be shared in the existing tmpfs file system that is mounted at /dev/shm:
<code>mkdir /dev/shm/hls/</code>
Create an index.html and optionally a favicon.ico or even a set of icons, and then put the files into the /dev/shm/hls directory. An example index.html that works is available in the Getting Started section of the [https://github.com/video-dev/hls.js/#getting-started README] for [https://github.com/video-dev/hls.js/ hls.js].
In one terminal, run the camera capture pipeline:
cd /dev/shm/hls/ &&
media-ctl --set-v4l2 '"ov5640 1-003c":0[fmt:UYVY8_2X8/240x320@1/15]' &&
gst-launch-1.0 v4l2src ! video/x-raw,width=320,height=240,format=UYVY,framerate=1/1 ! decodebin ! videoconvert ! video/x-raw,format=I420 ! clockoverlay ! timeoverlay valignment=bottom ! x264enc speed-preset=ultrafast tune=zerolatency ! mpegtsmux ! hlssink target-duration=1 playlist-length=2 max-files=3
In another, run a simple single threaded webserver which will serve html, javascript, and HLS to web clients:
cd /dev/shm/hls/ && python3 -m http.server
It should be possible to view the HLS stream directly in a web browser by visiting [http://pinecube:8000/ http://pinecube:8000/] if pinecube is the correct hostname and the name correctly resolves.
It is also possible to view the HLS stream with VLC: <code>vlc http://pinecube:8000/playlist.m3u8</code>
===== Debugging camera issues with the gstreamer pipeline =====
If the camera does not appear to work, it is possible to change the <code>v4l2src</code> to <code>videotestsrc</code> and the gstreamer pipeline will produce a synthetic test image without using the camera hardware.
If the camera is only sensor noise lines over a black or white image, the camera may be in a broken state. When in that state, the following kernel messages were observed:
[ 1703.577304] alloc_contig_range: [46100, 464f5) PFNs busy
[ 1703.578570] alloc_contig_range: [46200, 465f5) PFNs busy
[ 1703.596924] alloc_contig_range: [46300, 466f5) PFNs busy
[ 1703.598060] alloc_contig_range: [46400, 467f5) PFNs busy
[ 1703.600480] alloc_contig_range: [46400, 468f5) PFNs busy
[ 1703.601654] alloc_contig_range: [46600, 469f5) PFNs busy
[ 1703.619165] alloc_contig_range: [46100, 464f5) PFNs busy
[ 1703.619528] alloc_contig_range: [46200, 465f5) PFNs busy
[ 1703.619857] alloc_contig_range: [46300, 466f5) PFNs busy
[ 1703.641156] alloc_contig_range: [46100, 464f5) PFNs busy

=== Stock Linux ===
=== Stock Linux ===