Home > google, iphone > Upload Videos to YouTube with iPhone custom App

Upload Videos to YouTube with iPhone custom App

October 15th, 2010 Leave a comment Go to comments

EDIT: This is an old post, and apparently things have changed quite a bit. Unfortunately I haven’t had the time to update this and I’m not sure what the process to upload videos to YouTube is anymore.

With the 4.0 iOS and its new AVCaptureSession we now have access to video data, so that developers can edit this info and create cool apps such as SketchWiz, Predator Vision or iRetroscope.

However it’s not clear how these videos can be shared through the net. So in this post I’ll explain how we can upload videos to YouTube with a custom app and provide some sample code to test it.

We will need the Google Data API Client for Objective-C, and install it into our application. Here are the steps to do so:

- Download the GData Client for Objective-C from here
- Open the GData project with XCode
- Drag and drop the group GData Source from the GData project into your project (reference it or copy it into your project directory, up to you)
- Optional: In your project delete all groups inside GData Source but YouTube and Commons. This will make the compilation process much faster. You will have to comment the imports in your GData.h
- Add the Security.framework into your frameworks
- In the properties of your target, add the -ObjC to your Other Linker Flags setting
- In the properties of your target, add the /usr/include/libxml2 path to your Header Search Path setting
- Make sure your C Language Dialect is c99 in your target properties

You should now be able to compile the API within your own app.

Next step is to go here to get a Developer Key from Google. Your Developer Key and Client ID are required in order to use the GData API.

Once you have them, take a look at the simple YouTube upload test sample code based on the Mac OSX Example inside the GData Client Objective-C code and add them there in the YouTubeTestViewController.m.

Sample Code

For more information and other type of installations for the API, please read the API documentation.

I hope it helps. Any feedback is welcome as always.

  • Facebook
  • Twitter
  • Google Plus
  • Meneame
  • Add to favorites
  • RSS
  • BarraPunto
