GithubHelp home page GithubHelp logo

Picture quality pi zero about hkcam HOT 30 CLOSED

brutella avatar brutella commented on July 18, 2024
Picture quality pi zero

from hkcam.

Comments (30)

brutella avatar brutella commented on July 18, 2024 2

HomeKit decides which resolution is used to stream the video.

The HomeKit Accessory Protocol supports up- and downgrading the video resolution on the fly. This functionality is currently not implemented. Not sure if that is even possible with ffmpeg!

from hkcam.

brutella avatar brutella commented on July 18, 2024 2

I've just pushed 48e4dbc which offers a new command line argument for specifying the minimum video bitrate. This argument in combination with specifying the video size via v4l2-ctl should significantly improve the video quality.

You can set the video size to 720p and the bit rate to 800kbps by updating the run script /etc/sv/hkcam/run/.

#!/bin/sh -e
exec 2>&1
v4l2-ctl --set-fmt-video=width=1280,height=720,pixelformat=YU12
exec hkcam --min_video_bitrate=800 --data_dir=/var/lib/hkcam/data --verbose=true

Then restart the service via sudo sv restart hkcam or reboot the device.

Note: Once you specify a minimum bit rate, the streaming to Apple Watch might not work anymore. The Apple Watch wants to have a much lower bit rate.

from hkcam.

pieter avatar pieter commented on July 18, 2024 1

Running this on startup increases the image quality for me:

v4l2-ctl --set-fmt-video=width=1280,height=720,pixelformat=YU12
v4l2-ctl -c video_bitrate=1000000

from hkcam.

brutella avatar brutella commented on July 18, 2024 1

The wiki tells you more about updating hkcam from source.

from hkcam.

magnip avatar magnip commented on July 18, 2024

I have ssh into pi zero w and pasted this command.
raspivid -t 0 -b 5000000 -fps 30 -w 1920 -h 1080 -o - | nc -p 1904 -u 192.168.2.108 1234
If you have a hdmi monitor connected the camera video will be shown with excellent quality and very low latency. Rebooted pi by pulling power otherwise pi will freeze with error using sudo reboot.
Opened HomeKit app on iPhone and there is a noticeable improvement. Not as nice as the live view through hdmi but it’s getting there.

from hkcam.

AchimPieters avatar AchimPieters commented on July 18, 2024

I also have problems with the quality of the video. i've attached a image so you can see what's the trouble.
best-face-oil
As you can see it grainy. I've tried several raspivid settings but with no better result? can you help me?
The stills are high quality! like this:
best-face-oil

from hkcam.

iMartzen avatar iMartzen commented on July 18, 2024

I have ssh into pi zero w and pasted this command.
raspivid -t 0 -b 5000000 -fps 30 -w 1920 -h 1080 -o - | nc -p 1904 -u 192.168.2.108 1234
If you have a hdmi monitor connected the camera video will be shown with excellent quality and very low latency. Rebooted pi by pulling power otherwise pi will freeze with error using sudo reboot.
Opened HomeKit app on iPhone and there is a noticeable improvement. Not as nice as the live view through hdmi but it’s getting there.

What kind output do you get on that command:

"raspivid -t 0 -b 5000000 -fps 30 -w 1920 -h 1080 -o - | nc -p 1904 -u 192.168.2.108 1234"

and can you explain me what it does?

from hkcam.

benbeton avatar benbeton commented on July 18, 2024

I'm seeing this on my Pi Zero too. The Cam works fine, but the quality is not as good as in the screens on the website.
Any ideas why?

from hkcam.

mbenkler avatar mbenkler commented on July 18, 2024

i checked the logfile from hkcam, and there i see that the video resolution ist set to 1024*768 perhaps there is the problem:

2019-05-31_07:56:04.59030 Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1024x768, 283115 kb/s, 30 fps, 30 tbr, 1000k tbn, 1000k tbc

the cam module should provide 1080p video

from hkcam.

mbenkler avatar mbenkler commented on July 18, 2024

That is good to know, but why is it so blurry on my setup and your screenshots are in good quality.

from hkcam.

brutella avatar brutella commented on July 18, 2024

Mainly because those screenshots are not taken directly from the camera – they are mockups.

But the snapshots, which are shown in the HomeKit apps, are way higher quality than the video stream.

from hkcam.

