gkaindl / ambi-tv

a flexible ambilight clone for embedded linux
296 stars 85 forks source link

STK1160 with 640x480 (UYVY) Format #12

Closed shjackal closed 10 years ago

shjackal commented 10 years ago

Hi gkaindl,

First of all, thanks for the great software and the tutorial. The second i saw it, i ordered the parts and started to build it. The RGB LED Strip is attached to the TV and the mood-light is working just fine. The only problem i have, is the video format my video grabber spits out. Of course it's not the YUYV format as you already have integrated. Mine has a UYVY Format.

I copied all the functions specific to the YUYV format, and changed everything that made sense to me to the UYVY format. when i start the software it doesn't complain anymore about an unsupported format, but the average rgb color is not nearly the color it should be, and the edge-color doesn't change the color in anyway. As i see it the only difference between UYVY and YUYV is the component order of the macropixel.

I'd be very glad if i could show you my modified video-fmt.c and video-fmt.h files, if you see where i'm wrong. If we get it to work, of course you could use it to add it as supported format in your code. I'd be very glad to hear from you.

Thanks in advance.

gkaindl commented 10 years ago

Yes, sure, let me have a look. Without being absolutely sure at the moment (I'll have to look at v4l docs), it sounds as if you'd only need to switch around the component indexes. However, it's also possible that UYVY actually maps to 3 component planes, rather than interweaved samples (I doubt it, though).

Also, have you made sure that your grabber is actually returning a proper screengrab? You could install "mplayer" via apt-get, then run "mplayer tv:// -tv device=/dev/video0 -hardframedrop" to check – I'd recommend doing this on the console when you're logged into your RPi, which is connected to a screen via HDMI or composite, so that you can actually see the video stream. It's possible that you have a PAL/NTSC mismatch or another similar problem, where the image is horribly cropped or squished.

By the way, what color is the solid color you are getting with the edge-color processor? If it's black, it's likely that your input image is heavily cropped, if it's green-ish, it means v4l can't grab the frames properly.

shjackal commented 10 years ago

Thanks for the Tip, i am just now sitting infront of my stuff, and checked the video inupt, i got it clear as it should be, so i guess the video grabber part is working fine. (A clear 640 x 480 Picture, updating a bit slow, but i didn't tweek with overclocking yet, so this seems pretty normal)

The edge color doesn't change the color at all, so it jus stays with the color it had before cycling over from the moodlight. And the avg-color just shows a color when i start it, and it doesn't change then. when i stop and start the avg-color again, it shows a different color. (between almos white to red, to yellow) and all i have on my screen is the blue xbmc home screen. strange..

So i guess i just made some mistakes in the video-fmt.c / h files :( I forked your repository and uploaded my changed files to it: https://github.com/shjackal/ambi-tv/tree/master/src Would be glad if you could check it somtimes.

gkaindl commented 10 years ago

I'll have a detailed look later, but one thing I noticed is that in the crop detection function, you are using pix[0] and pix[2], like in my yuyv version, but in uyvy, you should use pix[1] and pix[3], since that is where the luma info is stored in this case.

also, I think it would be better to implement the yuyv and uyvy functions as the same function, using only using the format to choose the indexes differently, since otherwise, the behavior should be identical (and that way, it won't duplicate large portions of the code).

shjackal commented 10 years ago

You are completely right. That's at least my first error :) That's the function i didn't find a thing to change for my UYVY format. I changed it now, but it still doesn't work, Seems like i have some more problems in the code.

Sure that would be the easiest way. but since i didn't really understand the whole code, and didn't want to make things worse, i started with additional functions :)

shjackal commented 10 years ago

Hmm, i'm stuck now. I can't find anymore clues what's not working. Is there anything to change for the resolution too?

shjackal commented 10 years ago

Hmm, ok, got it working. When i just change the original yuyv functions (Component Index, and crop function pix[0] --> pix[1] and pix[2] -> pix[3]) it works. No idea why it didn't work with my seperate functions. Anyway it works for me now, but it seems as i don't understand the code good enough to implement it so both UYVY and YUYV would work.

gkaindl commented 10 years ago

@shjackal could you please still push your changes to your fork? I don't have an STK1160-powered grabber myself, but if I can see some working code, I can maybe hack "official" support for it into my ambi-tv branch.

rcdev67 commented 10 years ago

Hi,

i tried these modifications too, but they have no affect. Hardware is functional, Leds are lightning and mplayer shows me the grabbed tv-picture. I modified the code as described for the uyvy but nothing happens. please could you describe it once again. thank you ! and many thanks to gkaindl for this great challenge !!

cu Andreas

shjackal commented 10 years ago

Sure :-) i Uploaded my video-fmt.c on my fork. Would be nice if you could implement it "correctly" :)

@af6767 you can try it with my code. you just need my video-fmt.c although - it's just a dirty hack. (https://github.com/shjackal/ambi-tv)

rcdev67 commented 10 years ago

@shjackal Hey, thank you, you make my day :-) I have made these changes but only with your complete video-fmt.c it works !! again, thank you !!

