Simple mixer control 'Capture',0 Capabilities: cvolume cswitch cswitch-joined Capture channels: Front Left - Front Right Limits: Capture 0 - 65536 Front Left: Capture 65536 [100%] [on] Front Right: Capture 65536 [100%] [on]portraitUnable to parse link: Invalid argument (22)Unable to setup formats: Invalid argument (22)
I tried both rear and front no file is saved.
I don't hear any click sound as when the camera is starting.
Designs
Child items
...
Show closed items
Linked items
0
Link issues together to show that they're related.
Learn more.
I got the same errors Unable to parse link: Invalid argument (22) and Unable to setup formats: Invalid argument (22) with the app. For some other video recording scripts, people said we should start the Megapixels camera app first to set up the camera but this did not fix the issue.
Sometimes the issue is even worse because the ffmpeg commands never ends even when killing it with sudo killall -9 ffmpeg and this results in a black screen when using the Megapixels camera app so we have to restart the PinePhone.
You can execute the following commands used by the app to try to understand better where the issue comes from:
The error above can be fixed by replacing sh /opt/fastvideo/capture.sh with bash /opt/fastvideo/capture.sh in "record.sh" file.
bash: line 1: /sys/class/leds/white:flash/brightness: Permission denied
To fix the error above, I used a worarkound by removing & echo 0 > /sys/class/leds/white:flash/brightness from the "Stop and save" button command since I did not use the torch with the app for the moment.
Maybe someone knows a better a fix.
I tried all the other video recording scripts below but none worked on an updated Mobian system with Phosh (Mobian edition convergence package), even with the correct video source number and sensors number. I never tried previously.
But then I had to cut, crop, rotate the video and shift the audio with avidemux on my computer. And it is not the best video quality. The only advantage with screen recording is that we can see the video preview but maybe this is also possible with ffmpeg / ffplay.
Does someone have an idea how to record video without screen recording and without errors?
This is because your user is not in the group which have access to leds. I think in pmos the group is video but not 100% sure. You can sure remove the led part from the script but you can also add your user to group which has priviledge (via new udev rule or usermod or similar)
bash: line 1: /sys/class/leds/white:flash/brightness: Permission denied
About other issues I am not sure. This works on pmos and arch as is and it use to work also in Mobian.
Today in postmarketos edge channel you can record videos with Snapshot if you have all needed packages installed (libcamera, wireplumber). So this project is not needed because we have now working video recording app. I am 99% sure that the solution will land to Mobian and Arch too in short time.
How ever if someone wants to send mr to solve these issues in Mobian I can sure merge those changes. Personally I don't think it is good idea to use time on this because this was ment to be solution before someone actually makes the libcamera thing to work.
I installed the gnome-snapshot Flatpak (https://flathub.org/apps/details/org.gnome.Snapshot) but there is an error "No Camera Found".
There is also this error in the terminal:
Gsk-Message: 16:48:21.216: Failed to realize renderer of type 'GskNglRenderer' for surface 'GdkWaylandToplevel': OpenGL ES 3.0 is not supported by this renderer.
Mobian has a package for Millipixels but it is not working either on the PinePhone.
@b4ptx I do not have a PinePhone, but I ran into similar issues on the PinePhone Pro regarding Invalid argument (22) and hanging forever. In my experience, this stemmed from misconfiguring something in the links between pads (height, width, format, a missing link, or a link that can't work due to constraints).
To figure out what it's actually complaining about, I enabled debug logging for a few things.
Those are probably the main ones. The first let me know if the height, width or format was incorrect (in dmesg).
If this is solved, it may solve the infinite loading too. I can't remember what it was for me - either the misconfigured links, or an issue with drivers, or both.
I use this personally, but it adds a lot of noise.
@k.vos Your commands don't display additional information in dmesg when the errors happen, do you know why? I tested with an updated Mobian on PinePhone.
By the way, how can I revert the commands and do they persist after reboot?
It looks like the errors Unable to parse link: Invalid argument (22)and Unable to setup formats: Invalid argument (22) happen because some variables are null due to missing information in the command media-ctl -d1 -p.
For example here is what I got now (the camera ov5640 and secondary camera gc2145 are not displayed even if the Megapixels app is running fine):
Media controller API version 6.1.69Media device information------------------------driver cedrusmodel cedrusserial bus info platform:cedrushw revision 0x0driver version 6.1.69Device topology- entity 1: cedrus-source (1 pad, 1 link) type Node subtype V4L flags 0 device node name /dev/video3 pad0: Source -> "cedrus-proc":0 [ENABLED,IMMUTABLE]- entity 3: cedrus-proc (2 pads, 2 links) type Node subtype Unknown flags 0 pad0: Sink <- "cedrus-source":0 [ENABLED,IMMUTABLE] pad1: Source -> "cedrus-sink":0 [ENABLED,IMMUTABLE]- entity 6: cedrus-sink (1 pad, 1 link) type Node subtype V4L flags 0 device node name /dev/video3 pad0: Sink <- "cedrus-proc":1 [ENABLED,IMMUTABLE]
So it appears the camera names are missing randomly. If I reboot and the camera names appear, no errors will be displayed but ffmpeg will be frozen and it will be impossible to kill the process.
Update: it appears that the missing camera names can be fixed by replacing the command media-ctl -d1 -p with media-ctl -p to use the default media device ID 0 (https://linux-sunxi.org/CSI).
My commands enable dynamic debug logging for a few particular files, but that only works if your device enables/supports dynamic debug logging. If the kernel module isn't included, or it's not enabled in some other way, it may not show anything in dmesg.
I haven't done this enough to know how you enable it, but it's a generic Linux thing, so you may need to do some digging for your setup. https://stackoverflow.com/questions/11631968/how-to-enable-dynamic-debugging-in-the-linux-kernel and https://docs.kernel.org/admin-guide/dynamic-debug-howto.html may be helpful. I don't have either a PinePhone nor Mobian, so can't test myself right now.
By the way, how can I revert the commands and do they persist after reboot?
It does not persist after a reboot
There may be multiple devices that you can show with media-ctl, so you can try media-ctl -d 0 -p, but also try with 1, 2, 3, etc. Cedrus looks like it's used for hardware accelerated video encoding/decoding (https://linux-sunxi.org/Cedrus), so unrelated to the front/rear camera.
@k.vos Like mentioned in your links, I checked that the command cat /proc/dynamic_debug/control is displaying information and ran these commands as root:
These commands did not display additional information in dmesg because I am seeing the same information without. Here is what I can see in dmesg (the first 2 lines are displayed when starting the Megapixels app but the issue happened even when not starting the Megapixels app after boot):
Then I installed Linux kernel 6.6.37 from staging repository with this command:
sudo apt install linux-image-6.6-sunxi64
After reboot, I was able to record videos with ffmpeg.
However now the Megapixels app crashes when I press the button to take pictures (even if I can see the preview). I can see these errors when running Megapixels from command line:
Found config file at /usr/share/megapixels/config/pine64,pinephone-1.2.iniAdding camera rear from configAdding camera front from configMPDevice: MEDIA_IOC_SETUP_LINK error 22, Invalid argumentFailed to open /sys/class/leds/white:flash/flash_strobeMPDevice: MEDIA_IOC_SETUP_LINK error 22, Invalid argumentMPDevice: MEDIA_IOC_SETUP_LINK error 22, Invalid argumentInitialized OpenGL ES 2.0MPCamera: VIDIOC_STREAMON error 22, Invalid argumentMPCamera: VIDIOC_DQBUF error 22, Invalid argument
In dmesg, I can see this error (see the last line when I press the button to take a picture):
[ 350.518403] ov5640 0-004c: ov5640_write_reg: error: reg=3008, val=42[ 350.957359] ov5640 0-004c: ov5640_set_ctrl_focus: can't set focus when not powered[ 355.358745] sun6i-csi 1cb0000.csi: invalid input/output dimensions: 1280x720/2592x1944
You could try changing some of the values in /usr/share/megapixels/config/pine64,pinephone-1.2.ini to see if it works after that. E.g. capture-width and preview-width both 1280 or both 2592, etc. https://salsa.debian.org/Mobian-team/devices/kernels/sunxi64-linux/-/blob/mobian-6.6/drivers/media/i2c/ov5640.c has some other width/height combinations that should work.
If Megapixels isn't doing it, you could also try changing the width/height or cropping of the csi subdevice with media-ctl/v4l-ctl.
But I'm not sure if this is an issue with the kernel or Megapixels, maybe best to create an issue in the sunxi64-linux repo on Mobian? I also found a similar issue about Megapixels there.
A workaround was possible with capture-width and preview-width both 1280, capture-height and preview-height both 720 (but not 2592 and 1944), capture-rate and preview-rate both 30 (or 10, I don't remember) in /usr/share/megapixels/config/pine64,pinephone-1.2.ini. However the pictures will be lower quality with a resolution of 1280x720 instead of 2592x1944.
I also built the latest version of Megapixels from GitLab but the app is crashing. I reported the issue here:
All the PinePhone video recording scripts I found so far were not displaying a video preview but it is in fact possible to do video recording with ffmpeg and preview the video at the same time! This can be done by adding "-f xv display" to the ffmpeg command (https://superuser.com/questions/343586/how-to-display-and-capture-webcam-stream-at-the-same-time/1551806#1551806). There is a delay of a few seconds in the video preview but I don't know if it can be improved without lowering the resolution and FPS.
I made a recording script with video preview based on the commands from your repository and also fixed the errors from this issue ("Unable to parse link: Invalid argument (22)" and "Unable to setup formats: Invalid argument (22)") by getting the correct media device ID:
Closing the preview will end the recording. If we want to enable the flash light, it can be accessed quickly from the top system menu by pressing the torch icon (at least on Phosh).
It is also possible to preview and record video with WebRTC but when I tested in Firefox (after executing the appropriate media-ctl commands), it was only possible to record a few seconds, otherwise the file is corrupted:
https://webrtc.github.io/samples/src/content/getusermedia/record/
Update: I updated the video recording script with preview, it is now possible to preview the video without delay while recording thanks to v4l2loopback which allows accessing a camera from several applications at the same time.
I noticed that after recording around 2 minutes with preview, the phone crashed but I was able to fix the issue and record more than 5 minutes with preview by lowering the FPS to 20 (which may appear as around 15 FPS with the variable framerate ffmpeg parameter "-fps_mode vfr" to avoid duplicated frames) but the video should be smooth enough.