mbenkler avatar mbenkler commented on July 18, 2024

thanks for the feedback

from hkcam.

magnip avatar magnip commented on July 18, 2024

Running this on startup increases the image quality for me:

v4l2-ctl --set-fmt-video=width=1280,height=720,pixelformat=YU12
v4l2-ctl -c video_bitrate=1000000

You are a star bro! The video feed is still a little grainy but it has a lot less latency. Well done it’s much closer to the pi zero default video output viewed in browser.

from hkcam.

fisch55 avatar fisch55 commented on July 18, 2024

I changed the run but I get the following message in log

Verbose logging (default true) 2019-06-21_17:57:14.45689 flag provided but not defined: -min_video_bitrate 2019-06-21_17:57:14.45726 Usage of hkcam: 2019-06-21_17:57:14.45763 -data_dir string 2019-06-21_17:57:14.45770 Path to data directory (default "Camera") 2019-06-21_17:57:14.45794 -h264_decoder string 2019-06-21_17:57:14.45801 h264 video decoder 2019-06-21_17:57:14.45826 -h264_encoder string 2019-06-21_17:57:14.45832 h264 video encoder (default "h264_omx") 2019-06-21_17:57:14.45857 -input_device string 2019-06-21_17:57:14.45863 video input device (default "v4l2") 2019-06-21_17:57:14.45899 -input_filename string 2019-06-21_17:57:14.45906 video input device filename (default "/dev/video0") 2019-06-21_17:57:14.45933 -loopback_filename string 2019-06-21_17:57:14.45940 video loopback device filename (default "/dev/video1") 2019-06-21_17:57:14.45967 -multi_stream 2019-06-21_17:57:14.45973 Allow mutliple clients to view the stream simultaneously (default true) 2019-06-21_17:57:14.45997 -verbose 2019-06-21_17:57:14.46004 Verbose logging (default true)

from hkcam.

brutella avatar brutella commented on July 18, 2024

@fisch55 You have to compile a new version of hkcam from source as described here

from hkcam.

fisch55 avatar fisch55 commented on July 18, 2024

ok, can I build it directly on PI?

from hkcam.

brutella avatar brutella commented on July 18, 2024

Yes

from hkcam.

fisch55 avatar fisch55 commented on July 18, 2024

