Cov txheej txheem:

Ua Si Video Nrog ESP32: 10 Cov Kauj Ruam (nrog Duab)
Ua Si Video Nrog ESP32: 10 Cov Kauj Ruam (nrog Duab)

Video: Ua Si Video Nrog ESP32: 10 Cov Kauj Ruam (nrog Duab)

Video: Ua Si Video Nrog ESP32: 10 Cov Kauj Ruam (nrog Duab)
Video: БЛИНЧИКИ НОВОГОДНИЕ САМЫЕ ВКУСНЫЕ. Блины с мясом рецепт. Мясной соус с красной икрой. 2024, Hlis ntuj nqeg
Anonim
Ua Si Video Nrog ESP32
Ua Si Video Nrog ESP32

Cov Lus Qhia no qhia qee yam txog kev ua yeeb yaj kiab thiab suab nrog ESP32.

Kauj Ruam 1: ESP32 Nta & Txwv

Nta

  • 4 SPI npav, 2 SPI npav muaj rau cov neeg siv chaw, lawv yog SPI2 thiab SPI3 lossis hu ua HSPI thiab VSPI. Ob lub npav SPI tuaj yeem khiav tau ntau tshaj 80 MHz. Hauv kev xav nws tuaj yeem thawb 320x240 16-ntsis xim pixels mus rau SPI LCD ntawm 60 fps, tab sis nws tseem tsis tau suav lub sijhawm siv nyiaj ua ntej yuav tsum tau nyeem thiab txiav txim siab cov ntaub ntawv video.
  • 1-ntsis / 4-ntsis SD npav tuaj yeem txuas daim npav SD hauv cov txheej txheem ib txwm muaj
  • I2S sab hauv DAC lub suab tso tawm
  • dhau 100 KB RAM muaj rau cov vis dis aus thiab suab tsis
  • Ncaj ncees ua lub zog kom txiav txim siab JPEG (ua si Motion JPEG) thiab LZW cov ntaub ntawv nrawm (ua si Animated GIF)
  • Dual-core version tuaj yeem faib nyeem cov ntaub ntawv los ntawm SD daim npav, txiav txim siab thiab thawb rau SPI LCD mus rau ntau txoj haujlwm sib luag thiab txhawb kev ua haujlwm rov ua haujlwm

Txwv

  • tsis txaus RAM sab hauv kom muaj ob chav thav duab tsis rau 320x240 hauv 16-xim xim, nws txwv kev ua haujlwm ntau yam. Nws tuaj yeem kov yeej me ntsis nrog PSRAM sab nraud txawm hais tias nws qeeb dua RAM sab hauv
  • tsis txaus ua lub zog txiav txim siab mp4 video
  • tsis yog txhua qhov ESP32 version muaj 2 tus tub ntxhais, cov qauv ua haujlwm ntau yam tsuas yog tau txais txiaj ntsig ntawm dual-core version

Ref.:

Kauj ruam 2: Hom Video

RGB565

Los yog hu ua 16-ntsis xim yog cov ntaub ntawv raw cov ntaub ntawv feem ntau siv ntawm kev sib txuas lus ntawm MCU thiab xim xim. Txhua lub xim pixel sawv cev los ntawm tus nqi 16-ntsis, thawj 5-ntsis yog tus nqi liab, tom qab 6-ntsis yog tus nqi ntsuab thiab tom qab ntawd 5-ntsis tus nqi xiav. Tus nqi 16-ntsis tuaj yeem ua rau 65536 xim sib txawv yog li nws tseem hu ua 64K xim. Yog li 1 feeb 320x240@30 fps video yuav raug qhov loj me: 16 * 320 * 240 * 30 * 60 = 2211840000 khoom = 276480000 bytes lossis ntau dua 260 MB

Animated GIF

