How do I download a youtube video in iOS - ios

I know how to launch a youtube video within an iOS web view, but how can I download that video to save on my iPad app? Is it possible? Do I need to use some call with a NSURLConnection object and then save the received data into the proper file format?
One specific point I am unsure about is what the url to request the file would be. When viewing a video on youtube, the downloadable videos are triggered with a button, so it's not evident to me what the url would be.

You would need to download an iOS-compatible version of the video, possibly using the same technique employed by the Safari FlashToHTML5 plugin.
Youtube DOES offer video download links:
http://lifehacker.com/#!5152236/youtube-offers-official-downloads-and-purchases-for-videos
.. make sure you do not violate their TOS.
In general, when downloading large files, you might consider implementing resumable file downloads, especially because connectivity on a mobile device is transient.
On top of that, make sure that you're on a wifi network when downloading (or resuming a download), using Reachability. Note that excessive bandwidth usage over cellular networks is a reason for app rejection.

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.

Store videos for an iOS app online or offline?

I am currently working on an iOS app where users can watch several videos (e.g. fitness videos). The videos are all captured by my team, so I don't need access to external videos.
Now my question is, does it make more sense to store the video files offline right in the app or use some kind of online server (and which one would you recommend)? I don't want to embed Youtube videos.
Thanks in advance!
It is always better to go online. Because the size of video may vary and huge video files would scrap user device's memory. SO it is recommended to use an external server to host the video files.
You can also add an option to download the files if needed.

YouTube Player API android does not automatically change the video quality

Hope anyone can help me
We are developing an Android app that integrates the latest YouTube API Player. Everything seems to be ok when user wants to load a video (using the video Id), and the user is able to visualize it.
However, we have identified in our lab an strange behaviour in the YouTube player when the quality of the network where the user is located gets worse. We thought that the YouTube player would automatically adapt the video quality depending on the network conditions (no quality selection is done, thinking that by default is set to automatic), however it does not, but the native YouTube App does.
Let me describe the test performed where we have observed this behaviour:
An android device with the native YouTube App and our app installed and connected to our WLAN network
The WLAN network provides access to internet and we can inject some impairments on that network (i.e. reduce the bandwith)
Configure excellent bandwith in the nertwork
Start the video and visualize some seconds
Configure bad bandwith (i.e. 256 kbit/s) in the network
After a few seconds:
a. YouTube App stalls just a little, then decrease the quality and continue playing the video.
b. AT4-App stalls longer to continue playing at the initial quality.
We think we already use the Youtube API at the most so we don’t know if we can upgrade our app to behave exactly like native YouTube App, because it does not make any sense that the API has less functionality that the native App (which is supposed to rely on the same APIs).
Thks

How can I measure my app's data traffic?

I'm developing an iPad app, which loads some images and does video calls. The images are retrieved over http, and the video stream is over rtp. Is there a way to measure all download and upload that is being performed by my app?
I'm not looking for a debug tool, I'd like to log how much bandwidth customers use.
Try to use Google Analytics SDK

Play mp3 from web with MPMoviePlayerController over 3G

In my app I use MPMoviePlayerController to play an mp3 file from a web server. This plays while downloading the whole file, which is fine over WiFi. But now I want it to work over 3G (and get it into the app store). How do I get it to just buffer the next 10 seconds or so (as per apple rules)? I'm digging through the documentation on AVPlayer, HTTP Live streaming, etc, but I'm still confused about the best way to do this. With so many podcast apps out there, I'm suprised there aren't more tutorials/libraries about it.
Thanks for your time.
I investigated this as well, and I was not able find a way to limit the look-ahead buffer using MPMoviePlayerController. I believe you would have to load chunks at the network layer and feed them in at the AVFoundation layer, but I have not attempted this myself.
That said, I can confirm that you can get an app approved that plays mp3 files using MPMoviePlayerController over both WiFi and 3G connections. In my app I added a setting so the user can decide whether to enable mp3 downloads over 3G or not, although I don't know if that was needed to get approved. I provided it so users didn't inadvertently incur bandwidth costs.

Resources