How to decode and capture composite video screenshot? - Page 1
Forum section: electronics / projects

author: Victoria
author_rank: Newbie
timestamp: March 02, 2024, 05:12:35 pm
content: Hi,we have Comelit intercoms with composite video camera at the main entrance of our house. The intercom inside has one pin CBVS, which is supposed to be composite input (I guess PAL as these products are mainly popular in Europe). That's been discussed here:https://github.com/plusvic/simplebus2-intercom/issues/7I'm looking for a way to decode the composite video input (convert to some digital format), capture one screenshot that I can process later on an MCU (ESP32).What would be the simplest, cheapest solution to capture and digitize one frame from a composite video signal (PAL)?I have seen some video decoder ICs doing this job, but they are multichannel and relatively complex. Isn't there an ideal IC with one video input and one I2S output or so?P.S. I'm a total noob in analog video stuff (can do some programming stuff), so forgive me to ask how to digitilize composite video in a simplest way..Thank you

author: wasedadoc
author_rank: Super Contributor
timestamp: March 02, 2024, 05:19:08 pm
content: There are lots of USB video grabbers.

author: Victoria
author_rank: Newbie
timestamp: March 02, 2024, 05:26:35 pm
content: Thank you. I have noticed such devices, but my overall aim is to send a screenshot when somebody rings the bell over ESP32. And grabbing video stream from USB stick into ESP32 would be probably more challenging than learning how to use those decoder ICs.That's why I'm hoping for some easier decoder which can be used along with MCU.

author: Benta
author_rank: Super Contributor
timestamp: March 02, 2024, 10:11:46 pm
content: This is a complex task.No, there are no ICs that will do this for you.The USB video grabbers are just A/D converters that will send some non-standard digitized samples to your PC, and leave all the processing to custom (closed-source) software, which will then generate an MPEG-2 (or MPEG-4) stream.There is one exception I know of in the consumer realm, but it is obsolete since 10+ years, which is the "Terratec Grabster AV400".This contains a very advanced Conexant chipset that does all video processing plus MPEG-2 encoding and emits a standardized USB MPEG-2 stream to eg, VLC or any other video software. No need for special drivers.If you're lucky, you'll find one on eBay.Frankly, the easy way is to place a BT/WLAN still camera at your door and use that instead.

author: c64
author_rank: Frequent Contributor
timestamp: March 02, 2024, 10:55:43 pm
content: What's wrong with video decoder IC? You will get YCbCr + clock, which you can capture with your ESP32 gpio pins (assuming it can capture at this rate).YCbCr is usually 10bit, but you can drop few LSB to save few pins.If you don't need color, you can discard color information and only use Y component.

author: Victoria
author_rank: Newbie
timestamp: March 03, 2024, 12:14:20 am
content: Quote from: c64 on March 02, 2024, 10:55:43 pmThank you. Sounds easy. Yet I need to study the whole format (so like standard output of video decoders ICs is YCbCr + clock?), and I did not find a suitable IC yet. On the ESP, 10 pins plus a few to control the IC I could dedicate.And I just need one image, not a stream, so the idea would be when the bell rings, I would wake up the decoder chip, wait for it to give the ESP some sort of "new frame" interrupt, read the data stream for exactly one frame and put the decoder to sleep. Then I would build e.g. JPEG from it (reshuffle the buffer I guess) and do whatever else with it. That's the concept.I have seen this project, but I don't have computer by hand, so I can't see the schematics (and cannot open it online, don't know why), but the TVP5150PBS decoder looks "not so complex" at least for the number of pins and functions I have seen at some others (it is out of stock):https://github.com/11tools/esp32cvbscamWhat I'm missing is:Is there an off the shelf decoder IC which would ideally just let itself wake up (with no extra settings needed) which would, when available, generate "new frame" interrupt and spit out the data stream (which I would buffer until next "new frame" interrupt)? Or even better, cache one frame for me (with that I would not need to worry about the I/O performance)?

author: c64
author_rank: Frequent Contributor
timestamp: March 03, 2024, 12:29:10 am
content: You can still buy TVP5150 @ digikey/mouserAlso, you can check Analog Devices, they has quite an extensive range of video decoders

author: c64
author_rank: Frequent Contributor
timestamp: March 03, 2024, 12:32:56 am
content: Quote from: Victoria on March 03, 2024, 12:14:20 amI don't think so. Maybe some unknown manufacturer in China, for some very niche application. Which means no reasonable quality datasheet. You much faster can learn and do it yourself.

author: BrianHG
author_rank: Super Contributor
timestamp: March 03, 2024, 12:35:06 am
content: I used to use the ADV7182/ADV7183 for my composite/s-video/component video inputs for my video scaler. It is a premium IC meaning around 10-15$, but all you need is a crystal and some caps, set a few I2C controls and it will deliver the rest for you.

