Gamasutra is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Gamasutra: The Art & Business of Making Gamesspacer
Share Your Experience: YouTube Integration In Games
View All     RSS
September 16, 2019
arrowPress Releases
September 16, 2019
Games Press
View All     RSS







If you enjoy reading this site, you might also want to check out these UBM Tech sites:


 

Share Your Experience: YouTube Integration In Games


November 22, 2008 Article Start Previous Page 4 of 4
 

Uploading Videos

The demo application already provides request and response operators for authentication, search, and video upload. To simplify the API's usage, I added inline methods that fill in known details of a request, such as which function objects to use, and call YouTubeService::service() internally. A video upload can be achieved with only a few lines of code:

YouTubeService youTubeService("YouTubeDeveloperKey");

YouTubeAuthenticationData authenticationData;
authenticationData.userName = "user";
authenticationData.password = "password";
youTubeService.authenticate(authenticationData);
ASSERT(youTubeService.isAuthenticated());

YouTubeUploadData uploadData;
uploadData.fileName = "screen.ogv";
uploadData.mimeType = "video/ogg";
uploadData.title = "Title";
uploadData.description = "Test upload";
uploadData.category = "Tech";
uploadData.isPrivate = false;
uploadData.developerTag = "TagName";
uploadData.keywords = "1Dot, 2Dots, 3Dots, more";

YouTubeVideoEntry videoEntry;
YouTubeServiceState upload =
youTubeService.upload(uploadData, videoEntry);
ASSERT(upload == YouTubeServiceStates::Ok);

When uploading the video file, you have a number of options that describe the contents, such as title, description, and category. Useful is the developer tag, which is an invisible marker that's only accessible to your application.

This tag can be used in search requests to filter videos uploaded by your application. With the private flag, you can decide whether the video is accessible to everyone or only the user.

Once uploaded, it usually takes 5-10 minutes for YouTube to process the video and enable it for viewing on YouTube's web site. You can check the status of a video under My Account / My Videos / Uploaded Videos for the account that was used to upload the file. You can watch some sample videos on the test account I created for this article.

Summary

As you have seen, adding YouTube upload to your game is straightforward, but requires some planning.

To start with, you need to decide how you are going to record the game footage. From the discussed options, a framebuffer capture is the easiest to add to an existing game, but recording game state or player input gives you more flexibility to apply changes to the recording. If you want to change the camera angle later on, for example, game state recordings allow you to do that.

I chose the Theora video format to turn the recording into a video because the encoder comes with an easy to use reference implementation and doesn't require license fees. Other video formats accepted by YouTube include DivX and most formats of the MPEG suite.

Finally, an application can upload videos with YouTube's RESTful interface; a protocol based on HTTP. The demo application for this article comes with an implementation for authentication, search, and video upload requests that you can use for your own game.

Note: Demo updated 5 January 2009. Note from the author: "Update v1.1: Fixed a bug where I mixed up the color channels when reading from the DirectX render target. DXUT sets the render target to D3DFMT_X8R8G8B8 by default where the color channels are ordered BGRX in memory. For this reason, I added ImageFormat::B8G8R8A8 as a new image format and a new code path to ImageUtils::convertToYCbCr420p() to handle this format."

[EDITOR'S NOTE: This article was independently published by Gamasutra's editors, since it was deemed of value to the community. Its publishing has been made possible by Intel, as a platform and vendor-agnostic part of Intel's Visual Computing microsite.]


Article Start Previous Page 4 of 4

Related Jobs

Hyperkinetic Studios
Hyperkinetic Studios — Los Angeles, CA, California, United States
[09.16.19]

Lead Environmental Artist - Los Angeles
Hyperkinetic Studios
Hyperkinetic Studios — Los Angeles, California, United States
[09.16.19]

Level Designer - Los Angeles
Sucker Punch Productions
Sucker Punch Productions — Bellevue, Washington, United States
[09.16.19]

QA Tester
Daybreak Games
Daybreak Games — Austin, Texas, United States
[09.16.19]

Senior Engine Programmer





Loading Comments

loader image