Tiny Core Linux

Tiny Core Base => Raspberry Pi => Topic started by: RockJamm on June 01, 2020, 11:52:46 AM

Title: Raspicam on Picore 11betab
Post by: RockJamm on June 01, 2020, 11:52:46 AM
Hi,

Very recent convert to PiCore here hoping to get the standard raspberry pi camera stuff working for monitoring of wildlife.  I notice ffmpeg is already so that's an excellent start.  :D
I appreciate this may not be very high on anyone else's list of priorities however I am prepared to do some learning and put in some time (however I do have a job and a family so that's not endless).

I'm pretty sure there is no extension (think that's the correct term - please correct me if not) currently existing for this and I'm wondering whether there is a process documented anywhere for getting something available in, let's say, Raspbian and modifying it so that it works in PiCore?

I have a programming background and some experience of Linux.  Any suggestions as to where I should start?  If this is a sensible way to go then I could contribute other extensions too I guess.
Title: Re: Raspicam on Picore 11betab
Post by: Paul_123 on June 01, 2020, 12:06:17 PM
Camera stuff should be in the rpi-vc.tcz extension.

Which I see is not currently in the 11.x extension.   You can get it from the 10.x repo until someone copies it over.

There is alot of info in the FAQ's and wiki's on how things are handled.   Most extensions are compiled from source.   The rpi-vc is not, it is just copied from the rpi firmware github and packaged.
Title: Re: Raspicam on Picore 11betab
Post by: Juanito on June 01, 2020, 02:00:03 PM
Is it still the case that rpi-vc is required - I thought I'd read that with the latest mesa and full kms, it was no longer required - or am I mixing two different things?

As a side issue libEGL.so, libGLESv2.so and libGLESv1_CM.so are duplicated in other extensions.
Title: Re: Raspicam on Picore 11betab
Post by: Paul_123 on June 01, 2020, 02:15:15 PM
perhaps the graphics side handled elsewhere, but the camera support needs separate binaries.   And there are other things in there too,   vcgencmd, tvservice,.......

Perhaps we need to separate rpi-vc a bit further.

Title: Re: Raspicam on Picore 11betab
Post by: RockJamm on June 02, 2020, 02:59:24 AM
Many thanks I'll investigate today and see where I get to.  Really appreciate your thoughts.
Title: Re: Raspicam on Picore 11betab
Post by: Juanito on June 02, 2020, 06:30:13 AM
I did some testing without the rpi-vc extension.

The v4l-dvb-KERNEL extension was missing some modules, which have now been added.

First add a couple of lines to /mnt/mmcblk0p1/config.txt such that:
Code: [Select]
$ cat /mnt/mmcblk0p1/config.txt
...
[ALL]
# Enable camera
start_x=1
gpu_mem=128
..and reboot

Then load the required extensions:
Code: [Select]
$ tce-load -i libv4l2
$ sudo modprobe bcm2835-unicam

To take a photo:
Code: [Select]
$ v4l2-ctl --overlay=1 [enable viewfinder]
$ v4l2-ctl --set-fmt-video=width=2592,height=1944,pixelformat=3
$ v4l2-ctl --stream-mmap=3 --stream-count=1 --stream-to=photo.jpg

To record a video:
Code: [Select]
$ v4l2-ctl --overlay=1 [enable viewfinder]
$ v4l2-ctl --set-fmt-video=width=1920,height=1088,pixelformat=4
$ v4l2-ctl --stream-mmap=3 --stream-count=100 --stream-to=video.264
..adjust stream count for a longer video
Title: Re: Raspicam on Picore 11betab
Post by: Juanito on June 02, 2020, 07:27:00 AM
rpi-vc copied to the piCore-11.x repos - things seem to work, but care will need to be taken to avoid a clash with libEGL and friends.
Title: Re: Raspicam on Picore 11betab
Post by: RockJamm on June 02, 2020, 07:36:00 AM
FANTASTIC!  many thanks
Title: Re: Raspicam on Picore 11betab
Post by: Paul_123 on June 02, 2020, 08:26:05 AM
Couple of interesting posts about the camera that I've not seen.....

