Skip to content

Add Demuxer Example Guide and API #30

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

Merged
merged 1 commit into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
174 changes: 174 additions & 0 deletions source/amebapro2/API_Documents/Multimedia/Class Demuxer.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
Class Demuxer
=============

.. contents::
:local:
:depth: 2

**Demuxer Class**
------------------

**Description**
~~~~~~~~~~~~~~~

A class used to handle MP4 file processing and extract audio and video streams from an MP4 file.

**Syntax**
~~~~~~~~~~

.. code-block:: c++

class Demuxer

**Members**
~~~~~~~~~~~

+---------------------------+------------------------------------------+
| **Public Constructors** |
+===========================+==========================================+
| Demuxer::Demuxer | Constructs a Demuxer object. |
+---------------------------+------------------------------------------+
| **Public Methods** |
+---------------------------+------------------------------------------+
| Demuxer::begin | Begin initializes and starts the demuxer |
| | for processing an MP4 file. |
+---------------------------+------------------------------------------+
| Demuxer::pause | Pause the RTSP streaming. |
+---------------------------+------------------------------------------+
| Demuxer::resume | Resume the RTSP streaming. |
+---------------------------+------------------------------------------+
| Demuxer::end | Stop demuxer. |
+---------------------------+------------------------------------------+

**Demuxer::begin**
-------------------

**Description**
~~~~~~~~~~~~~~~

Begin initializes and starts the demuxer for processing an MP4 file.

**Syntax**
~~~~~~~~~~

.. code-block:: c++

void begin(const char* MP4FileName, uint32_t loopMode, uint32_t startTime = 0);

**Parameters**
~~~~~~~~~~~~~~

MP4FileName: The name of the MP4 file to be processed.

loopMode: Determines whether the file should play in a loop. (Valid value: 0 (No looping) & 1 (looping))

startTime: The starting position (in milliseconds) from which playback begins. (Default: 0ms)

**Returns**
~~~~~~~~~~~

NA

**Example Code**
~~~~~~~~~~~~~~~~

Example: `DemuxerRTSP <https://github.com/Ameba-AIoT/ameba-arduino-pro2/blob/dev/Arduino_package/hardware/libraries/Multimedia/examples/DemuxerRTSP/DemuxerRTSP.ino>`_

.. note :: "Demuxer.h" must be included to use the class function.

**Demuxer::pause**
-------------------

**Description**
~~~~~~~~~~~~~~~

Pause the RTSP streaming.

**Syntax**
~~~~~~~~~~

.. code-block:: c++

void pause(void);

**Parameters**
~~~~~~~~~~~~~~

NA

**Returns**
~~~~~~~~~~~

NA

**Example Code**
~~~~~~~~~~~~~~~~

Example: `DemuxerRTSP <https://github.com/Ameba-AIoT/ameba-arduino-pro2/blob/dev/Arduino_package/hardware/libraries/Multimedia/examples/DemuxerRTSP/DemuxerRTSP.ino>`_

.. note :: "Demuxer.h" must be included to use the class function.

**Demuxer::resume**
--------------------

**Description**
~~~~~~~~~~~~~~~

Resume the RTSP streaming.

**Syntax**
~~~~~~~~~~

.. code-block:: c++

void pause(void);

**Parameters**
~~~~~~~~~~~~~~

NA

**Returns**
~~~~~~~~~~~

NA

**Example Code**
~~~~~~~~~~~~~~~~

Example: `DemuxerRTSP <https://github.com/Ameba-AIoT/ameba-arduino-pro2/blob/dev/Arduino_package/hardware/libraries/Multimedia/examples/DemuxerRTSP/DemuxerRTSP.ino>`_

.. note :: "Demuxer.h" must be included to use the class function.

**Demuxer::end**
-----------------

**Description**
~~~~~~~~~~~~~~~

Stop demuxer.

**Syntax**
~~~~~~~~~~

.. code-block:: c++

void end(void);

**Parameters**
~~~~~~~~~~~~~~

NA

**Returns**
~~~~~~~~~~~

NA

**Example Code**
~~~~~~~~~~~~~~~~

NA

.. note :: "RTP.h" must be included to use the class function.

Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ This function returns the calculated resized width.
**Example Code**
~~~~~~~~~~~~~~~~

Example: TBD
Example: `VideoOSDImage <https://github.com/Ameba-AIoT/ameba-arduino-pro2/blob/dev/Arduino_package/hardware/libraries/Multimedia/examples/VideoOSDImage/VideoOSDImage.ino>`_

.. note :: "VideoStreamOverlay.h" must be included to use the class function.

Expand Down Expand Up @@ -941,7 +941,7 @@ This function returns the calculated resized height.
**Example Code**
~~~~~~~~~~~~~~~~

Example: TBD
Example: `VideoOSDImage <https://github.com/Ameba-AIoT/ameba-arduino-pro2/blob/dev/Arduino_package/hardware/libraries/Multimedia/examples/VideoOSDImage/VideoOSDImage.ino>`_

.. note :: "VideoStreamOverlay.h" must be included to use the class function.

