How to create virtual display under Raspbian using xrandr? - raspberry-pi

Could anybody help me out to understand how to create virtual display for Raspberry Pi 3 B running Raspbian using xrandr?
I saw that it is possible to do this, for example, for Ubuntu and Linux Mint by executing these commands:
#!/bin/bash
xrandr --newmode "1920x1080_60.00" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync
xrandr --addmode VIRTUAL1 1920x1080_60.00
sleep 2
xrandr --output VIRTUAL1 --mode 1920x1080_60.00 --left-of HDMI1 --primary
xinput map-to-output $(xinput | grep -v 'XTEST.*pointer' |grep 'slave.*pointer' | grep -o 'id=*[0-9]*[0-9]' | cut -d'=' -f2) HDMI1
But under raspberry this script is not able to find VIRTUAL1 output.
When I simply run xrandr I get the following result:
xrandr: Failed to get size of gamma for output default
Screen 0: minimum 320 x 240, current 1360 x 768, maximum 1360 x 768
default connected 1360x768+0+0 0mm x 0mm
1360x768 60.00*
1024x768 60.00
800x600 60.00 56.00
640x480 60.00
680x384 60.00
512x384 60.00
400x300 60.00 56.00
320x240 60.00
1920x1080_60.00 (0x2af) 172.800MHz -HSync +VSync
h: width 1920 start 2040 end 2248 total 2576 skew 0 clock 67.08KHz
v: height 1080 start 1081 end 1084 total 1118 clock 60.00Hz
with no VIRTUAL1 and HDMI1 listed, only default. Can't figure out what steps should be taken for these outputs to appear in the given list?
Or if it is not possible then how can I create virtual display using other tools?

You wont be creating a virtual display for use with RPI. What you need to do is link your display to xrandr. This is done with the following code in terminal.
DISPLAY=:0 xrandr
Once you have done this it will be linked to xrandr and you'll be able to use it as if on Linux. However, you will need to do this on every boot or create a script that will run on boot and do this for you.
Also using xrand are will not resize your frame-buffer, this will need to be done as well.

Related

Bootup/Startup Script Not Working for nVidia GPU Clock Offset

