AGORA MEDIA PUSH WITH FLUTTER USING RESTFUL API
Hi Coders,
First Let's talk about
Media Push
Agora Media Push helps to publish video/audio streams from agora to other platform i.e. YouTube,Facebook,Instagram,Twitter,Twitch etc. and this will be done by two methods
Methods:
1.Without Transcoding: If you have single host then you can use this method
2.With Transcoding: If you have multiple hosts then use this method and after transcoding it will upload to CDN(Content Delivery Network) and then we can can publish it to other targeted platforms.
Agora not provide direct sdk for Media push for Flutter yet so we are going to use RESTful API for that.
Official Documentation
Here you can read all the Documentation of agora media push Restful API
https://docs.agora.io/en/media-push/develop/restful-api
Before implementing Media Push in your code First you need to enable it from agora account Because its paid and you will need secret keys for authorization for Media Push when you will hit the URL then you need to pass authorization
When i was trying to implementing Media Push in my flutter project that time I faced many problems so after so many discussions with agora team finally i got successful in Media Push.
And after that i thought maybe there are also many other developers who are struggling with this So let's make easy for them out here
If you found my article helpful then gives a thumps up and visit my GitHub for more public repository and you can follow me on Instagram and also you can check my YouTube channel.
Let's understand above code in more details
Here I created a function called streamToSocialMedia in which there is an URL.
call this function whenever you want to publish stream to other platform with transcoding
String url = "https://api.agora.io/eu/v1/projects/$APP_ID/rtmp-converters";
APP_ID : your agora app id
you just need to edit replace $APP_ID with your agora app id
"name": "${channelId}_vertical",
channelId: name of live stream channel/channel id
change with the channel name (${channelId}) of live stream which you want to transcode and publish to other platforms
and also here after channel name _vertical is written which means the live stream will be transcode and publish in vertical mode and if you want to change than just replace _vertical with _horizontal i.e.
vertical mode channel: channelName_vertical
horizontal mode channel: channelName_horizontal
"rtcChannel": channelId,
replace channelId with your channel name
"rtcStreamUid": Uid,
Uid : UID is the channel stream uid of host so just replace it your your own host uid
"rtmpUrl":"rtmpPlatformUrl"+"rtmpPlatformKey"
This is the most important part and will used to publish transcoded stream to targeted platform due to this rtmpUrl So be careful at this.