วันจันทร์ที่ 24 ตุลาคม พ.ศ. 2559

how to broadcast from ffmpeg to darwin streaming server (rtp , rtsp )?

This topic describe how to  broadcast from ffmpeg to darwin streaming server .
advantage rtsp or rtp protocal streaming used as standard for long time ago .application that used such as watch video stream on Nokia classic mobile or blackberry mobile or sony Ericsson mobile.
  another application is your webcam streaming to internet server so you can watch your webcam anytime as you want .



1.server install  Darwin streaming server
   https://github.com/macosforge/dss/releases
   or you prefer chinese darwin complied
  https://github.com/EasyDarwin/EasyDarwin/releases

2.set relaying parameter file( Darwin streaming server) used for forward rtsp relay unicast broadcast.
    relayconfig.xml

<OBJECT TYPE="relay">

<!-- this is the traditional relay source.  It just listens for data on the specified -->
<!-- ports and relays it to the specified destionations.  Note that you can't use -->
<!-- announced_destinations with a udp_source (they will be ignored) -->
<OBJECT CLASS="source" TYPE="udp_source">
<!-- this is the local address to listen on (optional) -->
<PREF NAME="in_addr">0.0.0.0</PREF>
<!-- this is the address of the broadcaster -->
<PREF NAME="source_addr">127.0.0.1</PREF>
<!-- in_ports are the ports to listen to to (must match config on broadcaster) -->
<LIST-PREF NAME="udp_ports"> -->
<VALUE>5000</VALUE> -->
<VALUE>5002</VALUE> -->
</LIST-PREF>
<!-- time to live for a multicast source (optional, only used for sending receiver -->
<!-- reports) -->
<PREF NAME="ttl">5</PREF>
</OBJECT>

<!-- this would normally be followed one or more udp_destinations -->

</OBJECT>
define source_addr as you prefer


3. run ffmpeg to encode and push up to streaming server

 3.1 application webcam through Easydarwin
 refer  http://m.blog.csdn.net/article/details?id=46928933

fmpeg -f dshow -i video="Integrated Camera":audio="麦克风 (Realtek High Definition Au" -vcodec libx264 -acodec libvo_aacenc -preset:v ultrafast -tune:v zerolatency -f rtsp rtsp://127.0.0.1/live.sdp
-f rtsp rtsp://127.0.0.1 (if your server and webcam run on same computer)




 3.1 application restream from  through  Darwin streaming server

-not recommend use vlc reencode because not support aac , amr encode
-download windows ffmpeg version at https://ffmpeg.zeranoe.com


run command
ffmpeg -re -i rtmp://server.com/live/stream1   -strict experimental -vcodec h263 -vb 20k  -s qcif -strict experimental  -acodec amr_nb -ar 8000 -ab 7950 -ac 1  -f  rtsp  rtsp://server2.com/3gp.sdp

explain
  -i rtmp://server.com/live/stream1  => get input from rtmp://server.com/live/stream1 
  -strict experimental  => for use amr encoding
-vb 20k => video bitrate 20kbps
-s qcif => video size 176x144  (  h263 support  cif (352x288) , qcif 176x144 ,‘sqcif’ 128x96 )
-acodec amr_nb => use amr_nb (amr narrow band ) encoding sound at low bitrate
-ar =>  ar (audio sampling rate) 8000hz
-ab =>  audio bit rate 4750 , 5150 ,5900 ,6700,7400 ,7950 ,10200 bps
-f  rtsp  rtsp://server2.com/3gp.sdp => push to server2 that install darwin server and relay broadcast


watching stream at rtsp://server2.com/3gp.sdp


remark
1. ffmpeg -re -i input.mpg -vcodec copy -an -f rtp rtp://224.10.20.30:20000 -vn -acodec copy -f rtp rtp://224.10.20.30:30000 -newaudio
<= not working with darwin i have tested http://lucabe72.blogspot.com/2010/04/rtp-streaming-with-ffmpeg.html