Ant Media Server can republish live streams to 3. party endpoints. In other words, live stream can be send to youtube, facebook, periscope and generic RTMP server simultaneously through Ant Media Server.

In this blog post, we are going to show how a developer can use this functionality on Ant Media Server.

Let’s do it on step by step fashinon

How to create client id and secret on the social platforms ?

If you just want to test this functionality, please send an email  to contact@antmedia.io to get test client id and client secret. If you develop your app, please follow the tutorial. Btw, Facebook and Youtube publishing features are on Enterprise Edition, Periscope publishing is on Community Edition.

  • Facebook: You need to create an app on Facebook Developers. After you create an app, you can use App ID as client id and and App Secret as client secret as shown below.

Btw, your app need to have publish_actions permission and Live Video API feature

  • Youtube: You need to create a project on Google Developers Console. You can learn details from Getting Started guide for Youtube API.
    In short

    • Enable Youtube Data API v3 on the project
    • Go to Credentials , click “Create Credentials”, a popup appears then choose “OAuth Cliend Id”
    • Select “Other” as application type and click the “Create” button then client id and client secret should appear in a dialog.

You can see client id and client secret whenever you click the item in the list shown above.

  • Periscope: Firstly, you need to apply the Periscope Producer API private beta program. After you join the program, just login to periscope and click your profile photo on top right. Then select the “Developer” item.

After that just click the “Add Application” then client id and client secret will be displayed on the page

How to configure app for publishing Facebook, Youtube and Periscope ?

  • Open red5-web.properties file in under apps WEB-INF folder and add  below properties to that file
    ... 
    periscope.clientId=WRITE_PERISCOPE_CLIENT_ID
    periscope.clientSecret=WRITE_PERISCOPE_CLIENT_SECRET
    
    youtube.clientId=WRITE_YOUTUBE_CLIENT_ID
    youtube.clientSecret=WRITE_YOUTUBE_CLIENT_SECRET
    facebook.clientId=WRITE_FACEBOOK_CLIENT_ID
    facebook.clientSecret=WRITE_FACEBOOK_CLIENT_SECRET
    ...
  • Open red5-web.xml file again in under WEB-INF folder and make sure that web.handler bean is like below
    <bean id="web.handler" class="io.antmedia.serverapp.pscp.Application" >
    <property name="videoServiceEndpoints">
    <list>
    <!-- Open this comment block if you use enterprise edition
    <bean class="io.antmedia.enterprise.social.endpoint.FacebookEndpoint" init-method="start">
    <constructor-arg value="${facebook.clientId}"/>
    <constructor-arg value="${facebook.clientSecret}"/>
    <constructor-arg ref="preference.store"/>
    </bean>
    -->
    <bean class="io.antmedia.social.endpoint.PeriscopeEndpoint" init-method="start">
    <constructor-arg value="${periscope.clientId}"/>
    <constructor-arg value="${periscope.clientSecret}"/>
    <constructor-arg ref="preference.store"/>
    </bean>
    <!-- Open this comment block if you use enterprise edition
    <bean class="io.antmedia.enterprise.social.endpoint.YoutubeEndpoint" init-method="start">
    <constructor-arg value="${youtube.clientId}"/>
    <constructor-arg value="${youtube.clientSecret}"/>
    <constructor-arg ref="preference.store"/>
    </bean>
    -->
    </list>
    </property>
    <property name="dataStore" ref="db.datastore" />
    </bean>
    

 

How to authenticate for Facebook, Youtube and Periscope ?

Authenticate server to let it publish live stream on your behalf. In order to do that call below rest service with POST command

http://SERVER_NAME:5080/APP_NAME/rest/broadcast/getDeviceAuthParameters/{serviceName}

Change {serviceName} with facebook, youtube or periscope. This service returns a JSON data which includes verification_url and user_code. Please go to verification_url  value and enter the user_code value. A few seconds later you enter user_code , server will be authenticated for that service.

You can also call below rest service to look at whether server is authenticated

http://SERVER_NAME:5080/APP_NAME/rest/broadcast/checkDeviceAuthStatus/{serviceName}

Again change {serviceName} with facebook, youtube or periscope.

How to Create a live stream with Social Endpoints ?

http://SERVER_NAME:5080/APP_NAME/rest/broadcast/create

with POST command and send Broadcast JSON object. Like below

{
name:"live stream with social endpoints"
}

This rest service returns a Broadcast object with having and id field.

  • Then call below rest service with that id and social network name
http://SERVER_NAME:5080/APP_NAME/rest/broadcast/addSocialEndpoint

This rest service consumes “application/x-www-form-urlencoded” format and requires “id” and “serviceName” fields.

How to start Publishing Live Stream ?

Start publishing live stream to the server with the URL below

rtmp://SERVER_NAME/APP_NAME/ID

Please replace values accordingly and use stream’s “id”  for the “ID” in the URL. This “id” value is the one being returned by server in above section.

Then check the social media account to see the live stream.

Please let us know if you have any question by sending e-mail contact@antmedia.io

Categories: Tutorial

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

Tutorial

How to Create WebRTC WebSocket Connection in Android?

Ant Media WebRTC Android SDK You can use WebRTC facilities in Android Environment with the help of AntMedia Android WebRTC SDK. This SDK provides WebRTC WebSocket communication between Android devices and media servers (signaling servers) easily.This Read more…

Tutorial

What is CDN and which CDN service should be selected?

Would you like to lower the cost of digital video broadcasting by using CDN? Would you like to please the customer by increasing the upload speed of the video? If you answered yes to one Read more…

Tutorial

Distribute Live Stream to Periscope simultaneously with Periscope Producer API

Ant Media Server now distributes live stream to Youtube, Facebook, and Periscope simultaneously.  In order to do that, we have integrated Youtube Data API, Facebook Open Graph and Periscope Producer API to Ant Media Server Read more…

%d bloggers like this: