Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Play video with sound #2

Open
loboris opened this issue Aug 21, 2018 · 4 comments
Open

Play video with sound #2

loboris opened this issue Aug 21, 2018 · 4 comments

Comments

@loboris
Copy link

loboris commented Aug 21, 2018

Playing videos with sound works great if using CMD_PLAYVIDEO with OPT_SOUND, but it uses the full screen and no other graphics can be used.
Much more interesting option is using CMD_VIDEOSTART / CMD_VIDEOFRAME and it also works without issues.
The problem is, when playing the video that way, it looks there is no way to get the sound!
CMD_VIDEOSTART takes no options, I was looking everywhere and couldn't find any way to enable sound with CMD_VIDEOSTART.
It looks like FT81x designers just forgot to enable that feature. Is there any solution?

@FT81xMania
Copy link
Owner

There is no solution friend. Be a problem with the design of the FT81x chip

@Gjepali
Copy link

Gjepali commented Feb 7, 2024

Please see my repo https://github.com/Gjepali/gd23zu (it's a few years old, but I uploaded it now) - I had modified your old library primary for video playback. Your code is good, but really slow on SPI. Compare wiring.h, GD23ZU.h and GD23ZU.cpp. I tested it on F103 and F405. I tried to run it on F205, but there was problem with DMA on Arduino libraries for HAL.

  1. Turn on external crystal for FT81x for audio output - internal oscillator as usually has bad duty cycle and PWM output for audio is not clear.
  2. SPI data is sent byte by byte - DMA is much more fastest (with no delay between bytes).
  3. I'm using SdFatEX (with bigger buffer) insteed of SdFat for F103 and SdFatSdio for F405 insteed of SdFat
  4. TAM_BUFFER_SD=32768 for F405
  5. added backlight dimming support
  6. touch calibration -> stored in internal flash (eeprom emulation)
  7. MoviePlayer routine and buffer modified
  8. Arduino Code: added HAL_SD_MODULE_ENABLED in Arduino packages ...\variants<YOUR BOARD NAME>\variant.h
  9. STM32GENERIC: comment all DMA1_ChannelX_IRQ definition in STM32GENERIC-master\STM32\libraries\stm32_dma_F0F1F3L1.h -> this is multiple definition!!!
  10. STM32GENERIC: _useDMA = false; in STM32GENERIC-master\STM32\libraries\SDIO\src\SDIO.cpp - do not block DMA here!!!
  11. STM32GENERIC: in STM32GENERIC-master\STM32\libraries\SdFat\src\SdFatConfig.h change: #define ENABLE_EXTENDED_TRANSFER_CLASS 1, #define MAINTAIN_FREE_CLUSTER_COUNT 1
  12. STM32GENERIC: in STM32GENERIC-master\STM32\libraries\SDIO\src\SDIO.h uncomment lines
    #ifndef HAL_SD_CardStateTypeDef
    #define HAL_SD_CardStateTypeDef HAL_SD_CardStateTypedef
    #define HAL_SD_CardStatusTypeDef HAL_SD_CardStatusTypedef
    #endif
  13. format SD card with FAT32 and choose largest block size for better read performance
  14. use ffmpeg.exe to convert video file to MotionJPEG and mono PCM audio, but do not use full resolution !!! (example for 800x480px LCD: ffmpeg -i in.mp4 -vf eq=gamma=1,scale=790:470:force_original_aspect_ratio=decrease,pad=790:470:-1:-1:color=black -b:v 10000k -pix_fmt yuvj420p -ac 1 -acodec pcm_s16le -ar 44100 -af dynaudnorm=f=10:g=3:p=1.0,afade=t=in:st=0:d=0.5,areverse,afade=t=in:st=0:d=0.5,areverse -threads 1 -vcodec mjpeg out.avi)

F103: max 6000k video bitrate with audio
F405: max 15000k video bitrate with audio

  • videos where there is not a big change in the image during one frame can handle a higher bitrate

STM32F405: speed from SD (sdio 30 MHz) to MCU is ~10,2 MB/s

  • you can double speed (~21 MB/s) by bypass sdio clock:
    #define SDIO_CLOCK_BYPASS_SET() SDIO->CLKCR |= SDIO_CLKCR_BYPASS_Msk | SDIO_CLKCR_PWRSAV_Msk
    #define SDIO_CLOCK_BYPASS_RESET() SDIO->CLKCR &= ~(SDIO_CLKCR_BYPASS_Msk | SDIO_CLKCR_PWRSAV_Msk)
  • it's not legal frequency!!!
  • it works only with original STM32, not with clones like APM32
  • this 60 MHz clock is above STM32 limit, but works in commercial temperature range....
  • 30 MHz works well with 60 cm SD extender from Adafruit, but not with 60 MHz clock
    STM32F405: speed from MCU (SPI) to FT81x is ~3,6 MB/s
    STM32F405: speed from SD to FT81x (SDIO + SPI) is ~2,6 MB/s
  • tight throat (the slowest) is SPI to EVE... it needs QSPI, but mainstream MCU don't have SDIO and QSPI simultaneously...
  • i't not possible to set max SPI clock for FT81x (30 MHz) and max SDIO for MCU (48 MHz) simultaneously... best performance clocks for F405 are 120 MHz HCLK, 30 MHz SPI, 30 MHz SDIO

Hope it helps someone....

@Gjepali
Copy link

Gjepali commented Feb 7, 2024

STM32GENERIC has a few limitations and some bugs. It would be great to migrate to better library... stm32duino. I was trying to use CDC and Mass Storage simultaneously with STM32GENERIC, but it's not easy to modify it... stm32duino can do it, and it has bigger MCU support.

It would be great to migrate your GDSTx to stm32duino and use my modification for better performace in STM32.

@FT81xMania
Copy link
Owner

FT81xMania commented May 14, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants