- Transmit a NTSC signal captured by a CCTV camera over Wi-Fi to a central monitoring server
- Reduce bandwidth for transmission, as a raw BT.601/BT.656 stream requires a bandwidth of 216Mbps, which is unacceptable even over LAN
- Minimize costs per converter/transmitter
- Any NTSC composite camera - in my case, I have a handful of Bosch VDC-455V04-20 CCTV cameras
- NTSC-M digital video decoder - whatever the cheapest you can find on eBay, e.g.
- TW9900
- AK8859VN
- GM7150BC
- ESP32 module with >=1MB pSRAM - ESP32's SRAM is not big enough to store even a single frame
- Various power supplies and/or voltage regulators required to power the decoder/ESP32
- Additional components as required by the decoder/ESP32
- Compliant BT.601 output
- Has I²C interface (AKA two wire serial interface)
- Can output synced, hsync, vsync signals
- Ability to remove hsync/vsync, SAV/EAV signals from transmission
+-----------+
| AIN | <---- () Analog NTSC composite video
| |
| | +---------------+
| SCLK | <---- | I2C_SCL |
| SDAT | <---> | I2C_SDA |
| | | |
| DCLK | ----> | I2S0I_WS_in |
| SYNC (EN) | ----> | I2S0_H_ENABLE |
| HSYNC | ----> | I2S0_H_SYNC |
| VSYNC | ----> | I2S0_V_SYNC |
| DATA[7:0] | ----> | I2S0I_Data_in |
+-----------+ +---------------+
- Set up logging
- Set up Wi-Fi
- Set up I²S transfer
- This includes allocating enough DMA RAM for one line of data
- Invert HSYNC/VSYNC/enable signals in software if necessary
- Allocate enough RAM on pSRAM for one complete frame
- Set up decoder
- Wait until client has connected
- Start decoder
- Wait until signal is syncronized so data transfer can begin
- When HSYNC is active:
- Copy the line data to pSRAM, swapping BT.601's
CbY0CrY1
data order to the JPEG library'sY0CbY1Cr
expected input - Remember that since the signal is interlaced, copy into rows 1, 3, 5, ..., and then to rows 2, 4, 6, ...
- In the event this copying takes longer than HSYNC, allocate a second DMA RAM chunk for the next line
- Copy the line data to pSRAM, swapping BT.601's
- When VSYNC is reached, repeat step 7, but prepare to copy field 2 (even rows)
- On the next VSYNC:
- Call the JPEG library to convert the resulting YUV frame to JPEG
- Transfer result, along with headers, over Wi-Fi
- If this takes longer than the VBLANK period, offload these tasks to the second core.
- If the conversion is not done before end of VBLANK period, create another buffer for the frame on pSRAM
- Go to step 8, waiting until VBLANK is done