Streaming video hosted in Azure Media Services on iOS (Xamarin) - ios

I have a video hosted in Azure Media Services. I have encoded the video using the H264 Multiple Bitrate 1080p Encoding preset (I've tried others as well). After publishing for streaming I get the following endpoints. (I replaced my actual site name with mysite below)
Smooth Streaming
http://mysite.streaming.mediaservices.windows.net/eaaa9f34-e39a-4393-a93b-14a7609ebd27/sampleVid.ism/manifest
MPEG-DASH
http://mysite.streaming.mediaservices.windows.net/eaaa9f34-e39a-4393-a93b-14a7609ebd27/sampleVid.ism/manifest(format=mpd-time-csf)
HLS(v3)
http://mysite.streaming.mediaservices.windows.net/eaaa9f34-e39a-4393-a93b-14a7609ebd27/sampleVid.ism/manifest(format=m3u8-aapl-v3)
HLS(v4)
http://mysite.streaming.mediaservices.windows.net/eaaa9f34-e39a-4393-a93b-14a7609ebd27/sampleVid.ism/manifest(format=m3u8-aapl)
I have successfully streamed the video for android using the HLS(v4) url, so I know the video works.
For ios I followed this tutorial. https://developer.xamarin.com/recipes/ios/media/video_and_photos/play_a_video_using_avplayer/
I could successfully play a local video. I also was able to play a remote video following this apple tutorial. https://developer.apple.com/library/prerelease/content/documentation/AudioVideo/Conceptual/AVFoundationPG/Articles/02_Playback.html
There must be something wrong with the URL I'm using, but I can't figure out what it is. Here is the code in my ViewDidLoad method.
var myUrl = NSUrl.FromString("http://myurl.streaming.mediaservices.windows.net/eaaa9f34-e39a-4393-a93b-14a7609ebd27/sampleVid.ism/manifest(format=m3u8-aapl)");
var appleUrl = NSUrl.FromString("http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8");
_playerItem = new AVPlayerItem(myUrl);
_player = new AVPlayer(_playerItem);
_playerLayer = AVPlayerLayer.FromPlayer(_player);
_playerLayer.Frame = ProfileVideoContainerView.Frame;
ProfileVideoContainerView.Layer.AddSublayer(_playerLayer);
_player.Play();
myUrl does not work, but appleUrl does.

It turns out I just needed to use https instead of http. I thought I had tried this, but apparently not. Also, I'm not sure why the appleUrl works with http.

There is an iOS "feature" that disallows a connection to an http endpoint unless the endpoint is listed in the info.plist as an allowed unsecured connection. I had forgotten about this and got caught by it a few days/weeks ago. I think this feature was implemented with iOS9, but am not 100% sure on this. It may have been implemented before then.

Related

Architecture for a web app to add overlays to users' Youtube live stream video?

I am trying to build a web app for users to easily add text (as open caption) and other assets in my app as overlays in real-time to their YouTube live stream video.
They will use their camera to record their video, and select from my app which text should be added to the video.
Then, the video will be sent to Youtube live through their API.
Here are my questions:
First of all, I was wondering if mixing video + subtitle and sending it to Youtube's rtmp url can be done from the client side, so it's simple and lightweight.
Second, should I encode the output being sent to Youtube? Can this be done from the browser too?
I'm only seeing a few node.js frameworks, and even they're not very mature (or is Webcodecs for this purpose?). Is a web app a poor choice for this task?
Lastly, if I do need a server to process the video, where should the encoding happen (from the user's machine, or in the server, or both?)? Is my server most likely going to be the bottleneck given YouTube's infrastructure, since video files are huge and my server is limited?
I am new to video streaming, so please excuse my lack of understanding of the subject. Also, if there's any good resource for my problem, please share them with me.
First of all, I was wondering if mixing video + subtitle and sending it to Youtube's rtmp url can be done from the client side, so it's simple and lightweight.
You can do the video compositing and audio mixing and what not, but browsers don't support RTMP. To get the data to an RTMP server, you need to send it to a server where it is proxied off to the final URL.
They will use their camera to record their video, and select from my app which text should be added to the video.
Yeah, that's no problem at all. Draw everything to a canvas every frame.
Second, should I encode the output being sent to Youtube?
Yes, you must. Check out the Media Recorder API.
Lastly, if I do need a server to process the video, where should the encoding happen (from the user's machine, or in the server, or both?)?
The video has to be encoded client-side to get to the server in the first place. The server can then hopefully just repackage with flv and send it along. If the browser doesn't support H.264 in its Media Recorder API, then you'll have an intermediary codec like VP8, and you'll have to transcode server-side.
A few years ago, I wrote a tutorial on how to do all of these steps here: https://github.com/fbsamples/Canvas-Streaming-Example Note that the tutorial is in the context of Facebook, but this should teach you the concepts.

RTSP with iOS 8

My partner and I are developing an app for a client where they have a camera that connects to the app. Currently it is running in http but we want to use RTSP. We scraped the internet today to look for possible ideas, but they all seem outdated.
We tried incorporating DFURTSPPlayer but kept getting compile errors that were related to the actual SDK.
We want to use something like VideoStreamSDK.
Does anyone have any ways they can point us towards?
Thanks!
SOLVED
We found a RTSP player essentially that we were able to just incorporate it easily into our project.
[edit:
This requires to purchase their license :( , currently it is not working and throws error: Error Domain=com.imoreapps.avplayer.errordomain Code=-149]
Have you tried with MobileVLCKit? it's really easy and work well!
I wrote a small example here: https://github.com/rvi/ONVIFCamera
If you want to try it, just type pod try ONVIFCamera in your terminal.
Here is how to do it:
var mediaPlayer = VLCMediaPlayer()
// Associate the movieView to the VLC media player
mediaPlayer.drawable = self.movieView
let url = URL(string: "rtsp://IP_ADDRESS:PORT/params")
let media = VLCMedia(url: url)
mediaPlayer.media = media
mediaPlayer.play()
I successfully compiled and used DFURTSPPlayer but it crashed on some iOS devices.
Some days ago I have integrated this solution for playing rtsp video stream from IP-cameras: https://github.com/Bilibili/ijkplayer
The only issue I have is not stable connection. Player established connection only after few attempts.

iOS broadcasting live to Azure Media Services

I am trying to make a Periscope-like app (not practically, but technical requirements are alike) where users can start streaming quickly from their iPhone to an unknown amount of users, both mobile. I am trying to use Azure Media Services for live video streaming, but even after reading pages of documentation I'm stuck.
I'm using VideoCore (https://github.com/jgh-/VideoCore) to publish from iOS device to the RTMP server. On local (using Wowza) I can just connect to the local server with my set username and password as shown:
vcSession = [[VCSimpleSession alloc] initWithVideoSize:CGSizeMake(1280, 720) frameRate:30 bitrate:1000000 useInterfaceOrientation:NO];
[self.view addSubview:vcSession.previewView];
vcSession.previewView.frame = self.view.bounds;
vcSession.delegate = self;
[vcSession startRtmpSessionWithURL:#"rtmp://172.20.10.2:1935/live?rtmpauth=test:test" andStreamKey:#"test"];
Where the rtmpauth parameter has the username:password format, which I've set both to test on my local server. It works. In Azure, I've created a channel named test, and I've got the following Ingest URL:
rtmp://test-myappname.channel.mediaservices.windows.net:1935/live/some-long-hexadecimal-string
In Wirecast, I'm able to stream to URL (though EXTREMELY slow and connection frequently lost, don't know why) by selecting Azure Media Services in Output Settings and typing that Ingest URL. In iOS, I have no idea how to connect to Azure Media Services.
In startRtmpSessionWithURL:andStreamKey: method, I've tried all the possible combinations of URL and a stream key, but no luck. I have no idea what my username/password is (nothing is given at the Azure side), what the stream key is (I've tried test, live, empty string) and what that long hexadecimal string is (some sources say that it's called a locator, though).
What is the correct format of RTMP URL and stream key when connecting to Azure Media Services for streaming?
I'll find someone to help you. I think you are just missing a stream name after the long hex string in the URL.
rtmp://test-myappname.channel.mediaservices.windows.net:1935/live/some-long-hexadecimal-string/[YOUR-CUSTOM-STREAM-NAME-Anything Really!]
Also, do you have any control over the encoding settings? Its possible that some encoding settings are not right. We have not tested with that VideoCore library, so it may also be that there is a slight variation in the RTMP protocol (since it is very poorly documented and there is a lot of missing information out there).
I'm curious why your Wirecast setup is having trouble as well. That doesn't sound good to start with. Network issue? Are you setting it to the proper Encoder preset with H.264 and NOT x264 set?
Review your settings in Wirecast against Cenk's blog post here: http://azure.microsoft.com/blog/2014/09/18/azure-media-services-rtmp-support-and-live-encoders/

How to stream video over secure connection on iOS

I can play a video from a local resource (on the device).
I can stream a video from the unprotected internet.
I can't stream from the company intranet (either from internal or externally)
Typical secure company network. Videos are stored in SharePoint 2007 lists (but I have url to the video file).
I've tried:
MPMoviePlayerController
MPMoviePlayerViewController
UIViewView (creating html on fly using the <video> tag and video url)
and I can't get anything to work. Heck, I can't even get it to work going directly to the link in Safari on the iPad. The only thing I haven't tried doing is downloading it as a file then playing locally. Due to a host of usability issue this would not be a preferred option.
There were 2 problems.
MPMoviePlayerController doesn't support all the challenge authentication which exists in NSURLConnection. The solution is to just do a "dummy" NSURLConnection somewhere inside your secure area, have it handle all the challenges and set it to store the information for the session. From here on out, MPMoviePlayerController or other connections which don't support the ins and outs of SSL requests will use the existing session.
A valid intermediate certificate had to be installed on the server. Something I never would have figured out myself. It exists as a small item in one of the guides under Secure connections.

Live Streaming over RTMP from Wowza to iOS

I'm trying to play a live stream that is being sent out by a Wowza server, we are using RTMP to handle the streams. We have an equivalent for that works on android and the way they do it is by connecting to the server via the url and 2 parameters to identify the actual stream to play and if you are allowed to see the live video. After the connection is attempted, the server does a call back sending an integer for a check to see if the user is logged in. Once the check has passed, the video is played.
I have no idea how to handle the call back or how to properly set up the connection so that it takes both parameters and the url.
One big issue is that the Wowza server was created by a third party that we are no longer in contact with, so i have no idea on how the actual server is set up.
Any suggestions would be greatly appreciated
I recommend a few steps to start with:
Determine how the Android app actually works. Is the the server you speak of to which it sends the two parameters the Wowza server? If so, it is probably a custom plugin.
Get access to the server, so that you can configure it for iOS streaming.
You'll also need to check out some documentation, http://www.wowza.com/forums/content.php?3-quick-start-guide, http://www.wowza.com/forums/content.php?217#cupertinostreaming
Once you have a better understanding of the problem, the Wowza folks are very helpful at http://www.wowza.com/forums.
Good luck!
there is no need to android apps etc. Wowza is supporting the output which can be played # ios, because of the ios cant play flash, then it cannot played rtmp or rtsp . However Ios can play the stream which is like http: // myWowzaServer/myApplication/myStream/playlist.m3u8 ...
For better config detail please visit the
http://emrekaratasoglu.com/php-freelance-watch-wowza-live-stream-apple-ios-mobile-phone/

Resources