High-speed continuous data streaming to PC (analog video) - Page 1
Forum section: electronics / projects

author: Novgorod
author_rank: Contributor
timestamp: October 28, 2021, 11:47:40 am
content: Hi,I'm playing with the idea to make "my own" analog video capture device for archiving old videotapes because virtually everything on the market for this purpose is garbage except maybe for professional equipment in the multi-thousand-dollar range or some ancient XP-era ATI capture cards that can only be found in landfills. The typical Chinese USB video dongles use the worst quality decoders and don't allow to control any decoder settings or access the raw data.On the other hand, decent-quality composite/S-video NTSC/PAL decoder chips are ubiquitous and quite cheap, since they are still used in modern TVs and projectors as legacy video inputs, for example a chip like theTI TVP5150AM1that costs around 6 bucks. There are also a bunch of other inexpensive high-quality decoder chips on the market (mainly from AD and TI). Even the most basic decoder chips have an impressive range of adjustability via an I²C interface and output the digital pixel data over an 8bit or 16bit parallel bus at 27MHz or 13.5MHz, respectively (that's for standard 4:2:2 encoding; some chips support 4:4:4 which only makes sense with a true RGB source).All I need to do is configure the chip via I²C and stream the digital image data to the PC, which is the challenging part. The maximum data rate is around 30 MByte/s, which should be just within the USB 2.0 capability (including overhead), but I don't know where to begin with the interface controller. I don't need to implement any video capture device standards on the PC side, it's enough to just get the continuous raw pixel data stream via USB into a memory buffer on the PC and write the contents to disk and/or display the video. Is there a general-purpose USB 2.0 interface chip I can use for that, which provides an I²C bus to communicate with the decoder chip and also packages the pixel data into USB frames at the required speed? A microcontroller is maybe the best choice, but which one would be fast enough?I also thought of misappropriating a cheap logic analyzer for capturing the signal, but it seems like they can only store some number of samples in local memory and then send the memory contents to the PC afterwards, so they can't be used for continuous (i.e. uninterrupted) streaming at this kind of data rates. For a brief moment I was even contemplating whether it's possible to brute-force capture the video signal with a fast ADC and do all the decoding entirely in software - it wouldn't take a lot more data bandwidth than transferring the digitized pixels, but ADC devices made for this speed (basically oscilloscopes) are just never capable of continuous streaming to a high-speed peripherial port (USB, ethernet) or mass storage.

author: oPossum
author_rank: Super Contributor
timestamp: October 28, 2021, 11:57:26 am
content: https://www.cypress.com/products/universal-serial-bus-usb?redirId=140341#tab8https://www.cypress.com/products/universal-serial-bus-usb?redirId=140341#tab9SX3 & FXG2

author: NiHaoMike
author_rank: Super Contributor
timestamp: October 28, 2021, 01:38:28 pm
content: Take a look at SDRs that have baseband inputs. If you mod the VCR to bring out the raw head signals (buffered using high speed opamps), it would simplify things since you won't have to get one that goes down to near DC, plus you can try all sorts of post processing to get better image quality than what the old analog electronics can achieve.http://repairfaq.org/sam/vcrfaq.htm#vcrvhsvidQuote

author: Benta
author_rank: Super Contributor
timestamp: October 28, 2021, 03:41:49 pm
content: I agree that 99% of the video grabbers on the market are absolute garbage. The dongle just contains a video/audio ADC and streams the raw video/audio data over USB and leaves all the processing to the PC.There are a couple of exceptions though, that are very rare (no longer manufactured), but with luck can be found on eBay or sinilar sites.They are the Terratec Grabster AV400 and AV450. I own a handful, all bought for US$ 30...50. Price new was around US$ 120.So what's special about those two?: they are based on a brilliant Conexant chip set that contains all analog and digital video and audio processing, plus a complete MPEG-2 encoder.Inputs: Audio L+R, CVBS and S-video.Output: an MPEG-2 USB stream that can be opened directly with VLC, streamed to your HDD or whatever you like. No drivers or special software needed.

author: HB9EVI
author_rank: Frequent Contributor
timestamp: October 28, 2021, 03:54:53 pm
content: for this purpose I still have a Hauppauge WinTV PVR-350 in an older legacy configuration PCnothing fancy, just doing what it should

author: BrianHG
author_rank: Super Contributor
timestamp: October 28, 2021, 07:55:01 pm
content: In the past, the best quality sampler, especially for non-time based corrected signals like those from videotape was actually Sony's Digital 8 cameras which has Composite/S-Video inputs with a fire-wire output. Sony designed the sampling chipset with 4 line adaptive comb decoder for the composite video sources and also designed the PLL clocking with analog video tape in mind as they knew many bought these cameras just to sample video into their PCs.Look around on ebay and you may find a deal where the cassette mechanism may have problems but the sampling to fire-wire still works. Though, fire-wire ports may be a problem.As for you sampling raw video just to do the best possible composite video decode, as a project, this can be a chore. Worse if you want to sample from analog videotape as sample clocking will be all f-ed up.As for using sampler IC for Composite video, like the TI you mentioned, they all behave in a bad manner with analog videotape. The best one I found is analog devices ADV7188. It has a built in line-by-line time based corrector and outputs the standard 27MHz/13.5MHz 480p. So be warned, if you want good VTC sampling, you must use the exact crystal specified in the datasheet. I don't mean just the frequency, I mean the crystal mode and loading capacitance. If you want quality, just ignore TI and go straight to the ADV7188.Your TI TVP5150AM1 chip is a toy and it's crap. And don't even bother with an 9bit adc and crap 8bit output is you want to do effective picture processing. It is a waste of your time and you might as well search for the best 10$ sampler available on Amazon.

author: Benta
author_rank: Super Contributor
timestamp: October 28, 2021, 08:15:09 pm
content: I am on the same page as BrianHG.Which is why I proposed the Terratec Grabsters as a one-off possibility.The chipset is Conexant CX23416 and CX25836/7, which are absolutely brilliant ICs. The picture quality can't really be better when digitized. This also goes for VHS.Unfortunately, I think they are obsolete.EDIT: I just found this, which blew my pants off:https://www.globalsources.com/si/AS/Yuan-High-Tech/6008803970048/pdtl/Conexant-CX23416-USB-2-0-Hardware-MPEG2-Encoder/1028480440.htmEDIT 2: Oh well, seems to be just as obsolete as the Terratec version. Same hardware, different case.

author: NiHaoMike
author_rank: Super Contributor
timestamp: October 28, 2021, 10:35:32 pm
content: Quote from: Benta on October 28, 2021, 03:41:49 pmFor archival purposes, a good quality ADC streaming the raw samples to the PC is exactly what you want! Any post processing is best done in software so you can determine if it really does make things look better or not. Certainly beats trying to undo an "enhancement" that backfired on that particular content.

author: BrianHG
author_rank: Super Contributor
timestamp: October 28, 2021, 10:56:16 pm
content: The 'ADV7188' supports raw ADC through with clock locking and TBC enable or disabled.I confirmed I have at least 1 home-made dev board remaining with 5v in, flex cable data out.2-SVideo, 5 BNC connectors.

author: Benta
author_rank: Super Contributor
timestamp: October 28, 2021, 10:57:39 pm
content: Quote from: NiHaoMike on October 28, 2021, 10:35:32 pmI can follow your thinking. But what's on the market as "Video-dongles" is total crap.And concerning post-processing, I see a problem with "raw" formats and what they even are. But OK, if someone has the muse to go into this, fine.It can be solved, if you know the raw data format.

author: dmendesf
author_rank: Frequent Contributor
timestamp: October 28, 2021, 10:58:41 pm
content: If you wanna go the conexant way:www.ebay.com/itm/Sony-captura-de-video-editar-cartao-PCI-PCVA-IMB5A-22ENX-26-ENX-26-CX23416-12-/200881792492?mkcid=16&mkevt=1&_trksid=p2349624.m46890.l49286&mkrid=711-127632-2357-0Else if you want to stick with your original plan you have 2 options: the cypress 8051+FIFO (can put the i2c+datastream in a single IC, but a lot of programming is needed) or else the FTDI way (+something else to program the I2C).The FTDI can only stream at 30mb/s in a master FIFO mode, and usually you need a FPGA to drive that BUT the newest STM32 have a periferal called parallel slave port that SEEMS a perfect fit for it (didn't try yet).

author: NiHaoMike
author_rank: Super Contributor
timestamp: October 29, 2021, 12:58:39 am
content: Quote from: Benta on October 28, 2021, 10:57:39 pmBasically like a WAV file, but at a much higher sample rate. They're very common when working with SDR.

author: Novgorod
author_rank: Contributor
timestamp: October 29, 2021, 08:41:24 am
content: Thanks for the suggestions, it's all very helpful. It seems like data streaming should be possible with a Cypress or FTDI module (FTDI can do 40Mbyte/s FIFO over USB 2.0 apparently). It will require some substantial hardware and software development, so let's see if I ever find enough time to materialize it...Quote from: NiHaoMike on October 28, 2021, 01:38:28 pmS-video does exactly that without having to tinker with the VCR. It outputs luma (Y) and chroma (C) separately so they can be processed independently. The SDR approach would only help with the chroma signal because it's QAM modulated onto a subcarrier above the luma frequencies, but you need some logic/circuitry to recover the phase from the burst pulse on each line. And the luma (Y) signal still needs real-time sampling because it's basically an oscilloscope signal of the pixel brightness. Effectively, this approach will only reduce the required analog sampling bandwidth a bit (since only the Y has to be sampled), which still requires 10s of Msamples/s.Quote from: Benta on October 28, 2021, 03:41:49 pmThe on-chip digital encoders are a bit of a hit-or-miss (mostly the latter). The MPEG2 encoders usually encode to some low-bitrate DVB or DVD standard for convenience and won't let you adjust the bitrate or access the raw data. For archiving I would use h264 at a high bitrate, but do some processing (deinterlacing, geometry, maybe some other filters) on the uncompressed image, so it's important to get the raw RGB (or YUV) stream to the PC. There are modern versions of these transcoder boxes which record from HDMI into an mp4 format onto a USB drive (and can be used for example with an analog to HDMI upscaler), but they also offer little to no configurability.Quote from: BrianHG on October 28, 2021, 07:55:01 pmThat's interesting. I know they could play back analog Hi 8 tapes, but I wasn't aware the cameras could digitize the signal, or even have external video inputs. I might be able to borrow one from some old people, so I'll check it out..QuoteThat was just an example for the data transfer requirements and standards. A few bucks more for a better quality chip like the ADV7188 won't be a problem, but they all have the same type of data output bus. Also, what's wrong with an 8bit output bus? The encoding is still effectively 16bit per pixel (4:2:2), it's just transferred at double the rate of a 16bit bus and the USB FIFO thingies use 8bit anyway. Or are you referring to a higher pixel bit depth (HDR?) or no chroma subsampling (like 4:4:4)? That sampling quality doesn't make much sense for VHS and would be far beyond USB 2.0 transfer speeds.QuoteHow much?Quote from: NiHaoMike on October 29, 2021, 12:58:39 amCan these SDR boards stream about 30 Msamples/s continuously to a PC?

author: BrianHG
author_rank: Super Contributor
timestamp: October 29, 2021, 10:11:16 am
content: NTSC is 20bit per pixel, not 16. Especially with low bandwidth VHS, you do not want those fine contours around soft edge objects like what you get with cheap .264 lower bitrate junk. .265 10bit is the norm today.The chroma bandwidth is 50% that of the Luma, so 4:2:2 is fine. On analog VHS, this is actually even worse having something like 100 lines of resolution for the color.

author: NiHaoMike
author_rank: Super Contributor
timestamp: October 29, 2021, 01:34:20 pm
content: Quote from: Novgorod on October 29, 2021, 08:41:24 amVHS uses a FM carrier around 3.4MHz and an AM carrier around 629kHz. If you capture the raw signal, you can decode those in software and bypass most of the analog electronics in the VCR.QuoteThe ones that can do wideband will do that easily.

author: Novgorod
author_rank: Contributor
timestamp: October 29, 2021, 02:49:02 pm
content: Quote from: BrianHG on October 29, 2021, 10:11:16 amI was referring to the digital uncompressed 4:2:2 output stream, something like BT.656. Each component (Y, Cb, Cr) is digitized with 8bit (or 10bit if it's really fancy), making it 24bit (or 30bit) per pixel. The 4:2:2 chroma subsampling reduces it effectively to 16 bits per pixel in terms of data rate, not in terms of quantization.Quote from: NiHaoMike on October 29, 2021, 01:34:20 pmAny example? Capturing the raw VHS signal the way it comes from the tape or the recovered composite/S-video PAL/NTSC signal requires about the same hardware in terms of bandwidth and sampling rate.

author: Benta
author_rank: Super Contributor
timestamp: October 29, 2021, 03:56:33 pm
content: Quote from: Novgorod on October 29, 2021, 08:41:24 amThis is not the advantage that you might think it is. After digitizing lots of VHS tapes, I can say that the results are better using CVBS rather than S-Video.S-Video is excellent as output directly from the source (eg, video camera), where the Y and C signals are generated directly. In a VCR, S-Video is generated by splitting the composite, which leads to degradation.

author: BrianHG
author_rank: Super Contributor
timestamp: October 29, 2021, 05:02:04 pm
content: Quote from: Benta on October 29, 2021, 03:56:33 pmThe chroma and luma are recorded on a VHS tape with different sub-carriers as 2 distinct signals. Having an S-VHS play a VHS cassette whose circuitry keeps the 2 separate from tape all the way to feeding your sampler is a plus. Especially for commercially made tapes which were mastered from separated Y/C all the way through the pipeline. However, we now come to the quality of the player. Later in the analog videotape players, players with a technology called 'perfect tape' came out where some of the better ones, not by price, roasted the playback quality (not necessarily the record quality or sound quality) of even the old top prosumer/commercial decks. This tech was a digital sampler which sampler the RF coming from the video head and software rendered the best possible NTSC signal. It looked at the relative signal strengths and decoded sync quality to 'equalize' the playback bandwidth at multiple frequency points to deliver the most sharp, but yet without making contrast bars surrounding image boarders. These decks where never released in S-Video, but, using them to sample from will still reveal the best picture if the tape mechanics is up to par.

author: Novgorod
author_rank: Contributor
timestamp: October 29, 2021, 05:03:00 pm
content: Quote from: Benta on October 29, 2021, 03:56:33 pmAre you sure about that? A VHS tape doesn't store a CVBS signal, it uses different bands, bandwidths and modulation methods for the Y and C components, so they have to be demodulated and processed separately before being combined into a CVBS output signal. If the VCR or camera has an S-video output for tape playback, it can simply output the demodulated/converted Y and C components before they are mixed together. I understand that the VHS source is still a "composite" signal, but it has to be split in Y and C by the player in order to output PAL/NTSC compatible video (S-video or CVBS) - unless you can somehow digitize the raw VHS signal itself and decode it on the PC like the other dude suggested.What you're saying would make sense for a cable or antenna receiver where a CVBS signal is directly demodulated by the tuner, and even then it's just a matter of whether your digitizer chip has a better composite splitter than the source device.

author: BrianHG
author_rank: Super Contributor
timestamp: October 29, 2021, 05:17:50 pm
content: Novgorod, you are correct.Composite samplers have some additional filtering when they split the composite. Maybe this is why Benta saw a better picture when sampling composite instead of s-video as s-video revealed more junk from his source signal and some samplers in composite mode also add some edge enhancement processing to help deal with dot-crawl when the filter out the 3.58MHz band. I've also seen PC video grabbers which do not turn off this filtering feature even when grabbing S-Video loosing definition when sampling high-resolution S-Video.

author: Benta
author_rank: Super Contributor
timestamp: October 29, 2021, 06:49:45 pm
content: You may be right, concerning CVBS vs. S-Video quality differences. Mind you, I've only worked with PAL.My observations are purely from practically doing the digitizing, I never made the effort to analyze the problem fully.

author: NiHaoMike
author_rank: Super Contributor
timestamp: October 30, 2021, 02:07:20 am
content: Quote from: Novgorod on October 29, 2021, 02:49:02 pm"MSI.SDR" is a relatively cheap one that should work. Its 10kHz lower limit won't work for capturing composite video, but capturing the raw signal from the heads will work. Note that like most SDRs, it uses "quadrature sampling" which means that each sample is in fact equivalent to two samples from a single ADC.

author: nichga
author_rank: Newbie
timestamp: October 31, 2021, 04:44:13 am
content: what is your technical backgroundherehttps://en.wikipedia.org/wiki/Ferroelectricity

author: mariush
author_rank: Super Contributor
timestamp: October 31, 2021, 06:56:43 am
content: I used to capture and record with a Leadtek Winfast 2000 XP Expert tv tuner card, which had a good Conexant chipset (something higher end, 10 bit adc or something like that).It supported raw capture in VirtualDub so it was perfectly fine for recording vhs tapes.Stopped using it because it was PCI and because it doesn't pass audio through the pci slot, you had to use a analogue CD cable to connect the tuner to the CD in header on the sound card or motherboard onboard audio cd in header. (or make your own CD out on tuner card - line in stereo jack)But ... it was sold in enough volume that it pops up from time to time on eBay at reasonable prices ... just have to be careful to actually get the "expert" model, as the "deluxe" or other models had a more common less good chip.

author: Novgorod
author_rank: Contributor
timestamp: November 29, 2021, 02:27:14 am
content: Quote from: NiHaoMike on October 30, 2021, 02:07:20 amIt's been a while (not the highest priority project), so I've looked a bit into SDRs and I'm baffled how they can pack a pair of 10Ms/s or faster ADCs (for I/Q) with 12bit or more and an apparently fast enough USB interface (and all the RF demodulation stuff) in a small box for such a cheap price!That's insane considering what e.g. the typical National Instruments ADC interfaces cost with nowhere near the specs (I know, they are primarily made for "vertical" dynamic range/resolution/linearity and not speed, but still)...So with a suitable SDR I could either try to capture the VHS signal directly from the heads, possibly screw up the impedance matching and signal levels, have to demodulate and decode the (probably) undocumented VHS format to somehow recover a non-standard version of the PAL/NTSC video and then decode that and hope not to do it worse than the dedicated hardware in the player. Or alternatively, my first thought was to hack the SDR and put the S-video signal directly onto the ADCs (since there are 2 of them anyway) and bypass the entire RF chain, since the lower frequency limit is from the IF mixing/filtering and not from the ADCs (right?). If you ignore the whole RF part, the SDR should be just a dual high-speed ADC with a convenient USB interface and it should be possible to record the raw ADC streams (I assume). Would that work and is it a thing to use SDRs as "just ADCs" because there's nothing close to it in terms of price and specs?

author: NiHaoMike
author_rank: Super Contributor
timestamp: November 29, 2021, 03:02:20 am
content: I'm not sure if it's possible to use the MSI.SDR as plain ADCs, many SDRs do a final stage of frequency domain shifting and filtering in DSP.Save the raw "I/Q" data to disk, then you have basically unlimited tries to tweak the extraction algorithms to get the best results.

author: woodchips
author_rank: Frequent Contributor
timestamp: November 29, 2021, 02:17:59 pm
content: Just looking at archiving VHS tapes and saw this thread.My experience is decades old, but moved colour PAL video to a computer by simply sampling the analogue signal and storing it to disc. This was the days of 6 bit flash converters and IDE discs. Worked. Was from a camera rather than a video player, perhaps that is the difference.Might be useful to use an 8 bit ADC but why not just do that? I am unsure as to what the fancy splitters to extract the chrominance info do for you?Once on disc, can then process to your hearts content.

author: Novgorod
author_rank: Contributor
timestamp: November 29, 2021, 06:43:47 pm
content: Quote from: NiHaoMike on November 29, 2021, 03:02:20 amI guess we'll find out in 2-6 weeks - I ordered one from China to play around with.. I hope all the processing is bypassable to get access to the raw ADC data. And of course I would record the raw ADC stream to disk to develop the processing tools first, but I'm still skeptical that the final result would be any better than using a dedicated chip which has a much higher internal sampling rate and all the "fine-tuned" processing.

author: Novgorod
author_rank: Contributor
timestamp: November 29, 2021, 06:55:40 pm
content: Quote from: woodchips on November 29, 2021, 02:17:59 pmEven with 6bit instead of 8 it's tens of MBytes of data per second to store a full-bandwidth composite signal. What kind of ADC and interface did you use?I don't know if I got your question right, but if it's about using S-video vs. the composite signal, it would (theoretically) improve the quality a bit when capturing from tape. Luma and chroma are demodulated from the tape signal and then processed separately by the tape player before being combined again into a composite signal. If it has S-video, you can get the separated components before they are combined into composite, so you avoid one filter step and crosstalk degradation. Of course VHS is already a kind of composite signal, so if you capture it directly from the tape head (as suggested by the other guy), you bypass the whole demodulation process inside the player and can do it all digitally. But if you only have access to the video outputs on the player, then S-video should be the better choice.

author: Novgorod
author_rank: Contributor
timestamp: January 13, 2022, 05:23:34 pm
content: Just a final note on this (for now): After a bit of digging, I found the"Domesday project", which is very close to what I'm looking for. They designed a 10bit 40Ms/s digitizer for continuous streaming (including a FPGA and USB3.0 board) with the main purpose to digitize the RF signal directly from a laser disc head and do the entire RF to Y/C to RGB decoding in software. The software project has a fork for decoding VHS RF (calledVHS-decode) which produces very decent results already, including color, and is in active development, so I don't have to do it from scratch. It seems to be the superior approach compared with digitizing the composite or S-video signal, so I will give it a shot sometime when I'm free enough. There is no Hi8 support yet though (which would be more important than VHS), but that's a matter of software adaptation once the RF is recorded from the tape.