Categories: google, iphone Tags:
  1. Si
    November 10th, 2010 at 09:58 | #1

    Cheers, Uri. This saved me a load of time and worry.

  2. May 11th, 2011 at 12:04 | #2

    Thanks man!

  3. dinesh
    May 30th, 2011 at 08:29 | #3

    Thank u uri. If it is possible to upload video to youtube without developer Key?

  4. May 31st, 2011 at 05:26 | #4

    Thanks for your comment dinesh. I don’t think it’s possible to upload a video to youtube without a developer key, but I’m not sure about that. In any case, this key is free to obtain.

  5. justChecking
    July 26th, 2011 at 08:50 | #5

    hey ,

    Nice good post. It helped me a lot. One thing for people who are getting some sort of error like “TOO LONG……. ” just check keywords that are set in the example .. make them short..it will work..also use the actual youtube name instead of gmail username..!!!

    Thanks

  6. July 26th, 2011 at 10:00 | #6

    Thanks, I’m glad it helped you. And thanks for this tip!

  7. Amit
    October 13th, 2011 at 05:29 | #7

    hi,

    i am getting an error at login time…also i have used DEVELOPER_KEY… and i am using youtube user name instead of gmail id…

    Error:Error
    Domain=com.google.GDataServiceDomain Code=400 “The operation couldn’t be completed.

  8. October 13th, 2011 at 11:20 | #8

    Amit, I think youtube doesn’t accept the youtube user, just the google one. This post is rather old, and things might have changed a bit. Try it with the google account.

  9. kiran kumar
    November 2nd, 2011 at 02:57 | #9

    i new to youtube application and not yet uploaded app to google then is it possible to get client id

  10. COma4c
    November 29th, 2011 at 10:35 | #10

    @Amit
    did u find a way around that error ?

  11. Steve
    December 18th, 2011 at 14:40 | #11

    This is really useful . Thanks !

    Can anyone suggest how I can obtain the posted URL that YouTube assigns when you have successfully uploaded ? I wanted to be able to capture this and then email it if the user wanted to.

    Would appreciate any tips anyone has here or code samples.

  12. Wouter
    February 7th, 2012 at 05:50 | #12

    I’m glad I found this, but I’m having some trouble getting the video to upload. After I enter my details the app doesn’t seem to be doing anything. Does the app store the sample video on the device before it tries to upload? I thought that might be the problem so I tried to get the video on the device myself, but I’ve struggled with that aswell. I’m very new to iOS development, so please bare with me.

  13. March 30th, 2012 at 04:17 | #13

    hi guys.. when i am using just “google username” i am getting this error (error Error Domain=com.google.GDataServiceDomain Code=403 “The operation couldn’t be completed.)

    ans when i am using email address as an username i am getting following error(error Error Domain=com.google.GDataServiceDomain Code=400 “The operation couldn’t be completed.)..

    please i am waiting for a solution. please working sample code will be a great help. you can email me (ml_j13@yahoo.co.in )

  14. March 30th, 2012 at 04:18 | #14

    hi guys..i have put a developer key & my client id but when i am using just “google username” i am getting this error (error Error Domain=com.google.GDataServiceDomain Code=403 “The operation couldn’t be completed.)

    ans when i am using email address as an username i am getting following error(error Error Domain=com.google.GDataServiceDomain Code=400 “The operation couldn’t be completed.)..

    please i am waiting for a solution. please working sample code will be a great help. you can email me (ml_j13@yahoo.co.in )

  15. Ankit
    July 25th, 2012 at 02:04 | #15

    Hello Uri,

    I have got the same problem as mayur had discuss with you.
    Please send me the running sample code.
    ankitsabharwal90@gmail.com

  16. July 25th, 2012 at 03:08 | #16

    I’m sorry, but I haven’t been doing this for a while, so I am not sure where the problem might be. The sample code (http://urinieto.com/iPhone/YouTubeTest.zip) used to work for me.
    Good luck, and thanks for reading and commenting!

  17. Saba
    August 3rd, 2012 at 02:30 | #17

    Hi,
    I had the same error
    Domain=com.google.GDataServiceDomain Code=400 “The operation couldn’t be completed.

    But when i reduce the keywords lenght its working fine

    Thanks uri

  18. Saba
    August 8th, 2012 at 02:11 | #18

    Hello Uri,

    I have tried this in xcode 4.2 with ios5. I have done the required configuration that you have specified above and also tried http://code.google.com/p/gdata-objectivec-client/wiki/BuildingTheLibrary
    But when i run the code and try to upload video the app crashes on error
    *** Assertion failure in -[GDataServiceBase fetchObjectWithURL:objectClass:objectToPost:ETag:httpMethod:delegate:didFinishSelector:completionHandler:retryInvocationValue:ticket:]
    Please help

  19. vinay kumar
    September 6th, 2012 at 09:26 | #19

    can we upload Video on youtube channel in background through iphone

  20. October 30th, 2012 at 00:51 | #20

    it shows 403 error code and You tube account is not linked….

  21. Karthick
    November 6th, 2012 at 08:13 | #21

    hi i need sample source code to upload video from iphone to Youtube, but i had been this codes from (http://urinieto.com/iPhone/YouTubeTest.zip) and ( dl.dropbox.com/u/45432200/YouTubeVUpload%2030th%20May-2012.zip), but still i need one more example code

  22. Karthick
    November 6th, 2012 at 08:15 | #22

    hi i need sample source code to upload video from iphone to Youtube, but i had been tried this codes from (http://urinieto.com/iPhone/YouTubeTest.zip) and ( dl.dropbox.com/u/45432200/YouTubeVUpload%2030th%20May-2012.zip), but still i need one more example code

  23. Meganthan
    December 15th, 2012 at 02:26 | #23

    Hi uri, this is more helpful for everyone , i followed all your steps as u said .. , everything is good but after i entered username and password i’m getting error like this ( Domain=com.google.GDataService Domain code=403″ The operation couldn’t be completed)..

    I need to integrate this in my app, please tell me any solution or provide any running samples to my mail id ,,, meganathan@bnbinfotech.com ,
    Thanks,,,,,,,,,,

  24. Meganthan
    December 15th, 2012 at 02:39 | #24

    or Please give any other sample tutorial website’s URL

  25. Rahul Gupta
    January 13th, 2013 at 01:59 | #25

    Hi,
    Thanks for for nice tutorial. I have configured everything as you have mentioned here, but when I enter username and password I get following error.

    serviceBase: objectFetcher: failedWithStatus:400 data:GDataInvalidRequestUriExceptionException message unavailable

    Could you please help me.

  26. Chetan
    March 18th, 2013 at 05:42 | #26

    I am getting the below error: please help me ..

    YouTubeTest[799:707] serviceBase: objectFetcher: failedWithStatus:400 data:GDataInvalidRequestUriExceptionException message unavailable

  27. Cindy
    April 25th, 2013 at 04:34 | #27

    I miss this file GDataOAuthAuthentication

  28. Ajith
    April 29th, 2013 at 06:22 | #28

    Thanks Uri for your good post

    But I also met the same issues with status code 400,401,403..

    Finally I could clear all issues one by one. I created a new youtube account for testing this. So i had to create a new channel in youtube, that was my first issue. But the issue was not cleared soon after the channel creation, it took some time, really i dont know why this time delay. All issues cleared when I came back after my lunch.

    Next main issue was 403 error, it took around 2 days for me to clear.. :(

    (GDataServiceGoogleYouTube*) setUserCredentialsWithUsername:username password:password

    In setUserCredentialsWithUsername: the username is the email id of the account with @gmail.com (username@gmail.com)

    but for GDataServiceGoogleYouTube youTubeUploadURLForUserID:username

    the username doesnot need the @gmail.com (only ‘username’ required)

    or else you can directly use

    [GDataServiceGoogleYouTube youTubeUploadURLForUserID:kGDataServiceDefaultUser]

    instead of the other one

    Then use the correct email id (with @gmail.com) and password to upload the video

    Thanks

  29. Rajkumar
    April 29th, 2013 at 06:50 | #29

    Getting error when building.
    Undefined symbols for architecture i386:
    “_OBJC_CLASS_$_GDataOAuthAuthentication”, referenced from:
    objc-class-ref in GDataOAuthViewControllerTouch.o
    “_OBJC_CLASS_$_GDataOAuthSignIn”, referenced from:
    objc-class-ref in GDataOAuthViewControllerTouch.o
    ld: symbol(s) not found for architecture i386
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

    These are the errors.Can any one help me out of this.

  30. Jhimli Sen Mallick
    May 23rd, 2013 at 08:15 | #30

    Thanks Uri for your good post
    But I also met the same issues with status code 400,401,403..

  31. Jhimli Sen Mallick
    May 23rd, 2013 at 08:16 | #31

    Thanks Uri for your good post
    But I also met the same issues with status code 400,401,403..can u help me regarding this problem.then u can send me a mail at jhimli@techbla.in

  32. July 2nd, 2013 at 08:02 | #32

    I downloaded the sample code you provided. Added DEVELOPER_KEY & CLIENT_ID to it. But i am unable to make it working. Compiler gives 19 errors:

    unknown type name ‘GDataOAuthAuthentication’ in GDataOAuthViewControllerTouch.

    Can you help me out whats wrong with the Sample Code.

  33. July 2nd, 2013 at 09:18 | #33

    Suraj Mirajkar :
    I downloaded the sample code you provided. Added DEVELOPER_KEY & CLIENT_ID to it. But i am unable to make it working. Compiler gives 19 errors:
    unknown type name ‘GDataOAuthAuthentication’ in GDataOAuthViewControllerTouch.
    Can you help me out whats wrong with the Sample Code.

    Now i resolved the issue and compiler shows 3 errors that Rajkumar is getting:
    Undefined symbols for architecture i386:
    “_OBJC_CLASS_$_GDataOAuthAuthentication”, referenced from:
    objc-class-ref in GDataOAuthViewControllerTouch.o
    “_OBJC_CLASS_$_GDataOAuthSignIn”, referenced from:
    objc-class-ref in GDataOAuthViewControllerTouch.o
    ld: symbol(s) not found for architecture i386
    clang: error: linker command failed with exit code 1 (use -v to see invocation).

    Can you help me out.

  34. July 4th, 2013 at 08:20 | #34

    @Suraj Mirajkar

    i followed the link and resolved the issue.:
    http://stackoverflow.com/questions/16884230/youtube-api-error-authentication

    In – (IBAction)uploadPressed:(id)sender method:
    Use
    NSURL *url = [GDataServiceGoogleYouTube youTubeUploadURLForUserID:@"default" clientID:clientID];
    instead of NSURL *url = [GDataServiceGoogleYouTube youTubeUploadURLForUserID:username
    clientID:clientID];

    As Youtube developer site says use “default” in url.

  35. Rajkumar
    July 8th, 2013 at 06:42 | #35

    @Suraj Mirajkar How u getting Client Id.I getting only Dev Key at http://code.google.com/apis/youtube/dashboard/….Still I facing problem to upload a video in youtube.If u resolved it, can u help me.

  36. vikas
    July 16th, 2013 at 07:52 | #36

    hello uri,
    i am glad to use your code. but still now i got a error that file not found. plz help me i m new for ios development

  37. vikas
    July 17th, 2013 at 01:12 | #37

    @Suraj can you hep me i m getting a issue Domain=com.google.GDataServiceDomain Code=403 “The operation couldn’t be completed. (com.google.GDataServiceDomain error 403.)” UserInfo=0x9eb82f0 {Error=BadAuthentication, Info=InvalidSecondFactor, error=BadAuthentication}

  38. vikas
    July 17th, 2013 at 01:14 | #38
  39. Farhan Khan
    August 6th, 2013 at 06:57 | #39

    Hello ,
    I use gdata for uploading mp4 video of high quality from my iphone app. But video on youtube becomes very low quality.
    Please help me.Am seeking your help.

  40. March 6th, 2014 at 05:20 | #40

    I use gdata for uploading mp4 video from my iphone app but I am getting the error:NotLinkedYouTubeAccount. Here I am sending User_ID,Password,Developer Key & Client_ID.
    Kindly help me.

  41. March 6th, 2014 at 07:22 | #41

    Amit Kumar Midya :
    I use gdata for uploading mp4 video from my iphone app but I am getting the error:NotLinkedYouTubeAccount. Here I am sending UserName,Password,Developer Key & Client_ID.
    Kindly help me.

  42. niha
    March 26th, 2014 at 01:48 | #42

    Hello all,
    How can i upload video on specific youtube channel?
    Currently every video i am uploading is uploaded on my channel only!
    Please guide,thanks in advance

  43. Ankur Patel
    June 26th, 2014 at 05:34 | #43

    HI Uti Neto
    Thanks Lot from bottom of my heart
    It is working for me

  44. October 15th, 2014 at 13:36 | #44

    Thanks a lot…

  1. No trackbacks yet.


2 × = six