mmmm, for me it does not work...:-(

pi@raspberrypi:~ $ cd hkcam/ pi@raspberrypi:~/hkcam $ make build GOOS=linux GOARCH=arm GOARM=6 go build -o build/hkcam-_linux_armhf/usr/bin/hkcam -i cmd/hkcam/main.go /bin/sh: 1: go: not found Makefile:27: recipe for target 'build' failed make: *** [build] Error 127

I did it like here described:

Update from source

You can also compile the binary yourself. These steps require Git and Go to be installed. On macOS you can install it via Homebrew.

brew install git
brew install go
Clone the project with git clone https://github.com/brutella/hkcam.git
Fetch all branches with git fetch --all
Checkout a specific commit or branch – for example git checkout <commit-hash|branch-name>
Change directory into the project with cd hkcam
Build hkcam with make build
Copy the new binary onto the raspberry pi with scp build/hkcam-_linux_armhf/usr/bin/hkcam [email protected]:~
ssh into the raspberry pi with ssh [email protected] (password raspberry)
Stop the currently running daemon with sudo sv stop hkcam
Override the old binary with the new one sudo mv ~/hkcam /usr/bin/
Restart the hkcam daemon with sudo sv start hkcam

from hkcam.

RaymondMouthaan avatar RaymondMouthaan commented on July 18, 2024

just apply 48e4dbc and it works perfect 🥇 . Video quality and responsiveness improved a lot 👍 .

From the current log file these messages show up, not sure if that's okay? #14 still remains an issue... I guess you @brutella made a note of that ;)

Past duration 0.976448 too largeN/A time=00:03:03.93 bitrate=N/A speed=   1x    s dup=0 drop=25 speed=   1x    =0 drop=25 speed=   1x    
Past duration 0.601738 too largeN/A time=00:03:04.46 bitrate=N/A speed=   1x    03.10 bitrate= 805.0kbits/s dup=0 drop=25 speed=   1x    
Past duration 0.610634 too largeN/A time=00:03:07.49 bitrate=N/A speed=   1x    s dup=0 drop=26 speed=   1x    =0 drop=26 speed=   1x    
2019-06-24_20:20:00.30241 Past duration 0.918083 too large
Past duration 0.824455 too largeN/A time=00:03:09.53 bitrate=N/A speed=   1x    s dup=0 drop=26 speed=   1x    =0 drop=26 speed=   1x    
2019-06-24_20:20:02.45781 Past duration 0.638008 too large
Past duration 0.718193 too large 5630 fps= 30 q=-0.0 size=   18522kB time=00:03:08.60 bitrate= 804.5kbits/s dup=0 drop=26 speed=   1x    
2019-06-24_20:20:02.64061 Past duration 0.970299 too large
Past duration 0.801094 too largeN/A time=00:03:10.53 bitrate=N/A speed=   1x    s dup=0 drop=26 speed=   1x    
Past duration 0.647545 too large   18680kB time=00:03:10.16 bitrate= 804.7kbits/s dup=0 drop=26 speed=   1x    =0 drop=26 speed=   1x    
Past duration 0.618889 too largeN/A time=00:03:15.59 bitrate=N/A speed=   1x    s dup=0 drop=27 speed=   1x    
Past duration 0.617348 too largeN/A time=00:03:16.63 bitrate=N/A speed=   1x    s dup=0 drop=27 speed=   1x    =0 drop=27 speed=   1x    
Past duration 0.627831 too largeN/A time=00:03:17.63 bitrate=N/A speed=   1x    s dup=0 drop=27 speed=   1x    =0 drop=27 speed=   1x    
Past duration 0.627373 too largeN/A time=00:03:18.66 bitrate=N/A speed=   1x    s dup=0 drop=27 speed=   1x    =0 drop=27 speed=   1x    
Past duration 0.611458 too largeN/A time=00:03:19.66 bitrate=N/A speed=   1x    s dup=0 drop=27 speed=   1x    =0 drop=27 speed=   1x    

from hkcam.

fisch55 avatar fisch55 commented on July 18, 2024

Can u explain me how did u do it?

from hkcam.

RobPijpers avatar RobPijpers commented on July 18, 2024

I run hkcam version 0.0.8. When I change the file run in /etc/sv/hkcam/ the camera does not respond in the Home App. When set to default again the camera works again in the Home App.

from hkcam.

brutella avatar brutella commented on July 18, 2024

@RobPijpers Do you see an error message in the log file when you try to start a stream from your iOS device with the update run file?

from hkcam.

RobPijpers avatar RobPijpers commented on July 18, 2024

@brutella Maybe this is the problem:
2019-07-01_19:39:08.49927 flag provided but not defined: -min_video_bitrate
2019-07-01_19:39:08.50073 Usage of hkcam:

Below the content of my run file:
#!/bin/sh -e
exec 2>&1
v4l2-ctl --set-fmt-video=width=1280,height=720,pixelformat=YU12
exec hkcam --min_video_bitrate=800 --data_dir=/var/lib/hkcam/data --verbose=true

I used the image from this link https://github.com/brutella/hkcam/releases/download/v0.0.8/raspbian-stretch-lite-2019-04-08-hkcam-v0.0.8-armv6.img.zip

from hkcam.

brutella avatar brutella commented on July 18, 2024

The --min_video_bitrate option is not available in v0.0.8.
I will include it in v0.0.9.

from hkcam.

RobPijpers avatar RobPijpers commented on July 18, 2024

@brutella Please post a reply if v0.0.9 is available, thanks!

from hkcam.

brutella avatar brutella commented on July 18, 2024

v0.0.9 is now available.

from hkcam.

chris-hinds avatar chris-hinds commented on July 18, 2024

I have run through these steps in this issue, but still have pretty terrible video quality.

I am running on v0.0.9

This is running on anew PI Zero with the official 1080p camera module.
IMG_6359

from hkcam.

brutella avatar brutella commented on July 18, 2024

Your camera seems to be out of focus. Try to change the focus.

from hkcam.

RobPijpers avatar RobPijpers commented on July 18, 2024

@hindsc52 please post your run file here.

from hkcam.

chris-hinds avatar chris-hinds commented on July 18, 2024

@hindsc52 please post your run file here.

I have moved this to a new issue as to not clutter up this one, as others have suggested this is a focus issue.

Will post my run in on the nw issue.

#46

from hkcam.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.