Loading...
Logo
Processing Forum
Hey All,

I'm working on an interactive installation where users are recorded via webcam. The footage is then uploaded to the web via the youtube API.

Issue: I am not an able programmer, and really need to know how to do this.

Copy code
  1. //***** Webcam Capture and display with Social media integration *****
  2. //**** SJ, Victoria University of Wellington ****


  3. import com.google.gdata.client.Query;
  4. import com.google.gdata.client.Service;
  5. import com.google.gdata.client.youtube.YouTubeQuery;
  6. import com.google.gdata.client.youtube.YouTubeService;
  7. import com.google.gdata.data.Category;
  8. import com.google.gdata.data.Entry;
  9. import com.google.gdata.data.Feed;
  10. import com.google.gdata.data.TextContent;
  11. import com.google.gdata.data.extensions.Comments;
  12. import com.google.gdata.data.extensions.FeedLink;

  13. import com.google.gdata.data.youtube.FeedLinkEntry;
  14. import com.google.gdata.data.youtube.PlaylistEntry;
  15. import com.google.gdata.data.youtube.PlaylistFeed;
  16. import com.google.gdata.data.youtube.PlaylistLinkEntry;
  17. import com.google.gdata.data.youtube.PlaylistLinkFeed;
  18. import com.google.gdata.data.youtube.SubscriptionEntry;
  19. import com.google.gdata.data.youtube.SubscriptionFeed;
  20. import com.google.gdata.data.youtube.UserProfileEntry;
  21. import com.google.gdata.data.youtube.VideoEntry;
  22. import com.google.gdata.data.youtube.VideoFeed;
  23. import com.google.gdata.data.youtube.YouTubeMediaContent;
  24. import com.google.gdata.data.youtube.YouTubeMediaGroup;
  25. import com.google.gdata.data.youtube.YouTubeNamespace;
  26. import com.google.gdata.util.ServiceException;


  27. import com.google.common.collect.*;
  28. import com.google.gdata.client.*;
  29. import com.google.gdata.client.youtube.*;
  30. import com.google.gdata.data.*;
  31. import com.google.gdata.data.geo.impl.*;
  32. import com.google.gdata.data.media.*;
  33. import com.google.gdata.data.media.mediarss.*;
  34. import com.google.gdata.data.youtube.*;
  35. import com.google.gdata.data.extensions.*;
  36. import com.google.gdata.util.*;


  37. import java.io.BufferedReader;
  38. import java.io.File;
  39. import java.io.IOException;
  40. import java.io.InputStreamReader;
  41. import java.io.PrintStream;
  42. import java.net.URL;


  43. import java.io.IOException;
  44. import java.io.OutputStreamWriter;
  45. import java.io.UnsupportedEncodingException;
  46. import java.net.HttpURLConnection;
  47. import java.net.URL;
  48. import java.net.URLEncoder;

  49. import processing.video.*;
  50. import processing.net.*;

  51. import java.util.Iterator; 
  52. import java.util.LinkedList;
  53. import java.util.List;


  54. Capture myCapture; //get video feed
  55. MovieMaker mm; //declear MovieMaker object
  56. Timer timer; // declear the Timer
  57. PFont font; //initiate font useage
  58. Client localClient;
  59. Service service;

  60. String developer_key = "DEVELOPER KEY HERE";

  61. String YOUTUBE_URL = "http://gdata.youtube.com/feeds/api/videos";
  62. YouTubeService Service;
  63. YouTubeQuery query;
  64. MalformedURLException e;





  65. void setup() {
  66.   
  67.   try {
  68.     query = new YouTubeQuery(new URL(YOUTUBE_URL));
  69.     } catch (MalformedURLException e){
  70.       println("ERROR " +e.getMessage());
  71.     } catch (IOException e){
  72.       println("ERROR " +e.getMessage());
  73.     }

  74.     service = new YouTubeService("DEVELOPER KEY HERE");

  75.   //set the size of the window
  76.   size(1024, 768);
  77.   //setup the video file that will be recorded
  78.   mm=new MovieMaker(this, width, height, "EmotionalCapture.mov", 30, MovieMaker.H263, MovieMaker.HIGH);
  79.   //setup the capture system for video capture
  80.   myCapture=new Capture(this, 640, 480, 30);
  81.   //initiate the timer
  82.   //timer=new Timer(5, 5);
  83.   //setup the text message(s)
  84.   font = loadFont ("Helvetica-36.vlw");
  85. }

  86. void captureEvent(Capture myCapture) {
  87.   myCapture.read();
  88. }


  89. void draw() {
  90.   background(#FFFFFF);
  91.   myCapture.read();
  92.   image(myCapture, 190, 150);
  93.   mm.addFrame(); // Add frames to the video - start video record
  94.   //timer.update();
  95.   textFont(font, 36);
  96.   text ("Show me how you are feeling..", 240, 700);
  97.   fill (0);
  98.   println("Simon is awesome");
  99. }


  100. void keyPressed() {
  101.   if (key == 'q') {
  102.     //Finish the movie if the 'q' button is pressed
  103.     mm.finish();

  104.     
  105.                           //*****  Upload the File to youtube *****
  106.                           
  107.     VideoEntry newEntry = new VideoEntry();

  108.     YouTubeMediaGroup mg = newEntry.getOrCreateMediaGroup();
  109.     mg.setTitle(new MediaTitle());
  110.     mg.getTitle().setPlainTextContent("My Test Movie");
  111.     mg.addCategory(new MediaCategory(YouTubeNamespace.CATEGORY_SCHEME, "Installation"));
  112.     mg.setKeywords(new MediaKeywords());
  113.     mg.getKeywords().addKeyword("cars");
  114.     mg.getKeywords().addKeyword("funny");
  115.     mg.setDescription(new MediaDescription());
  116.     mg.getDescription().setPlainTextContent("My description");
  117.     mg.setPrivate(false);
  118.     mg.addCategory(new MediaCategory(YouTubeNamespace.DEVELOPER_TAG_SCHEME, "Kapziel"));
  119.     
  120.     newEntry.setLocation("Te Aro Design Schoool, Wellington");
  121.     // alternatively, one could specify just a descriptive string
  122.     // newEntry.setLocation("Mountain View, CA");

  123.     MediaFileSource ms = new MediaFileSource(new File("file.mov"), "video/quicktime");
  124.     newEntry.setMediaSource(ms);

  125.     String uploadUrl =
  126.       "http://uploads.gdata.youtube.com/feeds/api/users/default/uploads";

  127.    // VideoEntry createdEntry = service.insert(new URL(uploadUrl), newEntry);


  128.     println("upload complete");
  129.     exit();
  130.     
  131.   }
  132. }

Sorry for the messy code, it is currently early early morning.. I also start installing this in my exhibition space very soon. So would love to figure out how to do this ASAP. Also, there are some aspects in there that are now redundant, such as the timer; which was an original element, but not not so much.


Back to the Red Bull.

Thanks in advanced,


S.

Replies(2)

So... what's the problem ?
Is your sketch working ?
Sketch brings up video feed, will record, but I have not a clue where to go from there. Upon pressing the 'q' button, I want it to end the video capture, finish recording (mm.finish) and then upload the subsequent video to youtube.

Cheers,

S.