shjackal commented 10 years ago

@af6767 No Problem :)

duenorh commented 10 years ago

I have the same problem as shjackal. I have the stk1160 dongle that outputs 640x480 and crops my picture to tight. I've tried to compile with shjackals video-fmt.c file but nothing changes.

pete111 commented 10 years ago

Hello, please help I followed MrJohns42's steps (below) with my easycap dc60 stk1160 grabber. But when I run "mplayer tv:// -tv device=/dev/video0 -hardframedrop" I am getting green picture (or in top part some noise without images). How did you make your stk1160 grabbing right video?

What am I doing wrong? Please help

Steps: Install Debian Wheezy on SD card (2013-07-26) Run raspi-config, Expand the root file system (expand_rootfs), Configure password, keyboard, locale, timezone, ssh if you want sudo apt-get install git-core git clone https://github.com/gkaindl/ambi-tv.git ambi-tv cd ambi-tv/misc && sudo bash get-kernel-source.sh cd usbtv-driver && make sudo mkdir /lib/modules/3.6.11+/extra sudo cp usbtv.ko /lib/modules/3.6.11+/extra/ sudo depmod 3.6.11+ sudo modprobe videobuf2_core sudo modprobe videobuf2_vmalloc sudo modprobe usbtv Check that video0 is in /dev (if it’s not, STOP, come back here and ask for help) Add videobuf2_core, videobuf2_vmalloc, and usbtv to /etc/modules Check for spidev0.0 in /dev (if it’s there, skip the next 2 steps) Open /etc/modprobe.d/raspi-blacklist.conf and comment out ” blacklist spi-bcm2708” with a #. sudo reboot Check for spidev0.0 in /dev (if it’s not, STOP, come back here and ask for help) cd to the main ambi-tv folder you cloned make Create a copy of sample.conf and save as etc/ambi-tv.conf. Configure as necessary Try running bin/ambi-tv Use sudo if required, otherwise, change permissions of the offending file with chmod Add the full path to the ambi-tv executable to /etc/rc.local if you want it to run on startup

pete111 commented 10 years ago

wohooo, I found out it is problem with power. Raspberry pi is not strong enough to power usb easycap directly. When I use powered usb hub it works! :) Well, so the last problem is - leds are about 0,5-1s slower than image on my screen. Any idea? Many thanks

Phil1988 commented 10 years ago

I would say I found it out and told you :D

post your complete config.. (the config file and the system settings ... is your Pi oced?) maybe we can find the delay problem

fluxa commented 10 years ago

hey @shjackal, thanks for the fix for the STK1160 (640x480 UYVY) :), it's working almost perfect for me. I just have one issue, it seems that the Green and Red colors are swapped (see photo), Blue looks fine. Is anybody having this problem? Thanks!

img_20140301_225220 img_20140301_232714

fluxa commented 10 years ago

Just did a very small change on the yuv_to_rgb function in video-fmt.c and now colors mapped correctly.

*r = (unsigned char)rgb[1];
*g = (unsigned char)rgb[0];
*b = (unsigned char)rgb[2];