Trying to change GPU Graphics and Memory Transfer Rate Clock Offset on my nVidia EVGA 1030 SC on bootup. I am a linux noob here using Rocky Linux 9.
Question:
How do I check my current set values for GPUGraphicsClockOffsetAllPerformanceLevels and GPUMemoryTransferRateOffsetAllPerformanceLevels?
Currently I am checking by starting up nVidia X Server then look for the values in Graphics Clock Offset and Memory Transfer Rate Offset under the PowerMizer tab. Is there a better way? I don't even really know if that is always up to date...
What did I do wrong and what do I need to change to fix my bootup script below to work?
I think my bootup script is NOT working because the PowerMizer in nVidia X Server does NOT show clock offset values of 50MHz and 200MHz for Graphics and Memory Transfer Rates, respectively, when I boot with my script. It only shows 0 and 0.
However, it does show 50MHz and 200MHz when I enter the following 3 commands line after line directly in bash terminal.
nvidia-smi -pm 1
nvidia-settings -a [gpu:0]/"GPUGraphicsClockOffsetAllPerformanceLevels=50"
nvidia-settings -a [gpu:0]/"GPUMemoryTransferRateOffsetAllPerformanceLevels=200"
Below is the bootup script...
i.
Wrote a shell script file named nVidiaStartUp.sh and placed it in: /etc/rc.d/init.d
nVidiaStartUp.sh contains
#!/bin/bash
nvidia-smi -pm 1
nvidia-settings -a [gpu:0]/"GPUGraphicsClockOffsetAllPerformanceLevels=50"
nvidia-settings -a [gpu:0]/"GPUMemoryTransferRateOffsetAllPerformanceLevels=200"
ii.
In Terminal, executed chmod +x /etc/rc.d/init.d/nVidiaStartUp.sh
iii.
Added a script named nVidiaStartUp.service in /etc/systemd/system with contents below
[Unit]
Description=nVidia Startup Script Call with Undervolt
After=getty.target
[Service]
Type=simple
ExecStart=/etc/rc.d/init.d/nVidiaStartUp.sh
TimeoutStartSec=0
#RemainAfterExit=yes
[Install]
WantedBy=default.target
#WantedBy=graphical.target
#WantedBy=multi-user.target
iv.
Ran in terminal
systemctl enable nVidiaStartUp.service
v.
Reboot and then I check my clockoffset under PowerMizer in nVidia X Server. I don't see 50MHz and 200MHz. I only see 0 and 0. That seems to imply my bootup script isn't working? Please help!
======================================================================================================================================================
Additional background info:
I have installed nVidia driver and it loads with proper GPU information. Here is what it shows after running nvidia-smi
Fri Nov 4 11:39:36 2022
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 520.61.05 Driver Version: 520.61.05 CUDA Version: 11.8 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA GeForce ... On | 00000000:0B:00.0 On | N/A |
| 48% 50C P0 N/A / 30W | 373MiB / 2048MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| 0 N/A N/A 2309 G /usr/libexec/Xorg 100MiB |
| 0 N/A N/A 2439 G /usr/bin/gnome-shell 139MiB |
| 0 N/A N/A 3270 G ...470561649073451082,131072 130MiB |
+-----------------------------------------------------------------------------+
My relevant sections for Cool-bits (I am using 8 for cool-bits as this card is passively cooled) of my /etc/X11/xorg.conf shows
Section "Device"
Identifier "Device0"
Driver "nvidia"
VendorName "NVIDIA Corporation"
BoardName "NVIDIA GeForce GT 1030"
EndSection
Section "Screen"
Identifier "Screen0"
Device "Device0"
Monitor "Monitor0"
DefaultDepth 24
Option "Coolbits" "8"
SubSection "Display"
Depth 24
EndSubSection
EndSection

Raspberry Pi 4 saving corrupt h264 files?

I've been able to record .h264 files without a problem, both using raspivid and through Python, but whatever I try, I can't convert them to a .mp4, .mkv or .avi file.
I've tried converting using MP4box (suggested in several places) and mkvmerge, but to no avail.
When I use MP4box (MP4box -add <source.h264> <dest.mp4>), I get :
AVC-H264 import - frame size 1920 x 1080 at 25.000 FPS
WARNING: NAL Unit type 0 not handled - adding5/100)
AVC Import results: 44 samples - Slices: 3 I 41 P 0 B - 0 SEI - 3 IDR
Saving video.mp4: 0.500 secs Interleaving
Then I try to play this file using VLC, it doesn't give an error, but shows garbled data.
To be clear, the camera works fine (shows perfect video using Python code and raspistill outputs a perfect jpg file). I tried a different camera as well.
An attempt with mkvmerge :
pi#raspberrypi:~/cam $ raspivid -o test.h264 -fps 30 -t 15000 -w 1920 -h 1080
pi#raspberrypi:~/cam $ mkvmerge --default-duration 0:30p -o video.mkv test.h264
mkvmerge v31.0.0 ('Dolores In A Shoestand') 32-bit
'test.h264': Using the demultiplexer for the format 'AVC/h.264'.
'test.h264' track 0: Using the output module for the format 'AVC/h.264 (unframed)'.
The file 'video.mkv' has been opened for writing.
Error: 'test.h264' track 0: mkvmerge encountered broken or unparsable data in this AVC/h.264 video track. Either your file is damaged (which mkvmerge cannot cope with yet) or this is a bug in mkvmerge itself. The error message was:
Success
pi#raspberrypi:~/cam $
This is on a Raspberry Pi 4.
A sample file can be found here : https://filebin.net/c40usz0crhgggadf
Created with : raspivid -t 30000 -w 640 -h 480 -fps 25 -b 1200000 -p 0,0,640,480 -o pivideo.h264
I'm going to respond to this myself. After doing an 'apt-get upgrade', the problem is gone.
If anyone wants to figure this out to find the root cause, this is what apt-get did :
The following packages will be upgraded:
bind9-host bluez-firmware firmware-atheros firmware-brcm80211 firmware-libertas firmware-misc-nonfree firmware-realtek libbind9-161 libdns-export1104 libdns1104 libgs9 libgs9-common libisc-export1100 libisc1100 libisccc161
libisccfg163 liblwres161 libraspberrypi-bin libraspberrypi-dev libraspberrypi-doc libraspberrypi0 pi-bluetooth raspberrypi-bootloader raspberrypi-kernel raspberrypi-kernel-headers raspi-config rpd-plym-splash
The following packages will be DOWNGRADED:
python3-pgzero
27 upgraded, 0 newly installed, 1 downgraded, 0 to remove and 0 not upgraded.