author: Someone
author_rank: Super Contributor
timestamp: March 03, 2024, 12:51:19 am
content: Video doesnt wait to be leisurely processed. Somewhere in the system you are going to be spending $$ and or resources for a frame buffer that can collect the video at its native rate.Probably cheaper off switching to some camera module that already has the interface + speed you want.

author: globoy
author_rank: Frequent Contributor
timestamp: March 03, 2024, 05:37:19 pm
content: I'm not sure if this project will be helpful or not but here's someone doing something similar with NTSC.https://github.com/wooky/esp32-analog-video-over-wifi

author: Victoria
author_rank: Newbie
timestamp: March 03, 2024, 07:38:06 pm
content: Thank you, but no, it's an empty project.However, I may seem to be lucky. If I use TVP5150, I can get YCbCr 4:2:2 component video which seems to be provided among other formats by cameras like OV7725, which is supported by theESP32 Camera Driver. It comes even with frame to JPEG conversion example.Of course, I need to check the pin connection difference and modify the I2C communication because those cameras are certainly controlled in a different way than TVP5150. But the output data stream seems to be the same, so as a starting point I would choose this.

author: macboy
author_rank: Super Contributor
timestamp: March 06, 2024, 03:17:31 am
content: You will expend tremendous effort building hardware and firmware for this. You can accomplish the task much more easily with a raspberry Pi zero W (under $10) and a cheap USB frame grabber (also under $10), plus Linux, some basic free OS software, and some relatively simple scripts.

author: Victoria
author_rank: Newbie
timestamp: March 08, 2024, 05:23:31 pm
content: True. It seems to be complex stuff. Hence I'm considering even giving up on this entirely. It's for the person on the wheelchair and opening the main entrance door to a stranger is not unusual for the fluctuation of people in their house, so I'm thinking to just add camera to the peephole at the flat door (even if it's prohibited here).

author: tooki
author_rank: Super Contributor
timestamp: March 08, 2024, 05:47:41 pm
content: Quote from: macboy on March 06, 2024, 03:17:31 amI was just going to suggest exactly this.

author: inse
author_rank: Super Contributor
timestamp: March 08, 2024, 07:46:03 pm
content: Pointing a camera (module) at the existing display is no solution?

author: Victoria
author_rank: Newbie
timestamp: March 11, 2024, 02:43:10 pm
content: There's no space for that on the opposite wall. I was considering even intercepting the lane between decoder and display and transmit that, but have not investigated this.

author: soldar
author_rank: Super Contributor
timestamp: March 11, 2024, 08:28:34 pm
content: Quote from: Victoria on March 02, 2024, 05:12:35 pmNot easy and probably not worth the trouble.PAL carries analog luminance, line by line, and color info separately. If you can do without the color then digitizing to create a bitmap should be doable if your HW is fast enough.576 lines x 576 * 4 / 3 = 442368 pixelsShould not be to difficult to digitize. Now, if you want color and you want to convert to some compression scheme ike JPG then it becomes exponentially more complicated and not worth it.You can get IP cams for close to nothing these days so I really do not see the how this is practical. But if you want to do it it could be done.IP cams, recorders, etc are so cheap I have several just lying around to play with. And have several outside so I can see all around the house.

author: Nominal Animal
author_rank: Super Contributor
timestamp: March 11, 2024, 11:52:02 pm
content: Renesas/Intersil TW9990 and TW9992 are composite video decoder ICs available in singles from Mouser for 6-7€.TW9990 has 8-bit 4:2:2 YCbCr parallel digital output, and TW9992 MIPI output (CSI-2).Something like ESP32-P4 should work with TW9992. With TW9990, you'd need 8-bit parallel data input plus sync signal inputs, and sufficient RAM for a full frame (something like 768 pixels per scan line, only part of which will contain data, and 625 scan lines for a full frame).I would go for one of the really small Linux SBCs, perhaps an Orange Pi Zero 2W (~20€ from AliExpress), NanoPi NEO LTS or NanoPi NEO Air ($15 to $25 from FriendlyElec), instead, with one of the $10-$20 eBay EzCap composite video to USB 2 capture devices that advertise Linux compatibility. I avoid Raspberry Pis because of their hardware USB is faulty and I just don't like how the Foundation operates. They have additional GPIO pins available you can use for an external relay for handling the door button. For something like $50/50€ for a device with upstream Debian/Armbian support, this would make for a quite compact unit that would not consume too much power either.The video interface will be USB Video, which means a large set of standard Linux UVC utilities will work for both video and for individual image capture. You can also run Nginx or Apache as your https server over WiFi on the SBC, allowing secure access to the SBC from e.g. your phone without relying on cloud services. With a bit of help fromffmpeg, you could even stream the audio and video to the web page (and audio back to the door phone), with a door opening button, assuming you do the security correctly (either client and server certificates, or IP-tied cookie-based user password authentication).