Nov yog cov ntaub ntawv ib txwm muaj nyob hauv lub vev xaib txij li xyoo 1990. Nws txwv cov xim sib txawv rau txhua lub vijtsam txog 256 xim thiab tsis rov khaws cov pixel uas zoo ib yam xim ib yam li thav duab dhau los. Yog li nws tuaj yeem txo qis cov ntawv me me, tshwj xeeb tshaj yog thaum txhua cov duab thav duab tsis hloov pauv ntau yam. LZW kev nrawm tau tsim muaj peev xwm txiav txim siab los ntawm 1990s lub khoos phis tawj, yog li ESP32 kuj tseem muaj lub zog ua haujlwm ncaj ncees los txiav txim siab nws lub sijhawm tiag.

Tsab ntawv tsa suab JPEG

Los yog hu ua M-JPEG / MJPEG yog hom vis dis aus uas siv tau yooj yim rau kev kaw cov vis dis aus nrog lub zog ua tsawg. Qhov tseeb nws tsuas yog kev sib txuas ntawm cov duab JPEG. Sib piv nrog MPEG lossis MP4, Tsab ntawv tsa suab JPEG tsis xav tau cov txheej txheem kev suav ntau ntawm kev kwv yees cuam tshuam, txhua tus ncej yog ywj siab. Yog li nws xav tau cov peev txheej tsawg los nkag thiab txiav txim siab.

Ref.: Yog

en.wikipedia.org/wiki/List_of_monochrome_a…

en.wikipedia.org/wiki/GIF

en.wikipedia.org/wiki/Motion_JPEG

Kauj ruam 3: Suab hom

PCM

Cov ntaub ntawv nyoos rau cov suab digital. ESP32 DAC siv 16-ntsis qhov tob, uas txhais tau tias txhua 16-ntsis cov ntaub ntawv sawv cev rau cov piv txwv digital piv txwv. Feem ntau cov vis dis aus thiab nkauj feem ntau siv tus qauv piv ntawm 44100 MHz, uas txhais tau tias 44100 piv txwv cov teeb liab sib piv rau txhua ob. Yog li, 1 feeb mono audio PCM cov ntaub ntawv nyoos yuav raug qhov loj me: 16 * 44100 * 60 = 42336000 khoom = 5292000 bytes lossis ntau dua 5 MB. Qhov loj ntawm lub tso suab suab yuav yog ob npaug, piv txwv li ntau dua 10 MB

MP3

MPEG Layer 3 yog lub suab kaw suab uas siv dav rau nkauj sib dhos txij li xyoo 1990. Nws tuaj yeem txo qis cov ntaub ntawv me me kom qis dua ib feem kaum ntawm cov hom PCM nyoos

Ref.: Yog

en.wikipedia.org/wiki/Pulse-code_modulatio…

en.wikipedia.org/wiki/MP3

Kauj ruam 4: Hloov dua siab tshiab

Txoj haujlwm no siv FFmpeg hloov cov vis dis aus mus rau ESP32 hom ntawv nyeem tau.

Thov rub tawm thiab teeb tsa FFmpeg ntawm lawv lub vev xaib raug cai yog tias tseem tsis tau:

Hloov mus rau PCM suab

ffmpeg -i input.mp4 -f u16be -acodec pcm_u16le -ar 44100 -ac 1 44100_u16le.pcm

Hloov mus rau MP3 suab

ffmpeg -i input.mp4 -ar 44100 -ac 1 -q: a 9 44100.mp3

P toevod RGB565 na TWG

ffmpeg -i input.mp4 -vf "fps = 9, nplai = -1: 176: chij = lanczos, qoob loo = 220: in_h: (in_w -220)/2: 0" -c: v rawvideo -pix_fmt rgb565be 220_9fps. rgb wb

Hloov mus rau Animated GIF

ffmpeg -i input.mp4 -vf "fps = 15, nplai = -1: 176: chij = lanczos, qoob loo = 220: in_h: (in_w -220)/2: 0, phua [s0] [s1]; [s0] palettegen [p]; [s1] [p] paletteuse "-loop -1 220_15fps.gif

