upload video stream and audio stream on iOS - ios

Here's the needs: People record their video via my App and upload stream to our website, you know, like a live show.
When they are recording, the network goes bad, then record audio instead of video.
And when audience watch, first comes the video, in a certain time comes the audio with a static picture.
How am I supposed to do that? Thanks.

I got this after thinking. So I'll answer by my self.
If you wanna record video and audio separately. Use lower level Library to handle this. Then upload it. And you can get the upload speed, When the speed goes low, you can shut down the video upload process.

Related

Swift: How to play the video and download at the same time

Currently in our iOS Application, we are downloading the video and then playing it, which is indeed taking a lot of time and killing the user experience. Now, we want to shift to directly stream the video or play the video while it is downloading.
I have tried using AVAssetResourceLoaderDelegate. I doesn't play the video at all and displays the mime type as text/html. Maybe because I am loading from a secured URL with headers.
Can someone suggest me a good way where I can stream or Play the video while downloading it. Would be glad if someone suggest a way to Stream the video's directly from the URL.

AVPlayer seekToTime download an insane amount of media segment files consuming a lot of data

I'm working in an app where I'm able to play a HLS m3u8 playlist of a streaming radio (audio only) without any problem using an instance of AVPlayer. Using Charles I can see how the playlist is updated properly in a normal pace (each 9-10 seconds, which takes one media segment file). When I perform a seekToTime: (back in time), the player success playing the stream from when I want to, but in Charles I observe how the player starts dowloading a huge amount of media segment files, consuming a lot of data. It seems that the player downloads all the media segment files until that time and then keeps again with the normal behaviour.
I understand that the correct behaviour would be to download the media segment file for the time I'm seeking to, start playing it and then download constantly 1 or 2 media segment files each 9-10 seconds, as it does when I play the stream without timeshift.
My question is if this is a normal behaviour, or if something could be wrong with my m3u8 playlist or the client implementation. Anyone could help me to clarify this?
UPDATED: I can confirm this doesn't happen in iOS 7, so it seems to be a bug introduced by iOS 8.
I've been told by Apple that this is not a bug, but a feature. They've made the buffer bigger since iOS 8.

AVPlayer - switching stream quality while playing

I'm using AVPlayer to play youtube videos, for each youtube video id I retrieve a couple of stream urls in different qualities.
I want to play a particular stream quality according to the network state. For example if user is on 3G I want to play the lowest quality URL but if user moves to wifi I want to seamlessly switch to the better quality stream.
This is nothing new, youtube is doing that in their app and many others.
So I wonder what is the best way to do this kind of switching with AVPlayer, I don't want the user to notice the switching as possible, without pausing the video playback or buffering.
Any advices?
I'm not sure if this kind of functionality is supported on the youtube servers or if I need to do it on client side.
You should have a look at the Apple documentation on HTTP live streaming.
The only way to achieve the type of switching that you want and is talked about in the documentation is the use of m3u index files and TS files containing the video data.
You connect to the index file and store its contents, which will be multiple URL's along with bandwidth requirements. See the examples here. Then use the
Reachability class to check network status and connect to the appropriate stream. Start the Reachability notifier and react to events by changing the stream you're connected to. This will cause the TS file that belongs to the stream to be downloaded and buffered for playback, achieving the type of switching you want.
As I previously said, the drawback is the requirement to use TS files. This would mean you video files would have to be downloaded from Youtube, prepared using the Apple provided mediafilesegmenter command line tool and the stored on an FTP server! Not ideal at all but as far as I'm aware the only way to do this.
Check out the AVPlayer replaceCurrentItemWithPlayerItem: method. If I were you, I would use Reachbility to observe the user's network status. When the network reachability degrades, you can do something like this:
AVPlayerItem *item = [AVPlayerItem playerItemWithURL:urlOfLowerQuality];
[item seekToTime:player.currentTime];
[player replaceCurrentItemWithPlayerItem:item];
Use ReachabilityManager to check current status of data type either wifi or 3G. According to data mode switch url type.While Switching url take current time of video and need to set seek time of video.

Play youtube video in offline mode?

I want to play YouTube video when we redirect from internet area to non internet area.
Like I am having internet access at some point and I played Youtube video, and after some
times my internet connection is loosed, but now I want to play all those video which I played
previously.
I am not going to write any code for this but only tell you the route you probably need to take. As with any online media, If you don't have access to the internet, well you can't really get the data. What you need to do is capture the data which is coming in from any media and save it on the device. When the user then clicks on a video which has been previously saved while not connected to the internet, you can play the saved video file. There isn't really a simple quick way to do this, just do some research on saving streaming video or downloading video and saving to device.
I am not aware of any caching mechanism for a browser that could do that 'off the box'. This wouldn't make much sense anyway because the cache would get full with only a few videos.
The only way that comes to mind is to download the video of interest while connected and play it with your favorite media player. There's bound to be a few addons depending on the browser you use, I use VideoDownloadHelper for Firefox but for iPhone this blog seems to have some instructions.

Play the Video/Audio which is getting from the server

Is there any solution of this below one?
I have the Video/audio URLs
My Requirement is:
Is it possible to get the video/audio from the server and at the same time I have to open the player to play it(Like showing the Live-video directly in browser Field).
Means
Getting streaming into a buffer in back-end and at the same time I want to show it in the player.
If above is possible
I want to save that particular video/audio streaming data in to one file.
This blackberry KB link explains about streaming video from server. It may help you.

Resources