https://www.raspberrypi.org/blog/an-open-source-camera-stack-for-raspberry-pi-using-libcamera/

And a FAQ to go with it.   https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=273018

Note that currently the piCore11 is using the 4.19 kernel tree, so libcamera is not going to work, but I think the data paths with respect to v4l2 are similar.   raspivid and raspistill are still going to be around.
Title: Re: Raspicam on Picore 11betab
Post by: RockJamm on June 03, 2020, 03:58:04 AM
The libcamera stuff is very interesting thanks Paul.  I'm having a bit of trouble getting things working but I think that's more to do with me not having got my head around persistence of the config.txt that anything else.  When i've worked it out I'll feed back.   
Title: Re: Raspicam on Picore 11betab
Post by: Juanito on June 03, 2020, 04:01:35 AM
Video motion detection extension, motion, added to the repo - tested with an RPi3 and RPi camera using the default (v4l2) motion conf files  8)

Note that motion would not compile against rpi-vc mmal - it looks like it needs an update?

Title: Re: Raspicam on Picore 11betab
Post by: RockJamm on June 03, 2020, 05:58:26 AM
Once I'd worked out I had to mount mmcblk0p1 in order to edit config.txt camera works fine!  Many thanks all.  Really pleased.  What a great project this is! :)
Title: Re: Raspicam on Picore 11betab
Post by: RockJamm on June 03, 2020, 12:42:06 PM
Looks like vlc isn't available at the moment - is that likely to be added to the repository?  Having investigated a bit further it looks like that is more helpful to me than FFmpeg and V4L2 (or raspivid) | vlc is likely to be the way i go.
Title: Re: Raspicam on Picore 11betab
Post by: Paul_123 on June 03, 2020, 12:45:34 PM
Note that motion would not compile against rpi-vc mmal - it looks like it needs an update?

mmal looks like it has had 2 updates since the Rpi4 launch.   I'll update the package tonight.
Title: Re: Raspicam on Picore 11betab
Post by: Juanito on June 03, 2020, 01:43:37 PM
What does vlc provide that the others don't?
Title: Re: Raspicam on Picore 11betab
Post by: RockJamm on June 03, 2020, 02:58:32 PM
I believe it does as a means of creating an rstp stream accessible by a client.  If FFmpeg can do it I've not been able to establish how - could be my failing! :-)

I'm thinking Raspivid (or v4l) piped to vlc (which will act as server as well as converting)
Title: Re: Raspicam on Picore 11betab
Post by: RockJamm on June 03, 2020, 06:37:15 PM
Looks like I can use FFMPEG after all.  Apparently something like this should work (I'll give it a go tomorrow).

ffmpeg -f flv -listen 1 -i rtmp://localhost:8889/live/app -c copy -f flv -listen 1 rtmp://localhost:1935/live/app

if so then no need for vlc.

Thanks again!
Title: Re: Raspicam on Picore 11betab
Post by: DrRob on August 05, 2020, 07:25:03 AM
Video motion detection extension, motion, added to the repo...

What's that called in the repo, please?  I can't see "motion" here: http://ftp.nluug.nl/os/Linux/distr/tinycorelinux/11.x/armv6/ for example.

Thanks,
Rob.
Title: Re: Raspicam on Picore 11betab
Post by: Juanito on August 05, 2020, 07:47:36 AM
It's here: http://tinycorelinux.net/11.x/armv7/tcz/motion.tcz.list

I think I didn't put it in the armv6 repo as motion depends on libavcodec, which depends on x265, which does not compile for armv6.
Title: Re: Raspicam on Picore 11betab
Post by: DrRob on August 05, 2020, 08:54:23 AM
I think I didn't put it in the armv6 repo as motion depends on libavcodec, which depends on x265, which does not compile for armv6.

Ah, ok, fair enough, thanks.