matt2005 / RoadApplePi

An elegent "Black Box" solution that can be retrofitted into any car with an OBD(II) port for minimal cost.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No recordings

f321x opened this issue · comments

commented

The web interface works, it just won't record any footage.

The webcam itself won't activate either, the led's on it won't light up.
I can get the webcam to work by using VLC, so i know the webcam itself works. Both VLC and RoadApplePi are setup to use /dev/video0, so that in itself is correct.

I also can't seem to find any error logging, even though it mentions setting up syslog in raprec.c.

I did use matt2005's version, at that seems to be updated to work with raspbian buster.

If i run raprec.c using the terminal, i am getting some errors from v4l2, such as:

invalid v4l2 control type encountered
Unknown v4l2 mpeg control id

Altough that might be because the software itself is already running at this point.

I did try a different webcam, that didn't change anything.

Copied the issue from @theelichtje but have the exact same problem. Maybe here someone has a solution?

commented

I've solved by editing the "raprec.c" file.
first remove (or comment) lines 128 and 129 :

//system("uvcdynctrl -s 'Exposure, Auto' -- 3");
//system("uvcdynctrl -s 'Exposure, Auto Priority' -- 1");

then change line 163:

//execl("/usr/local/bin/ffmpeg", "ffmpeg", "-y", "-i", "/dev/video0", "-c:v", "h264_omx", "-b:v", "5M", fileStr, (char *)NULL);
execl("/usr/bin/ffmpeg", "ffmpeg", "-y", "-i", "/dev/video0", "-c:v", "libx264", "-b:v", "5M", fileStr, (char *)NULL);

then type in a terminal in the same folder of the file:

sudo systemctl stop raprec
sudo rm raprec
sudo rm raprun
sudo make && sudo make install
sudo systemctl restart raprec

and the recording will start.

With this setup i've found the video a bit laggy, so I've changed again line 163 with:

execl("/usr/bin/ffmpeg", "ffmpeg", "-y", "-f", "video4linux2", "-s", "1280x720", "-i", "/dev/video0", "-c:v", "libx264", "-preset", "ultrafast", "-tune", "zerolatency", "-b:v", "2M", fileStr, (char *)NULL);

With this setup it will record at 720p since is my webcam max resolution.

I end up using this, that also record the audio from the webcam mic (you might need to change the audio device):

execl("/usr/bin/ffmpeg", "ffmpeg", "-y", "-f", "video4linux2", "-s", "1280x720", "-i", "/dev/video0", "-thread_queue_size", "512", "-f", "alsa", "-ac", "1", "-i", "plughw:1,0", "-c:v", "libx264", "-preset", "ultrafast", "-tune", "zerolatency", "-b:v", "2M", "-c:a", "aac", "-b:a", "128k", fileStr, (char *)NULL);

be sure to have ffmpeg installed, the one in the setup.h didn't work for me but you can install it with:

sudo apt install ffmpeg

commented

I've find out that the command i used in the end, made a video not compatible with pretty much anything other than vlc. So now i'm using this:

execl("/usr/bin/ffmpeg", "ffmpeg", "-y", "-f", "video4linux2", "-s", "1280x720", "-i", "/dev/video0", "-thread_queue_size", "512", "-f", "alsa", "-ac", "1", "-i", "plughw:1,0", "-c:v", "libx264", "-preset", "ultrafast", "-tune", "zerolatency", "-profile:v", "baseline", "-level", "3.0", "-pix_fmt", "yuv420p", "-b:v", "2M", "-c:a", "aac", "-b:a", "128k", "-movflags", "+faststart", fileStr, (char *)NULL);

  • 'profile:v baseline' : Uses the baseline profile for H.264, which is more compatible with mobile devices.
  • 'level 3.0' : Sets the H.264 level to 3.0, which is compatible with most devices.
  • 'pix_fmt yuv420p' : Ensures that the pixel format is YUV 4:2:0, which is widely supported.
  • 'movflags +faststart' : Allows MP4 videos to start playing faster on mobile devices by moving metadata to the beginning of the file.

I've forgot to mention that the libmysqlclient-dev is not available anymore, you should use libmariadb-dev and edit the Makefile like this:

all: raprec raprun
raprec: raprec.c
	gcc raprec.c -o raprec -Wall -I/usr/include/mariadb -L/usr/lib/mariadb -lmariadb -lm
raprun: raprun.c
	gcc raprun.c -o raprun -Wall -I/usr/include/mariadb -L/usr/lib/mariadb -lmariadb -lbluetooth

install:
	cp raprec /usr/bin
	cp raprun /usr/bin
	chmod u+s /usr/bin/raprun
clean:
	-rm raprec raprun

and also change line 34 of raprec.c and line 37 of raprun.c with this:

#include <mariadb/mysql.h>

i'll make a fork sooner or later with these and other changes (the setup.sh is a mess under bookworm...)