Raspberry PI and U-Boot

I wish you a good day
I'm trying U-Boot on RPi and in short - I'm stuck that when I put any dtoverlay in config.txt, after turning on RPi it's just hangs on rainbow RPi splash screen
I have created rootfs using buildroot 2020.02.1 and U-Boot 2020.01
buildroot config for U-Boot
When I have just this in config.txt:
[pi0w]
kernel=uboot_rpi_0_w.bin
[all]
device_tree_address=0x03000000
hdmi_drive=1
hdmi_force_hotplug=1
dtparam=spi=on
dtparam=audio=on
dtparam=i2c_arm=on
dtparam=watchdog=on
and boot.scr I create using this:
setenv fdt_addr_r 0x03000000
setenv kernel_addr_r 0x01000000
fdt addr ${fdt_addr_r}
fdt get value bootargs /chosen bootargs
load mmc 0:1 ${kernel_addr_r} zImage
bootz ${kernel_addr_r} - ${fdt_addr_r}
so RPi boots fine. But once I add to config.txt for example "dtoverlay = miniuart-bt" then nothing - only rainbow. I need to add this 3 dtbo: "miniuart-bt, vc4-fkms-v3d, ads7846"
My original config.txt (without U-Boot):
boot_delay=1
kernel=zImage
hdmi_drive=1
hdmi_force_hotplug=1
avoid_warnings=1
disable_overscan=1
disable_splash=1
force_turbo=1
gpu_mem_256=128
gpu_mem_512=128
gpu_mem_1024=128
dtparam=spi=on
dtparam=audio=on
dtparam=i2c_arm=on
dtparam=watchdog=on
dtoverlay=miniuart-bt
dtoverlay=vc4-fkms-v3d
# Display configuration [WaveShare 4inch HDMI LCD]
dtoverlay=ads7846
dtparam=penirq=25
dtparam=xomhs=60
dtparam=xmin=300
dtparam=xmax=3750
dtparam=ymin=150
dtparam=ymax=3800
dtparam=rotate=0
dtparam=swapxy=0
hdmi_force_mode=1
hdmi_group=2
hdmi_mode=87
hdmi_cvt=480 800 60 6 0 0 0
Thank you in advance for your help
You need to comment the dtoverlay=vc4-fkms-v3d line when you're using dtoverlay=ads7846 at the same time.

Getting "output eDP-1 not found" from xrandr after upgrading to Ubuntu 17.10 when I try to change brightness

I have a ThinkPad X1 Yoga (2nd gen) and when running Ubuntu 17.04 I could change the brightness like this:
$ xrandr --output eDP-1 --brightness .7
Now, when I do that under 17.10 I get this:
warning: output eDP-1 not found; ignoring
xrandr: Need crtc to set gamma on.
When I hit brightness up and down buttons I see the numerical value in this file changing properly:
/sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight/brightness
But xrandr reports a new label:
$ xrandr -q
Screen 0: minimum 320 x 200, current 2560 x 1440, maximum 8192 x 8192
XWAYLAND0 connected 2560x1440+0+0 (normal left inverted right x axis y axis) 310mm x 180mm
2560x1440 59.96*+
I've tried replacing eDP-1 with XWAYLAND0 but it returns 0 with no errors and nothing at all happens to the brightness.
$ xrandr --output XWAYLAND0 --brightness 0.5
$ echo $?
0
Would love some help on getting brightness settings working again. Right now it's stuck on full brightness all the time, which isn't great for the battery.
xrandr is made for X11 and won't work on Wayland. At least I'm not aware of any Wayland protocol for this yet (though one could easily be made).
There might be some gnome-shell (if that's the compositor you're using) tool for this, though, but I'm not too familiar with gnome.

