1

Im looking to stream YouTube videos to an iOS app. Are there any frameworks or libraries to do so? can AVFoundation do this? Some other Apple framework or third-party library? (Matt Gallagher's AudioStreamer doesn't support video, as far as I know.)

Edit:

Would MPMoviePlayerController work?

Moshe
  • 57,511
  • 78
  • 272
  • 425
  • MPMoviePlayerController would not work. UIWebView would work and would use non public implementation that looks a lot like MPMoviePlayerController (but is not MPMoviePlayerController). See my answer on http://stackoverflow.com/questions/8518719/how-to-receive-nsnotifications-from-uiwebview-embedded-youtube-video-playback for more. – Till Jan 06 '12 at 20:47

3 Answers3

3

Check out YouTube official dev pages for information on playing back YouTube content with Objective-C on how to do this. Basically, the documentation suggests using a UIWebView to handle the video playback.

Moshe
  • 57,511
  • 78
  • 272
  • 425
Simon Lee
  • 22,304
  • 4
  • 41
  • 45
1

You should use ffmpeg library, as this library can connect any streaming server (supporting rtsp, mms, tcp, udp ,rtmp ...) and then draw pictures to the screen.. (for drawing you can use opengles or uiimage also works)

First of all, use avformat_open_input to connect to your ip address then use avcodec_find_decoder & avcodec_open2 to find codecs and to open them (you should call them for both audio & video)

Then, in a while loop read packets from server by using av_read_frame method When you get frame, if it is audio then sent it to AudioUnit or AudioQueue, if it is video, then convert it from yuv to rgb format by using sws_scale method and draw the picture to the screen.

That's all.

look at this wrapper also (http://www.videostreamsdk.com), it's written on ffmpeg library and supports iOS

Tarum
  • 161
  • 5
  • 1
    You should not use ffmpeg since the license makes it very difficult to include the library statically linked into your iPhone app. Unless you are going to release the source code for your own app, then you should find another solution. – MoDJ Dec 13 '13 at 04:08
0

If you choose using ffmpeg, then take a look at kxmovie project. It's movie player for iOS using ffmpeg and OpenGLES. Now the project at stable stage and you may try to use it.

Kolyvan
  • 501
  • 4
  • 8