Hi-res is not working
|Status:||In Progress||Start date:||26 Mar 2021|
|Target version:||PiBox - 2.0 - Harkonnen|
|Severity:||01 - Critical|
The following command works for low res:
mjpg_streamer -i "input_uvc.so -d /dev/video0 -r 256x144 -f 4" -o "output_http.so -p 9090"
The following command works for high res:
mjpg_streamer -i "input_uvc.so -d /dev/video0 -r 640x480 -f 33" -o "output_http.so -p 9090"
This is the current config for high res:
mjpg_streamer -i "input_uvc.so -d /dev/video0 -r 640x480 -f 10" -o "output_http.so -p 9090"
It should work. But it will fail if the old mjpeg_streamer is running. So the problem may be that the low-res is still running when we try to switch to the high-res.
RM #829: Init script doesn't need to set -I and -S. The config file can be used for that to customize piboxd for different systems.
#1 Updated by Hammel about 1 month ago
- Status changed from New to In Progress
- % Done changed from 0 to 10
Need to add some programmatic upkeep here.
This will allow me to query the device and do some setup before creating the hi-res/low-res instance of mjpeg-streamer.
#2 Updated by Hammel about 1 month ago
This may be a more general problem. I can't get the webcam to work at all with pisentry.
I need to retest a full media system build and check that the webcam is really working (on the web interface).
I need to add more debug - is the php message getting to piboxd? Is it the right message? Is piboxd not adding inbound to the queue? Is the message getting lost on the queue?
Just thought of this, but maybe I should switch from mjpg_streamer to ffmpeg. That might provide better results.I need to experiment with using ffmpeg to stream a webcam. Some references:
Question: Can we control the stream on the fly using v4l2-ctrl? A quick experiment shows this:
Set resolution and format
v4l2-ctl -d /dev/video2 -vwidth=1920,height=1080,pixelformat=YUYV
Play the video
ffplay -i /dev/video2
The pixelformat may not be needed as I can set it with ffmpeg directly. In other words, instead of adjusting the ffmpeg command I can simply adjust resolution with v4l2-ctl and then use the same ffmpeg command every time. Not sure if that's cleaner than what I have now, though by using v4l2-ctl I can use popen to run the command and find out if it works before starting the stream.
This works with VLC, but only because it can play from a UDP stream.
ffmpeg -f v4l2 -i /dev/video2 -profile:v high -pix_fmt yuvj420p -level:v 4.1 -preset ultrafast -tune zerolatency -vcodec libx264 -r 10 -b:v 512k -s 640x360 -f mpegts -flush_packets 0 udp://192.168.101.4:5000?pkt_size=1316
The IP address has to be the local hosts address where ffmpeg is run.
I've experimented with both mjpeg_streamer and ffmpeg. The latter doesn't stream as easily as mjpeg-streamer but does handle input and output formats managed via v4l2-ctl better. mjpeg-streamer doesn't honor v4l2 changes to the device. So the only choice is to relaunch mjpeg-streamer with different resolution settings.
That means a better understanding of why relaunching the process doesn't always work.
I have an update to piboxd/stream.c that waits for the process to really start by stat'ing it's /proc/<pid> directory. If that doesn't work it returns an error.
This should be extended in queueProcessor.c to put the request back on the queue to be tried again, with a max-tries option added. Right now there are other assumptions on what to do if the process doesn't start, like just updating the timestamp.