flv reencode to mp4 for iphone/ipod via ffmpeg and x264 (quality issue)

There are a lot of questions on this topic, and I've read most of them and most of the google search results I could come up with.
When I use FFMPEG to convert a FLV to a iphone3 compatble MP4 file, it just doesn't preserver enough of the quality. Yes, I've worked the hell out of -sameq and -b and -bt settings, text just isn't readable.
Next I tried to split the video out and process it directly, using these instructions:
https://sites.google.com/site/linuxencoding/x264-encoding-guide
The problem is myplayer (via ffmpeg) was not able to determine the duration of the FLV (even though the metadata was set).
(I assume) Because of that unknown duration, when I create the MP4 file, the resulting x264 file plays through super-fast while the audio plays at the normal rate.
user#server:/tmp# mplayer -nosound -benchmark -sws 9 -vf dsize=640:480:0,scale=0:0,expand=640:480 -vo yuv4mpeg:file=>(x264 --demuxer y4m --crf 0 --preset slow --threads auto --output output.264 - 2>x264.log) 'input.flv'
MPlayer 1.0rc4-4.4.5 (C) 2000-2010 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.
Playing input.flv.
libavformat file format detected.
[flv # 0x1202460]Estimating duration from bitrate, this may be inaccurate
[lavf] stream 0: video (vp6f), -vid 0
[lavf] stream 1: audio (nellymoser), -aid 0
VIDEO: [VP6F] 1680x992 0bpp 1000.000 fps 33.4 kbps ( 4.1 kbyte/s)
Clip info:
audiocodecid: 6
audiodatarate: 86
audiosamplerate: 44100
audiosamplesize: 16
audiosize: 6097005
canSeekToEnd: true
datasize: 8609138
duration: 567
framerate: 2
hasAudio: true
hasCuePoints: false
hasKeyframes: true
hasMetadata: true
hasVideo: true
height: 992
lasttimestamp: 567
metadatacreator: flvtool++ (Facebook, Motion project, dweatherford)
stereo: false
totalframes: 1043
videocodecid: 4
videodatarate: 33
videosize: 2316256
width: 1680
Using (default) progressive frame mode.Opening video filter: [expand w=640 h=480]
Expand: 640 x 480, -1 ; -1, osd: 0, aspect: 0.000000, round: 1
Opening video filter: [scale w=0 h=0]
Opening video filter: [dsize=640:480:0]
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffvp6f] vfm: ffmpeg (FFmpeg VP6 Flash)
==========================================================================
Audio: no sound
Starting playback...
Movie-Aspect is undefined - no prescaling applied.
[swscaler # 0x7f0c738b9620]Lanczos scaler, from yuv420p to yuv420p using MMX2
VO: [yuv4mpeg] 640x480 => 641x480 Planar YV12
I have also tried specifying FPS, but no change in results
user#server:/tmp# mplayer -nosound -fps 25-benchmark -sws 9 -vf dsize=640:480:0,scale=0:0,expand=640:480 -vo yuv4mpeg:file=>(x264 --demuxer y4m --fps 25 --crf 0 --preset slow --threads auto --output output.264 - 2>x264.log) 'input.flv'
Can someone tell me how to either:
fix my split A/V processing/timing/duration issues?
improve the
quality of the FFMPEG conversion of FLV to iphone3 compatible
format?
I would suggest trying handbreak(http://handbrake.fr/), I think it can encode flvs as well as almost every other file formate I have ever tried, and I'v never had any trouble with quality.