HTTP Streaming Example for ameba-rtos-pro2/Delay Time (Official FreeRTOS SDK)

Hello, I’m starting to migrate my project from the Arduino IDE to the official FreeRTOS. Although I can’t find an example in the HTTP server streaming image, I need a delay of less than 100 ms in my project, and the RTSP example isn’t compatible due to the protocol delay.

I’ve tried the official SDK’s RTSP before, but the delay is now a problem!

Attached is the image above the project folder.

Best regards.

Hi @TeschRenan ,

Currently streaming via HTTP server is not supported yet in the FreeRTOS SDK. In Arduino SDK, HTTPDisplayJPEGContinuous example captures JPEG images and streams them to a browser over HTTP. It uses Motion JPEG (MJPEG) encoding to transmit the image continuously.

For RTSP streaming, reducing the caching time in VLC to 0 ms can significantly lower latency. Based on my tests, the lowest achievable latency with this setting is approximately 500 ms. To further reduce the delay, lowering the video resolution can be done as well, as higher resolutions require more processing and transmission time.

However, video streaming performance can be affected by various factors such as Wi-Fi strength and environmental conditions, etc.

Hi Pammy, how are you?
Thanks for the replies. I’ll try after testing, but I can’t play the RTSP example right now.
Can you help me with this?
Example: I set up the “mmfv2_video_example” example in cmake and then changed the SSID and password in main.h in the inc folder!

The build works and I burn the CI, however the Wifi is not connecting, can I see the result? I think I was fiddling with some things, but now I can’t find the problem.

I can’t find the STA_MODE_SSID var in the code, I don’t know which value the code uses because Wifi init is very simple and doesn’t use this var either.

I’ll try to test another example when I’m waiting for the answer.

Thank you.

Hi @TeschRenan ,

After flashing the image to AMB82 Mini board, you can use AT command to connect to WiFi. You need not modify main.h.

You can refer to ameba-rtos-pro2/component/at_cmd/atcmd_wifi.c at main · Ameba-AIoT/ameba-rtos-pro2 · GitHub and ameba-rtos-pro2/component/at_cmd/atcmd_wifi.h at main · Ameba-AIoT/ameba-rtos-pro2 · GitHub .

STA:

ATW0={SSID}

ATW1={Password}

ATWC ← To connect

AP:

ATW3={SSID}

ATW4={Secret Password}

ATW5={channel}

ATWA ← start AP

AT command manual: https://raw.githubusercontent.com/ambiot/ambd_sdk/12dab4363fd0087eb4874461f8d3f6094110595f/doc/AN0025%20Realtek%20at%20command.pdf

Application Note: Welcome to AmebaPro2’s Documentation! — AmebaPro2's Documentation v0.1 documentation

Perfect Pammy, thanks for the explanation, but in my product I need to save the SSID and password in another method, from there I implemented this function to execute before wifi_common_init(); in video_example_media_framework.c the function is this!

And it is not working, I disabled this function and enabled it by AT command and the connection also does not work.

Initializing WIFI …[Driver]: [HALMAC]

11692M HALMAC_MAJOR_VER = 1

HALMAC_PROTOTYPE_VER = 4

HALMAC_MINOR_VER = 20

HALMAC_PATCH_VER =

[Driver]: The driver include MP

[Driver]: Ver = libwlan:2025.05.23.13.46_b9.6_f72abedb2cc8f958bf54e9c74d8a457beb4411b9

RFE type = 0

start_addr=(0x4000), end_addr=(0x8000), buffer_size=(0x4000), smp_number_max=(2048)

WIFI initialized

[FAST_CONNECT] Fast connect profile is empty, abort fast connection

init_thread(58), Available heap 0x6955cc0

use ATW0, ATW1, ATWC to make wifi connection

wait for wifi connection…

ATW0=“Julliano”
ATW0=“Julliano”

[ATW0]: AT_WLAN_SET_SSID [“Julliano”]

[MEM] After do cmd, available heap 110456160

ATW1=“12345678”
ATW1=“12345678”

