![]() |
|
How can I record video on a Pinephone? - Printable Version +- PINE64 (https://forum.pine64.org) +-- Forum: PinePhone (https://forum.pine64.org/forumdisplay.php?fid=120) +--- Forum: General Discussion on PinePhone (https://forum.pine64.org/forumdisplay.php?fid=127) +--- Thread: How can I record video on a Pinephone? (/showthread.php?tid=16539) |
RE: How can I record video on a Pinephone? - Kevin Kofler - 10-07-2025 If you have Megapixels working, you can try to open it, make a touch click in the preview to set focus, and close it, then run the recording script. RE: How can I record video on a Pinephone? - baptx - 10-08-2025 Thanks, that's what I wanted to try next and it worked. However I needed to start Megapixels after starting ffmpeg. Then Megapixels will auto-close its GUI but autofocus will work! RE: How can I record video on a Pinephone? - Kevin Kofler - 10-08-2025 Ah thanks, that trick in that form is news even to me. RE: How can I record video on a Pinephone? - baptx - 03-25-2026 On Mobian 13, Megapixels and Gnome Snapshot are still not usable to record videos: https://gitlab.com/megapixels-org/Megapixels/-/issues/12#note_2996773259 https://salsa.debian.org/Mobian-team/devices/sunxi-support/-/issues/3#note_730061 So using ffmpeg is still useful. To make the script with preview work with Mobian 13 on the PinePhone, I had to load the v4l2loopback module manually and with 2 devices. I also had to limit the preview to around 5 FPS to have a smooth recording when using 2 devices with v4l2loopback. Using only 1 device for v4l2loopback is no longer working to use it as preview and recording at the same time: https://github.com/v4l2loopback/v4l2loopback/issues/566#issuecomment-2007587016 However I noticed the ffmpeg parameter "-f xv display" does not produce a delay in the preview if we configure a lower framerate like 20 FPS so we no longer need v4l2loopback. Even when configuring 20 FPS, the video results in 15 FPS like with v4l2loopback but at least it appears smooth enough. When configuring 20 FPS with the media-ctl command, we can also see with media-ctl that it uses 15 FPS instead, maybe it is due to the fact that 20 FPS is not a known value for the camera. This produces a blank screen if we open Megapixels afterwards (tested with the Flatpak package) until we take the first picture. If we find a small delay in the video preview acceptable, we can configure 30 FPS which will result in a lower value from around 20 FPS to 24 FPS or a bit more (media-ctl also displays 30 FPS if we configure 24 FPS, maybe this configuration is not supported), this is what I am doing now and the phone did not crash after more than 5 minutes recording (unlike when I used v4l2loopback on the previous Mobian version). The PinePhone camera is recording in variable frame rate automatically (https://en.wikipedia.org/wiki/Variable_frame_rate), I don't know if the camera can use constant frame rate natively. Constant frame rate can be done with the ffmpeg parameter -vf "fps=$FPS" but I don't know if it is a good idea since it may not be the real FPS if it just duplicate frames. Another issue was the front camera that did not work with the same recording script on Mobian 13. With the following command, I saw the front camera gc2145 used the value 1x16 even when configuring 2x8 and the @ part with FPS is missing at the end: media-ctl -d$DEVICE -p This command from the script produces the error "Unable to setup formats: Invalid argument (22)" on Mobian 13 but the script was working on Mobian 12 (maybe the issue is due to a kernel upgrade): media-ctl -d$DEVICE -V"$MAIN_SENSOR:0[fmt:UYVY8_2X8/${WIDTH}x${HEIGHT}@1/$FPS]" The front camera only worked in Megapixels, I thought it is a known issue because the PostmarketOS wiki also says only the rear camera has mainline Linux support even if the front camera works with Megapixels: https://wiki.postmarketos.org/wiki/PINE64_PinePhone_(pine64-pinephone)#Cameras I was able to solve the error by removing the part @1/$FPS at the end. The front camera video is not horizontally inverted unlike Megapixels, so it records with the camera point of view instead of having a mirror effect. I tried the horizontal flip with the ffmpeg parameter -vf hflip but it did not work and was slowing down the preview. The command v4l2-ctl with the parameter --set-ctrl horizontal_flip=1 (https://stackoverflow.com/questions/66487493/v4l2-setting-horizontal-flip-results-in-bar-artifacts) did not work either, it says it is an unknown control, like the control rotate=90 if we want to have the recording and preview in portrait mode. |