File Exchange

image thumbnail

Upload a Video to YouTube™

version (232 KB) by Matthew Simoneau
Using the Youtube™ data API, upload a video directly from MATLAB®.


Updated 01 Sep 2016

View Version History

View License

This MATLAB function will send a video directly to YouTube, along with the most important metadata.
1) Download and unzip the GData Java™ Client Library, available at

2) Add the full path to gdata-youtube-1.0.jar to your classpath.txt and restart. Just using JAVAADDPATH doesn't work.

Cite As

Matthew Simoneau (2021). Upload a Video to YouTube™ (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (9)

jj rice

Lee White

I had major issues with this download. Tried multiple version of the gdata API and emailed the author. I agree with Nathan that the easiest way to do upload from matlab is using GoogleCL. Protip: to upload videos to youtube from matlab as 'unlisted' get the latest version of GoogleCL using SVN. Then you will need to enter the following command in matlab: DOS(python youtube post "filename.avi" --category Tech --access=unlisted --Title "It works!"

Nathan Orloff

I get emailed about this a lot. This code is not so useful. You should install the google command line utility and then do it that way.

Yeah. It can be done. You need to install the google command line utility and all the associated api's. Then you have to enable your youtube account as a developer. Then you can do it.

This guys code is basically useless. I had to do it all myself. The easiest way to do it is through the command line. That way you dont have to modify all the .jar files on the path. Also, it is much faster and matlab is really prone to memory leaks.

Once you get all that stuff setup, which is by no means straightforward. Something like the following should work.

function req_url = im_uploadmovie(game_id,moviedir,game_str)
% im_uploadmovie
% im_uploadmovie automatically uploads a game movie to youtube.

% See also im_makemovie

% Version 1.0, 2011-10-21..
movie_file = [moviedir '\movie_game_id_' num2str(game_id) '.mp4'];
commandline_str = ['google youtube post ' ...
'--category Games '....
'--summary "' strrep(game_str,sprintf('\n'),' ') '"'...
' "' movie_file '"'];
[~, results_str] = system(commandline_str);
ind = strfind(results_str,'Video uploaded:');
raw_url = results_str(ind:end);

Nathan Orloff

The problem with this code is in the developerKey, clientid. I think these are expired so you need to register with google API to get your own. I modified the code to allow you to set the privacy settings, and also work for an arbitrary movie type instead just .avi. Send me an email if you want it.

Nathan Orloff

Sheesh. This is a long error message. I am sorry about this. I tried making a new account but I am having trouble with the username and password. I don't understand why it isn't logging in. Do you have ideas why this might be happening? I have checked the username and password several times to verify that they are correct.
Error using
Java exception occurred: Error connecting with login

Caused by: The issuer can not be found in the trusted
CA list.
at ice.ssl.SSLSocket.processEvent(OEAB)
at ice.ssl.SSLSocket.certCallback(OEAB)
at ice.ssl.SSLSocket.append(OEAB)
at ice.ssl.SSLSocket.startHandshake(OEAB)
at ice.ssl.SSLSocket.IVSize(OEAB)
at ice.ssl.SSLSocket.getInputStream(OEAB)
... 4 more


This looks very useful (for us). However, the latest java is gdata-youtube-2.0.jar. I think this may be why I can't get this function to work. (I get a youtubeservice error).

Matthew Simoneau

Urs, don't you know? I'm from the future!

hUser aUser

Excellent! Glad to see this. I have tried myself to get a similar function working for uploading MATLAB pics to picasaweb using a similar api from google. But I did not have any luck.

Urs (us) Schwarz

very spiffy, matthew! however, what's MUCH more interesting: the html was published using version 7.7(!) already - whilst the pedestrians just received 7.6...

MATLAB Release Compatibility
Created with R2008a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!