[ATW1]: AT_WLAN_SET_PASSPHRASE [“12345678”]

[MEM] After do cmd, available heap 110456160

ATWC
ATWC

Joining BSS by SSID “Julliano”…

RFE type = 0

start_addr=(0x4000), end_addr=(0x8000), buffer_size=(0x4000), smp_number_max=(2048)

[Driver]: set ssid [“Julliano”]

(0) Scan: 1, Auth: 0, Assoc: 0, 4way: 0, connect: 0, reason: 65533

ERROR: Can’t connect to AP

[MEM] After do cmd, available heap 110455104

auto reconnect …

[Driver]: set ssid [“Julliano”]

I think that I had setting the configs correctly, but don’t, work.

I encountered the first problem, I can’t use “I need to use SSID and password directly”, I was testing continuously!

To use AT command. You need not include the quote (“ “).

ATW0=Julliano

ATW1=12345678

ATWC

For the method that you prefer,

In the FreeRTOS SDK, you can look for the following functions and take it for reference while you write your own function.

  • int wifi_enable_sta_mode(rtw_network_info_t *connect_param, int timeout, int retry)
  • int wifi_disable_sta_mode(void)

How to apply the function? After you created the function, you can use the function directly in your application/example code. You can take reference from ameba-rtos-pro2/project/realtek_amebapro2_v0_example/scenario/ai_glass/src/ai_glass_initialize.c at 3ff32fed42453fe753eacebecf8ffdb204f696f6 · Ameba-AIoT/ameba-rtos-pro2 · GitHub to see how the function can be used.

Hi Pammy, how are you? Thanks for the explanation. The code worked so far, but I was trying to implement MJPEG from the HTTP server.
Do you have a tips to try implementing something similar to the Arduino example?

Hello @pammyleong , regarding the HTTP Stream example, can you guide me through the steps I need to implement the code in the official SDK?

Initially, I was trying to use the snapshot example and send the capture from an HTTP server.
What do you think is a good idea?

In the cpp Class Video, captureSnapshot is used!

What’s the difference in implementing this method in the FreeRTOS SDK?

Is the performance of running code using Arduino the same as that of FreeRTOS by directly implementing this example?
Can I get better performance with FreeRTOS?

Hi @TeschRenan

Both SDKs deliver the same performance, since the Arduino SDK is built on the FreeRTOS SDK code base. However, in FreeRTOS SDK, Streaming via HTTP is not supported.

In the Arduino SDK, the “HTTPDisplayJPEGContinuous” example works by:

  1. Capturing frames one by one.
  2. Compressing each frame individually as JPEG (using the MJPEG encoder).
  3. Sending those frames sequentially over an HTTP connection.

On the client side, because the browser receives a continuous sequence of JPEG images, it looks like a video stream.

Since the Arduino SDK is built on the FreeRTOS SDK code base, it is possible to create a similar example in FreeRTOS SDK.

If you would like to create your own example, you can create a new example in ameba-rtos-pro2/project/realtek_amebapro2_v0_example/src/mmfv2_video_example at main · Ameba-AIoT/ameba-rtos-pro2 · GitHub and add your function name in ameba-rtos-pro2/project/realtek_amebapro2_v0_example/src/mmfv2_video_example/video_example_media_framework.c at main · Ameba-AIoT/ameba-rtos-pro2 · GitHub .

Another option that you can consider exploring: [Sharing] Video Streaming from Ameba Pro2 to Browser via FFmpeg

Hi @TeschRenan

Here’s a websocket viewer video for sharing. This feature is under development.

Dear @TeschRenan,

For low-latency video streaming, please refer to the following folder for example:
Ameba-AIoT/ameba-rtos-pro2: media_websocket_viewer.

You may follow the instructions in the README file to test this example. Optimization work is still in progress.

Thank you.

Hello Pammy!

Perfect, thanks to sharing this example.

Best Regards.

@pammyleong in final release is need the htdocs.bin in SD Card our this archive is possible sended to Flash memory in the future?