mmal cam on Pi4b Ubuntu

438 views
Skip to first unread message

Edward Barker

unread,
Nov 21, 2020, 6:56:59 AM11/21/20
to motioneye
Hi,

I have a Pi4b running ubuntu with motioneye istalled (thanks StrbaseSSD). To test that I could connect to remote motioneye cams on Pi Zero W units.

Today I started fitting cameras direct to the Pi4B. The mmal camera physically fitted fine and a red light lit on the camera unit. When I try to add a camera in motioneye no camera is found (in the camera field of the new camera dialog it just says '(no camera) and there is an exclamation mark in red).

Before going any deeper I wondered whether it is possible for motioneye running on Pi ubuntu to address an mmal camera? There are I dare say missing drivers?
 
Edward

Edward Barker

unread,
Nov 21, 2020, 7:11:42 AM11/21/20
to motioneye

Kevin Shumaker

unread,
Nov 21, 2020, 7:13:41 AM11/21/20
to Edward Barker, motioneye
You probably did, but just to confirm, did you enable the CSI camera in raspi-config?

--
You received this message because you are subscribed to the Google Groups "motioneye" group.
To unsubscribe from this group and stop receiving emails from it, send an email to motioneye+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/motioneye/6e6c8319-1f17-4904-aff2-ace5f40c9a96n%40googlegroups.com.


--
Thanks

Kevin Shumaker


N38° 19' 56.52"
W85° 45' 8.56"

Semper Gumby
“Don't tell people how to do things. Tell them what to do and let them surprise you with their results.” - G.S. Patton, Gen. USA
Ethics are what we do when no one else is looking.
Quis custodiet ipsos custodes?
“There is no end to the good you can do if you don’t care who gets the credit.” - C Powell
You know we're sitting on four million pounds of fuel, one nuclear weapon and a thing that has 270,000 moving parts built by the lowest bidder. Makes you feel good, doesn't it?

Edward Barker

unread,
Nov 21, 2020, 8:30:20 AM11/21/20
to motioneye
I haven't run raspi-config. There doesn't seem to be a version of it for Pi4B - ubuntu 20.04

I'm presuming raspi-config just edits a config file? Any idea what change it makes to enable the mmal cam?

I followed the following from other postings but not obviously making progress (but my Pi4B is still doing all its other stuff so haven't broken it yet!).

>sudo bash -c "echo 'start_x=1' >> /boot/config.txt"
sudo bash -c "echo 'gpu_mem=128' >> /boot/config.txt"
sudo chmod +x /usr/bin/rpi-update
sudo rpi-update
<reboot>

sudo apt install cmake
cd userland
./buildme --aarch64
touch ~/.bash_aliases
echo -e 'PATH=$PATH:/opt/vc/bin\nexport PATH' >> ~/.bash_aliases
echo -e 'LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/vc/lib\nexport LD_LIBRARY_PATH' >> ~/.bash_aliases
source ~/.bashrc
sudo ldconfig

sudo echo 'SUBSYSTEM==\"vchiq\",GROUP=\"video\",MODE=\"0660\"' > /etc/udev/rules.d/10-vchiq-permissions.rules
(this failed permission denied?)
sudo usermod -a -G video ubuntu
(reboot)

========From suggestions for 16.04 on Pi3, then silly stab at changing repo name and then double checking raspi-config though I doubt it will work on ubi 20.04 anyway
>sudo add-apt-repository ppa:ubuntu-raspi2/ppa; sudo apt-get install libraspberrypi-bin libraspberrypi-dev

Optional PPA for Raspberry Pi 2/3 installations.
Press [ENTER] to continue or Ctrl-c to cancel adding it.

Get:2 http://ports.ubuntu.com/ubuntu-ports focal-updates InRelease [111 kB]
Get:3 http://ports.ubuntu.com/ubuntu-ports focal-backports InRelease [98.3 kB]
Get:4 http://ports.ubuntu.com/ubuntu-ports focal-security InRelease [107 kB]
Get:5 http://ports.ubuntu.com/ubuntu-ports focal-updates/main arm64 Packages [561 kB]
Get:6 http://ports.ubuntu.com/ubuntu-ports focal-updates/universe arm64 Packages [646 kB]
Ign:9 http://ppa.launchpad.net/ubuntu-raspi2/ppa/ubuntu focal InRelease        
  404  Not Found [IP: 91.189.95.83 80]
Err:11 http://ppa.launchpad.net/ubuntu-raspi2/ppa/ubuntu focal Release         
  404  Not Found [IP: 91.189.95.83 80]
Reading package lists... Done                                                  
E: The repository 'http://ppa.launchpad.net/kirillshkrogalev/ffmpeg-next/ubuntu focal Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'http://ppa.launchpad.net/ubuntu-raspi2/ppa/ubuntu focal Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package libraspberrypi-bin
E: Unable to locate package libraspberrypi-dev
ubuntu@ubuntu:~$ sudo add-apt-repository ppa:ubuntu-raspi4/ppa; sudo apt-get install libraspberrypi-bin libraspberrypi-dev
Cannot add PPA: 'ppa:~ubuntu-raspi4/ubuntu/ppa'.
ERROR: '~ubuntu-raspi4' user or team does not exist.
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package libraspberrypi-bin
E: Unable to locate package libraspberrypi-dev
ubuntu@ubuntu:~$ sudo raspi-config
sudo: raspi-config: command not found
ubuntu@ubuntu:~$ sudo apt install raspi-config
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package raspi-config

Kevin Shumaker

unread,
Nov 21, 2020, 9:28:22 AM11/21/20
to Edward Barker, motioneye

Edward Barker

unread,
Nov 21, 2020, 10:10:42 AM11/21/20
to motioneye
I hadn't but have now followed the alternate place to put `start_x=1 ` from that more up to date document. The example picamera snap app is ubuntu core specific so I couldn't try that which is a pity. No difference to motioneye though. This one could take a while...

Edward



Kevin Shumaker

unread,
Nov 21, 2020, 10:23:29 AM11/21/20
to Edward Barker, motioneye
Which ubuntu are you using?

Edward Barker

unread,
Nov 21, 2020, 10:42:49 AM11/21/20
to Kevin Shumaker, motioneye
20.04 lts - normal ubuntu but arm. The article was using 'core' which given the error I got seems to use a different set of snaps to mine which it described as 'stable'.

Edward

Kevin Shumaker

unread,
Nov 21, 2020, 10:44:10 AM11/21/20
to Edward Barker, motioneye
What is/was your source for 20.04 lts?

Kevin Shumaker

unread,
Nov 21, 2020, 10:45:19 AM11/21/20
to Edward Barker, motioneye
I'll build one here real quick (relatively) and figure it out.
I have 20.10 64 from RPi Foundation and will try it, too...

Edward Barker

unread,
Dec 26, 2020, 6:15:53 AM12/26/20
to motioneye
Hi Kevin,

All for the very best for the season to you. I have just had another look at this. The situation was that with your considerable help I managed to install Motioneye on top of Ubuntu 20.04 LTS (not CORE) on a Pi4B. I couldn't get it to recognise a locally plugged MMAL camera. I accepted defeat with that and the MMAL cam is on a Pi Zero now working in the usual way with MotionEyeOS. Today I tried to plug in a couple of USB cameras into the USB2 ports. They are just cheap webcams but detect and work fine as VL42 under MotionEyeOS on PI Zero. They seem to be detected by the OS and the relevant driver is listed in MotionEye's add camera dialog (unlike the more proprietary MMAL) but then all that is displayed is the grey camera with a line through it. I can add remote motioneye cameras from Pi Zeros and sort of succeeded adding an rtsp feed IP camera.

I'm starting to think I will be unable to connect MMAL or VL42 cams to this configuration which would be OK provided I know. Did you ever succeed?

Edward.

Kevin Shumaker

unread,
Dec 26, 2020, 11:29:06 AM12/26/20
to Edward Barker, motioneye

Edward Barker

unread,
Dec 28, 2020, 4:57:45 AM12/28/20
to motioneye
OK, I have connected a basic usb webcam to a Pi4B running ubuntu 20.04.
if I type, for instance:

ffmpeg -f video4linux2 -i /dev/video0 -vframes 1 test2.jpg

I can get a perfectly good test image test2.jpg but my difficulty is that I can't convince motioneye to recognise the camera. When I select V4L cams the dropdown box is populated OK with drivers found after plugging the usb cam in but when any of them are chosen the result is just a grey camera with line through it.

The cameras I tried last time are mostly used for other things now. I have ordered some more but the camera currently connected (not I think as standard as the ones I tried before) has the following diagnostics::

ubuntu@ubuntu:~$ v4l2-ctl --all
Driver Info:
Driver name      : uvcvideo
Card type        : HD camera : HD camera 
Bus info         : usb-0000:01:00.0-1.4
Driver version   : 5.4.73
Capabilities     : 0x84a00001
Video Capture
Metadata Capture
Streaming
Extended Pix Format
Device Capabilities
Device Caps      : 0x04200001
Video Capture
Streaming
Extended Pix Format
Media Driver Info:
Driver name      : uvcvideo
Model            : HD camera : HD camera 
Serial           : 
Bus info         : usb-0000:01:00.0-1.4
Media version    : 5.4.73
Hardware revision: 0x00000100 (256)
Driver version   : 5.4.73
Interface Info:
ID               : 0x03000002
Type             : V4L Video
Entity Info:
ID               : 0x00000001 (1)
Name             : HD camera : HD camera 
Function         : V4L2 I/O
Flags         : default
Pad 0x01000007   : 0: Sink
  Link 0x0200000d: from remote pad 0x100000a of entity 'Processing 2': Data, Enabled, Immutable
Priority: 2
Video input : 0 (Camera 1: ok)
Format Video Capture:
Width/Height      : 640/480
Pixel Format      : 'YUYV' (YUYV 4:2:2)
Field             : None
Bytes per Line    : 1280
Size Image        : 614400
Colorspace        : Default
Transfer Function : Default (maps to Rec. 709)
YCbCr/HSV Encoding: Default (maps to ITU-R 601)
Quantization      : Default (maps to Limited Range)
Flags             : 
Crop Capability Video Capture:
Bounds      : Left 0, Top 0, Width 640, Height 480
Default     : Left 0, Top 0, Width 640, Height 480
Pixel Aspect: 1/1
Selection Video Capture: crop_default, Left 0, Top 0, Width 640, Height 480, Flags: 
Selection Video Capture: crop_bounds, Left 0, Top 0, Width 640, Height 480, Flags: 
Streaming Parameters Video Capture:
Capabilities     : timeperframe
Frames per second: 30.000 (30/1)
Read buffers     : 0

Edward Barker

unread,
Jan 22, 2021, 8:33:35 AM1/22/21
to motioneye
This post is just to say where I ended up. I am running MotionEyeOS on seven Pi Zero W, each with an MMAL camera and a cheap USB webcam through USB. They work fantastically. I particularly like the web interface. The environment gets great performance out of these tiny computers.

I have a separate Pi 4B 4gb ram running ubuntu already working hard on various tasks. I wanted to use cameras directly connected to that. With Kevin's great help I managed to get MotionEye installed and running. I can connect to other MotionEye units or in some cases to ip cameras. To date I have not suceeded in connecting to MMAL or cheap webcams over the USB2 ports. Fair enough, MotionEye over Ubuntu ARM on a Pi is not mainstream!

I have succeeded using the ffmpeg install by MotionEye to grab continuous content which is what I was after. It does make me realise how much I miss the MotionEye interface on those cameras.

This is a script fragment running from cron that does the camera work. ffmpeg's segment capabilities would have been a tidier approach but this works. I might ultimately have suceeded in hacking some config files to run MotionEye directly but this does enough for me.

All best,

Edward

----------------------------------------------------------------------------- 
ed_today=$(date +%F)
ed_time=$(date +%H-%M-%S)
if [[ ! -d "/media/ed/snap/data/output/Camera2/${ed_today}" ]]
then
mkdir /media/ed/snap/data/output/Camera2/${ed_today}
fi
ffmpeg \
-f video4linux2 \
-t 1796 \
-i /dev/video2 \
-vf "fps=fps=4","transpose=2,transpose=2","drawtext=fontfile=/usr/share/fonts/dejavu/DejaVuSans-Bold.ttf: text='%{localtime}': x=(w-tw)/2: y=h-(2*lh): fontcolor=white" \
/media/ed/snap/data/output/Camera2/${ed_time}-leek.mp4
mv /media/ed/snap/data/output/Camera2/${ed_time}-leek.mp4 \
/media/ed/snap/data/output/Camera2/${ed_today}/${ed_time}-leek.mp4
----------------------------------------------------------------------------------------------------------------------------

Reply all
Reply to author
Forward
0 new messages