Expand Down Expand Up @@ -977,7 +977,7 @@ This function returns the calculated heapsize as an unsigned int.
**Example Code**
~~~~~~~~~~~~~~~~

Example: TBD
Example: `VideoOSDImage <https://github.com/Ameba-AIoT/ameba-arduino-pro2/blob/dev/Arduino_package/hardware/libraries/Multimedia/examples/VideoOSDImage/VideoOSDImage.ino>`_

.. note :: "VideoStreamOverlay.h" must be included to use the class function.

Expand Down Expand Up @@ -1033,7 +1033,7 @@ NA
**Example Code**
~~~~~~~~~~~~~~~~

Example: TBD
Example: `VideoOSDImage <https://github.com/Ameba-AIoT/ameba-arduino-pro2/blob/dev/Arduino_package/hardware/libraries/Multimedia/examples/VideoOSDImage/VideoOSDImage.ino>`_

.. note :: "VideoStreamOverlay.h" must be included to use the class function.

Expand Down Expand Up @@ -1065,7 +1065,7 @@ NA
**Example Code**
~~~~~~~~~~~~~~~~

Example: TBD
Example: `VideoOSDImage <https://github.com/Ameba-AIoT/ameba-arduino-pro2/blob/dev/Arduino_package/hardware/libraries/Multimedia/examples/VideoOSDImage/VideoOSDImage.ino>`_

.. note :: "VideoStreamOverlay.h" must be included to use the class function. Each image requires setting a new block index.

3 changes: 2 additions & 1 deletion source/amebapro2/API_Documents/Multimedia/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ Multimedia
Class AudioDecoder
Class AudioEncoder
Class AudioStream
Class Demuxer
Class MotionDetection
Class MP4Recording
Class RTP
Class RTSP
Class StreamIO
Class VideoStream
Class VideoStreamOverlay
Class VideoStreamOverlay
78 changes: 78 additions & 0 deletions source/amebapro2/Example_Guides/Multimedia/RTSP Demuxer.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
RTSP Demuxer
=============

.. contents::
:local:
:depth: 2

Materials
---------

- `AMB82-mini <https://www.amebaiot.com/en/where-to-buy-link/#buy_amb82_mini>`_ x 1
- SD Card

Example
-------
This example demonstrates on how to use a demuxer on the AmebaPro2 board to process an MP4 file from an SD card and stream its content over RTSP (Real-Time Streaming Protocol).

Open the example in “File” -> “Examples” -> “AmebaMultimedia” -> “DemuxerRTSP”.

|image01|

First, you can choose whether to loop the MP4 file during streaming. If looping is enabled, the stream will play continuously without stopping.

Next, fill in the “ssid” with your WiFi network SSID and “pass” with the network password.

Finally, specify the name of the MP4 file you want to stream via RTSP. It is recommended to use an MP4 file recorded with the AmebaPro2 board.

|image02|

Compile the code and upload it to Ameba.

After pressing the Reset button, wait for the Ameba Pro 2 board to connect to the WiFi network. The board’s IP address and network port number for RTSP will be shown in the Serial Monitor.

On a computer connected to the same WiFi network, open VLC media player, and go to “Media” -> “Open Network Stream”.

|image03|

Since RTSP is used as the streaming protocol, key in `“rtsp://{IPaddress}:{port}”`` as the Network URL in VLC media player, replacing {IPaddress} with the IP address of your Ameba Pro2 board, and {port} with the RTSP port shown in Serial Monitor. The default RTSP port number is 554.

Next, click “Play” to start RTSP streaming.

|image04|

**To pause the streaming:**

Enter the command **“pause”** to pause the stream using Serial Monitor.

|image05|

**To resume the streaming:**

Enter the command **“resume"** to resume the stream using Serial Monitor.

|image06|

.. |image01| image:: ../../../_static/amebapro2/Example_Guides/Multimedia/RTSP_Demuxer/image01.png
:width: 654 px
:height: 854 px

.. |image02| image:: ../../../_static/amebapro2/Example_Guides/Multimedia/RTSP_Demuxer/image02.png
:width: 606 px
:height: 298 px

.. |image03| image:: ../../../_static/amebapro2/Example_Guides/Multimedia/RTSP_Demuxer/image03.png
:width: 432 px
:height: 482 px

.. |image04| image:: ../../../_static/amebapro2/Example_Guides/Multimedia/RTSP_Demuxer/image04.png
:width: 765 px
:height: 659 px

.. |image05| image:: ../../../_static/amebapro2/Example_Guides/Multimedia/RTSP_Demuxer/image05.png
:width: 348 px
:height: 388 px

.. |image06| image:: ../../../_static/amebapro2/Example_Guides/Multimedia/RTSP_Demuxer/image06.png
:width: 318 px
:height: 385 px
4 changes: 2 additions & 2 deletions source/amebapro2/Example_Guides/Multimedia/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Multimedia
Play MP3 with SD card
RTP Audio Stream
RTSP Audio Stream
RTSP Demuxer
RTSP Streaming V7RC
RTSP Streaming
RTSP Streaming with OSD Image

RTSP Streaming with OSD Image