Hloov ua Motion JPEG

ffmpeg -i input.mp4 -vf "fps = 30, nplai = -1: 176: chij = lanczos, qoob loo = 220: in_h: (in_w -220)/2: 0" -q: v 9 220_30fps.mjpeg

Nco tseg:

FFmpeg hloov dua siab tshiab Animated-g.webp" />

Kauj Ruam 5: Kev Npaj Kho Vajtse

Kev Npaj Kho Vajtse
Kev Npaj Kho Vajtse

ESP32 Dev Board

Ib qho dual-core ESP32 dev board yuav tsum ua tau zoo, lub sijhawm no kuv siv TTGO ESP32-Micro.

Xim Zaub

Txhua yam xim uas Arduino_GFX kev txhawb nqa yuav tsum ua tau zoo, lub sijhawm no kuv tab tom siv ILI9225 pawg thawj coj tawg nrog SD daim npav qhov.

Koj tuaj yeem pom Arduino_GFX txhawb cov xim xim teev ntawm Github:

github.com/moononournation/Arduino_GFX

Daim npav SD

Txhua daim npav SD yuav tsum ua tau zoo, lub sijhawm no kuv siv SanDisk "nrawm nrawm" 8 GB micro SD nrog SD adapter.

Suab

Yog tias koj xav siv lub mloog pob ntseg nkaus xwb, tsuas yog txuas lub mloog pob ntseg pins rau tus pin 26 thiab GND tuaj yeem mloog lub suab. Lossis koj tuaj yeem siv lub tshuab me me los ua suab nrog tus hais lus.

Lwm tus

Qee lub rooj noj mov thiab cov xov tooj cua

Kauj ruam 6: SD Interface

SD Interface
SD Interface
SD Interface
SD Interface

ILI9225 LCD breakout board kuj suav nrog SD crd slot breakout pins. Nws tuaj yeem siv ua SPI npav lossis 1-ntsis SD npav. Raws li tau hais hauv kuv cov lus qhia yav dhau los, Kuv nyiam siv 1-ntsis SD npav, yog li txoj haujlwm no yuav pib ntawm 1-ntsis SD npav.

Kauj Ruam 7: Muab Nws Ua Ke

Muab tso ua ke
Muab tso ua ke
Muab tso ua ke
Muab tso ua ke
Muab tso ua ke
Muab tso ua ke

Cov duab saum toj no qhia txog kev sim platform uas kuv tab tom siv hauv txoj haujlwm no. Lub khob cij dawb yog 3D luam tawm, koj tuaj yeem rub tawm thiab luam nws ntawm yam khoom sib txawv:

Qhov kev sib txuas tiag tiag nyob ntawm qhov khoom siv twg koj muaj hauv tes.

Nov yog cov ntsiab lus sib txuas:

ESP32

Vcc -> LCD Vcc GND -> LCD GND GPIO 2 -> SD D0/MISO -> 1k resistor -> Vcc GPIO 14 -> SD CLK GPIO 15 -> SD CMD/MOSI GPIO 18 -> LCD SCK GPIO 19 -> LCD MISO GPIO 22 -> LCD LED GPIO 23 -> LCD MOSI GPIO 27 -> LCD DC/RS GPIO 33 -> LCD RST

Ref:

Kauj Ruam 8: Txoj Haujlwm

Program
Program

Arduino IDE Cov

Rub tawm thiab teeb tsa Arduino IDE yog tias koj tseem tsis tau ua nws:

www.arduino.cc/en/main/software

Txhawb ESP32

Ua raws li Cov Lus Qhia Txhim Kho ntxiv ESP32 kev txhawb nqa yog tias koj tseem tsis tau ua nws:

github.com/espressif/arduino-esp32

Arduino_GFX Library

Rub tawm cov tsev qiv ntawv Arduino_GFX tshiab kawg: (nias "Clone lossis rub tawm" -> "Download ZIP")

