# \[Sharing\] Video Streaming from Ameba Pro2 to Browser via FFmpeg

**URL:** <https://forum.amebaiot.com/t/sharing-video-streaming-from-ameba-pro2-to-browser-via-ffmpeg/1505>\
**Category:** Arduino\
**Tags:** rtl8735b\
**Created:** [October 27, 2022, 9:19am UTC](https://forum.amebaiot.com/t/sharing-video-streaming-from-ameba-pro2-to-browser-via-ffmpeg/1505 "2022-10-27T09:19:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dakamaster](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/dakamaster/32/1744_2.png) [@dakamaster](https://forum.amebaiot.com/u/dakamaster)\
**Post date:** [October 27, 2022, 9:19am UTC](https://forum.amebaiot.com/t/sharing-video-streaming-from-ameba-pro2-to-browser-via-ffmpeg/1505/1 "2022-10-27T09:19:16Z")

</div>

## Intro

Recently, Ameba Family has a new member who joined us, Ameba Pro2, which supports video and AI functions. In our pre-released [Ameba Pro2 Arduino](https://github.com/ambiot/ambpro2_arduino) SDK, we have already supported real-time video streaming to [VLC Media Player](https://www.videolan.org/). However, some users might want to stream the video to their web browser. So, in this article, I will share with you guys how you could use FFmpeg to achieve the required feature.

## FFmpeg

 ![image](https://us1.discourse-cdn.com/flex016/uploads/ameba/original/2X/7/7663549395b6ac0f14332b0ebc0eaf5e317da9ea.png)

FFmpeg is the leading multimedia framework, able to **decode** , **encode** , **transcode** , **mux** , **demux** , **stream** , **filter** and **play** pretty much anything that humans and machines have created.

1. Download FFmpeg from [Download FFmpeg](http://www.ffmpeg.org/download.html) , if you are using a Windows system, you can just download it from the link here: [Builds - CODEX FFMPEG @ gyan.dev](https://www.gyan.dev/ffmpeg/builds/)  

2. After FFmpeg is successfully downloaded, key in `ffmpeg -version`, upon seeing the log below, it means your FFmpeg environment has been set up successfully  

## nginx

 ![image](https://us1.discourse-cdn.com/flex016/uploads/ameba/original/2X/0/0228e94d7ef09ba371f2ca3385aa0bea3b81392a.png)

1. Download `nginx-rtmp-win32` from [GitHub - illuspas/nginx-rtmp-win32: Nginx-rtmp-module Windows builds.](https://github.com/illuspas/nginx-rtmp-win32) and unzip it.  

2. Modify `conf/nginx.conf` using the code below:

```auto
worker_processes 1;

error_log logs/error.log debug;

events {
    worker_connections 1024;
}

rtmp {
    server {
        listen 1935;
        
        chunk_size 4000;
        
        application live {
            live on;
        }
        
        application hls {
            live on;
            hls on;  
            hls_path temp/hls;  
            hls_fragment 8s;  
        }
    }
}

http {
    include mime.types;
    default_type application/octet-stream;
    sendfile on;
    keepalive_timeout 65;
    server {
        listen 20000;
        
        location / {
            root html;
            index index.html index.htm;
        }
        
        location /stat {
            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }

        location /stat.xsl {
            root html;
        }
        
        location /hls {  
            #server hls fragments  
            types{  
                application/vnd.apple.mpegurl m3u8;  
                video/mp2t ts;  
            }  
            alias temp/hls;  
            expires -1;  
        }
        
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
            root html;
        }
    }
}

```

1. Open cmd and type `start nginx`, then open your browser: `localhost:20000` to check whether it displays information as shown in the screenshot below. Then close nginx by `nginx -s stop` or quit by `nginx -s quit`.  
 ![Pasted image 20221026173453](https://us1.discourse-cdn.com/flex016/uploads/ameba/original/2X/1/1e312b80ce646b259ee37897e9430124c59f98d9.png)

### Method 1: Display video streaming on your PC

Setup your video streaming example on Ameba, key in the command below, change the IP address to the IP broadcast by Ameba

```auto
ffplay -fflags nobuffer -flags low_delay -framedrop -rtsp_transport tcp rtsp://192.168.xxx.xxx/<your setting>  

```

For example, I am using the code below

```auto
ffplay -fflags nobuffer -flags low_delay -framedrop -rtsp_transport tcp rtsp://192.168.1.153:554

```

 ![Pasted image 20221026174744](https://us1.discourse-cdn.com/flex016/uploads/ameba/original/2X/2/2807dca67f138164ed9a5f5255fca3396131d268.png)

Lastly, a pop-up window will appear on your PC which shows the video streamed from your Ameba Pro2 Camera

 ![Pasted image 20221026175117](https://us1.discourse-cdn.com/flex016/uploads/ameba/original/2X/2/2c192f58ef52af66faa286572c24e769865e5aad.jpeg)  
 ![Pasted image 20221026175129](https://us1.discourse-cdn.com/flex016/uploads/ameba/original/2X/5/5fb139b7fa8411e5279b4189e8629453e92da68b.jpeg)  
 ![Pasted image 20221026175153](https://us1.discourse-cdn.com/flex016/uploads/ameba/original/2X/8/82b3d4efd25196127fa1e51b3852d238b222d624.jpeg)  
 ![Pasted image 20221026175229](https://us1.discourse-cdn.com/flex016/uploads/ameba/original/2X/4/4d6331db0c1a36e87ae0c2bccf4ed00160de011d.png)

### Method 2: Display video streaming on your Browser

The second method will use FFmpeg as a decoder to convert `RTSP` to `RTMP` since most browsers can only identify `RTMP`.

Therefore, by using the command below to convert the video source first, then stream it to your Nginx RTMP localhost to view it in your browser.

```auto
ffmpeg -re -rtsp_transport tcp -i "rtsp Address" -f flv -vcodec libx264 -vprofile baseline -acodec aac -ar 44100 -strict -2 -ac 1 -f flv -s 1280x720 -q 10 "rtmp://localhost:1935/live/test"  

```

For example, I am using the code below

```auto
ffmpeg -re -rtsp_transport tcp -i "rtsp://192.168.1.153" -f flv -vcodec libx264 -vprofile baseline -acodec aac -ar 44100 -strict -2 -ac 1 -f flv -s 1280x720 -q 10 "rtmp://192.168.1.213/live/demo"

```

Open your browser and key in `rtmp://192.168.1.213/live/demo`, and open PotPlayer, then you are able to stream your video in the browser.

The result is as shown below:

 ![image](https://us1.discourse-cdn.com/flex016/uploads/ameba/original/2X/0/06bba746de2482bbb674bf0f10e050175e857c28.png)

A pop-up window will ask whether you want to open the website in `PotPlayer`. You can download it from [here](https://potplayer.daum.net/). And the final results will be shown as below.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/ameba/original/2X/4/49e04b1e5268e5708cf24c9b5d4d9cfb4b2a2c02.jpeg)

 ![image](https://us1.discourse-cdn.com/flex016/uploads/ameba/original/2X/8/8a8161f78fa078fbb59f7914afe28055291f2ce7.jpeg)

---

<div class="post-metadata">

**Author:** ![Marco\_Rizzo](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/marco_rizzo/32/1707_2.png) [@Marco\_Rizzo](https://forum.amebaiot.com/u/Marco_Rizzo)\
**Post date:** [December 10, 2023, 4:10pm UTC](https://forum.amebaiot.com/t/sharing-video-streaming-from-ameba-pro2-to-browser-via-ffmpeg/1505/3 "2023-12-10T16:10:26Z")

</div>

Hello everyone, I would like to know if it is possible to use ffmpeg instead of vlc in the Multimedia - RTP Audio Stream example.  
I would like to send the audio stream via ffmpeg to amb82.  
Thank you,  
Marco.

---

<div class="post-metadata">

**Author:** ![M-ichae-l](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/m-ichae-l/32/33_2.png) [@M-ichae-l](https://forum.amebaiot.com/u/M-ichae-l)\
**Post date:** [April 1, 2024, 3:05am UTC](https://forum.amebaiot.com/t/sharing-video-streaming-from-ameba-pro2-to-browser-via-ffmpeg/1505/4 "2024-04-01T03:05:01Z")

</div>

Please refer to [RTP Class – Realtek IoT/Wi-Fi MCU Solutions](https://www.amebaiot.com/en/rtl8735b-arduino-api-rtp/) .  
For usage of FFmpeg, official SDK will keep using vlc instead.