github.com/moononournation/Arduino_GFX

Ntshuam tsev qiv ntawv hauv Arduino IDE. (Arduino IDE "Sketch" Menu -> "Xws li Lub Tsev Qiv Ntawv" -> "Ntxiv. ZIP Library" -> xaiv rub tawm ZIP file)

ESP8266 Suab

Rub tawm ESP8266Audio cov tsev qiv ntawv tshiab kawg: (nias "Clone lossis rub tawm" -> "Download ZIP")

github.com/earlephilhower/ESP8266Audio

Ntshuam tsev qiv ntawv hauv Arduino IDE. (Arduino IDE "Sketch" Menu -> "Xws li Lub Tsev Qiv Ntawv" -> "Ntxiv. ZIP Library" -> xaiv rub tawm ZIP file)

RGB565_video Qauv Cai

Rub tawm qhov tseeb RGB565_video tus lej cim: (nias "Clone lossis rub tawm" -> "Download ZIP")

github.com/moononournation/RGB565_video

SD Card Cov Ntaub Ntawv

Luam cov ntaub ntawv hloov pauv mus rau SD daim npav thiab ntxig rau hauv daim npav daim npav LCD

Sau & Upload

  1. Qhib SDMMC_MJPEG_video_PCM_audio_dualSPI_multitask.ino hauv Arduino IDE
  2. Yog tias koj tsis siv ILI9225, hloov chav kawm tshiab (ib puag ncig kab 35) txhawm rau kho lub npe chav kawm
  3. Nias Arduino IDE "Upload" khawm
  4. Yog tias koj ua tsis tiav qhov program, sim tshem qhov kev sib txuas ntawm ESP32 GPIO 2 thiab SD D0/MISO
  5. Yog tias koj pom qhov kev taw qhia tsis raug, hloov tus nqi "kev hloov" (0-3) hauv cov chav kawm tshiab
  6. Yog tias qhov program ua haujlwm tau zoo koj tuaj yeem sim ua piv txwv pib nrog SDMMC_*
  7. Yog tias koj tsis muaj daim npav SD lossis koj tsis muaj FFmpeg teeb tsa, koj tseem tuaj yeem sim SPIFFS_* piv txwv

Kauj ruam 9: Benchmark

Qhov ntsuas
Qhov ntsuas

Nov yog cov ntsiab lus kev ua tau zoo rau cov vis dis aus sib txawv (220x176) thiab suab (44100 MHz) hom ntawv:

Hom ntawv Ncej ib ob (fps)
MJPEG + PCM 30
15
RGB565 + PCM 9
MJPEG + MP3 24

Nco tseg:

  • MJPEG + PCM tuaj yeem ncav cuag fps siab dua tab sis nws tsis tsim nyog ua si hauv lub vijtsam me me ntau dua 30 fps
  • RGB565 tsis xav tau txheej txheem txheej txheem tab sis cov ntaub ntawv loj heev thiab siv sijhawm ntau ntawm kev thauj cov ntaub ntawv los ntawm SD, 4-ntsis SD npav thiab SD daim npav sai dua tuaj yeem txhim kho nws me ntsis (kev twv ua ntej tuaj yeem ncav cuag 12 fps)
  • Cov txheej txheem txiav txim siab MP3 tseem tsis tau ua haujlwm zoo, tam sim no tau mob siab rau cov tub ntxhais 0 rau kev txiav txim siab MP3 thiab cov tub ntxhais 1 rau ua yeeb yaj kiab

Kauj ruam 10: Zoo Siab Ua Si

Zoo Siab Ua Si!
Zoo Siab Ua Si!

Tam sim no koj tuaj yeem ua yeeb yaj kiab thiab suab nrog koj ESP32, nws qhib ntau qhov muaj peev xwm!

Kuv xav tias kuv yuav ua lub TV me me vintage tom qab …

Pom zoo: