OUseful.Info, the blog…

Trying to find useful things to do with emerging technologies in open education

Twitter Powered Subtitles for Conference Audio/Videos on Youtube

Last week, I wrote a post on hHow people Tweeted Through Carter on “Delivering Digital Britain” at NESTA, where I created a slideshow of tweets posted in response to the NESTA Delivering Britain event/video stream and used them to illustrate the audio recording of Lord Carter’s presentation.

Chatting to @liamgh last week, I mentioned how i was stumped for an easy way to do this. He suggested creating a subtitles feed, and then uploading it to Youtube, along with the audio recording (doh!).

So – here’s a proof of concept result of doing just that:

(Actually, I’m not sure that subtitles/closed captions work in the embedded movies, so you may have to click through: proof of concept use of Tweets as subtitles: Carter at ‘Delivering Digital Britain’, part 1. NB it is possible force embedded videos to show captions, as
Learn More: Showing captions by default
describes. Simply add &cc_load_policy=1 to the embed code; so e.g. in WordPress, you would use something like [youtube=http://www.youtube.com/watch?v=tBmFzF8szpo&cc_load_policy=1 ].
)

And here’s how I did it…

The first thing to do was check out how Youtube handled subtitles: Getting Started: Adding / Editing captions.

The trick is to upload a textfile with lines that look something like this:
0:03:14.159
Text shown at 3 min 14.159 sec for an undefined length of time.

0:02:20.250,0:02:23.8
Text shown at 2 min 20.25 sec, until 2 min 23.8 sec

Secondly – getting the list of tweets hashtagged with #carter over the period Lord Carter was speaking (i.e. the period covered by the video). For the original proof of concept, I used the tweets from the spreadsheet of scraped tweets that @benosteen grabbed for me, though it later occurred to me I could get the tweets direct from a Twitter search feed (as I’ll show in a minute).

Scraped tweet timestamp

The question now was how to get the timecode required for the subtitles file from the timestamp associated with each tweet. Note here that the timecode is the elapsed time from the start of the video. The solution I came up with was to convert the timestamps to universal time (i.e. seconds since midnight on January 1st 1970) and then find the universal time equivalent of the first tweet subtitle; subtracting this time from the universal time of all the other tweets would give the number of seconds elapsed from the first tweet, which I could convert to the timecode format.

As to how I got the universal time values – I used a Yahoo pipe (Twitter CSV to timeingsd):

At this point, it’s probably worth pointing out that I didn’t actually need to call on @benosteen’s tweetscraper – I could just use the Twitter search API (i.e. the Twitter advanced search feed output) to grab the tweets. How so? Like this:

Looking at the results of this query, we see the timing is a little off – we actually need results from 8.30am, the actual time of the event:

Which is where this comes into play – searching for “older” results:

If you click on “Older” you’ll notice a new argument is introduced into the search results page URL – &page=:

…which means that by selecting appropriate values for rpp= and page= we can tunnel in on the results covering from a particular time by looking at “older” results pages, and grabbing the URL for the page of results covering the time period we want:

Then we can grab the feed:

which gives us something like this:
http://search.twitter.com/search.atom?q=+%23carter+since%3A2009-02-24+until%3A2009-02-24

which we hack a little to get to the right period:

http://search.twitter.com/search.atom?q=+%23carter+since%3A2009-02-24+until%3A2009-02-24&page=4&rpp=100

(For more info on the Twitter search API, see the Twitter Search API Documentation wiki.)

NB while I’m at it, note that there’s a corollary hack here that might
come in useful somewhere, or somewhen, else – getting a Twitter search feed into a Google spreadsheet (so we can, for example,process it as a CSV file published from the spreadsheet):

=ImportFeed("http://search.twitter.com/search.atom?rpp=100&page=4&q=+%23carter+since%3A2009-02-24+until%3A2009-02-24")

That is:

Okay – back to the main thread – and a tweak to the pipe to let us ingest the feed, rather than the spreadsheet CSV:

Just by the by, we can add a search front end to the pipe if we want:

and construct the Twitter search API URI accordingly:

(The date formatter converts the search date to the format required by the Twitter search API; it was constructed according to PHP: strftime principles.)

Ok – so let’s recap where we’re at – we’ve now got a pipe that will give us universal timecoded tweets (that’s not so far for such a long post to here, is it?!) If we take the JSON feed from the pipe into an HMTL page, we can write a little handler that will produce the subtitle file from it:

Here’s the code to grab the pipe’s JSON output into an HTML file:

var pipeUrl="http://pipes.yahoo.com/pipes/pipe.run?_id=Dq_DpygL3hGV7mFEAVYZ7A&aqs";

function ousefulLoadPipe(url){

var d=document;
var s=d.createElement('script');
s.type='text/javascript';

var pipeJSON=url+"&_render=json&_callback=parseJSON";
s.src=pipeJSON;
d.body.appendChild(s);
}
ousefulLoadPipe(pipeUrl);

Here’s the JSON handler:

function parseJSON(json_data){
var caption; var timestamp=0; var mintime=json_data.value.items[0]['datebuilder'].utime;
for (var i=0; itimestamp) mintime=timestamp;
}

for (var j=json_data.value.items.length-1; j>=0; j--) {
caption=json_data.value.items[j]['title'];
timestamp=1*json_data.value.items[j]['datebuilder'].utime;
if (j>0) timeEnd=(1*json_data.value.items[j-1]['datebuilder'].utime)-3; else timeEnd=10+1*json_data.value.items[j]['datebuilder'].utime;
if (timeEnd<timestamp) timeEnd=timestamp+2;
timecode=getTimeCode(timestamp-mintime);
timeEnd=getTimeCode(timeEnd-mintime);
var subtitle=timecode+","+timeEnd+"
"+caption+"<br/><br/>";
document.write(subtitle);
}
}

Here’s the timecode formatter:

//String formatter from: http://forums.devshed.com/javascript-development-115/convert-seconds-to-minutes-seconds-386816.html
String.prototype.pad = function(l, s){
return (l -= this.length) > 0 ? (s = new Array(Math.ceil(l / s.length) + 1).join(s)).substr(0, s.length) + this + s.substr(0, l - s.length) : this; };

function getTimeCode(seconds){
var timecode="00:"+(Math.floor(seconds / 60)).toFixed().pad(2, "0") + ":" + (seconds % 60).toFixed().pad(2, "0")+".0";
return timecode;
}

(I generated the timecodes in part using a string formatter from http://forums.devshed.com/javascript-development-115/convert-seconds-to-minutes-seconds-386816.html.)

Copy and paste the output into a text file and save it with the .sub suffix, to give a file which can then be uploaded to Youtube.

So that’s the subtitle file – how about getting the audio into Youtube? I’d already grabbed an audio recording of Carter’s presentation using Audacity (wiring the “headphones out” to the “microphone in” on my laptop and playing the recording from the NESTA site), so I just clipped the first 10 minutes (I think Youtube limits videos to 10 mins?) and saved the file as a wav file, then imported it into iMovie (thinking I might want to add some images, e.g. from photos of the event on flickr). This crib – iMovie Settings for Upload to YouTube – gave me the settings I needed to export the audio/video from my old copy of iMovie to a file format I could upload to Youtube (I think more recent versions of iMovie support a “Share to Youtube” option?).

I then uploaded this file, along with the subtitles file:

So there we have it: Twitter subtitle/annotations (pulled from a Twitter search feed) to the first part of Lord Carter’s presentation at Delivering Digital Britain…

PS Also on the Twitter front, O’Reilly have started watching Twitter for links to interesting stories, or into particular debates: Twitscan: The Debate over “Open Core”.

Chatting to @cheslincoln the other night, we got into a discussion about whether or not Twitter could be used to support a meaningful discussion or conversation, given the immediacy/short lived nature of tweets and the limited character count. I argued that by linking out to posts to support claims in tweets, “hyper-discussions” were possible. By mining “attention trends” (a term I got from misreading a tweet of Paul Walk’s that scaffold a conversation, it’s possible to create a summary post of a conversation, or argument, like the O’Reilly one?

See also this post from Paul Walk: Anything you quote from Twitter is always out of context.

Written by Tony Hirst

March 8, 2009 at 4:04 pm

13 Responses

Subscribe to comments with RSS.

  1. Definitely a nice idea.

    In terms of getting the tweets via the search api – I did this in my experiment with live blogging using twitter (documented at http://www.meanboyfriend.com/overdue_ideas/2008/10/ili08-liveblog.html and http://www.meanboyfriend.com/overdue_ideas/2008/10/ili08-liveblog.html). As I note I had a few problems with the output (not all apps seemed to like the pipes output) – and found the limit of 100 tweets at a time on the search.twitter.com output frustrating. However, worse than this when I checked back recently I noticed that the tweets were no longer showing – I still don’t know why – the tweets are still there, but the search fails to retrieve them. I guess this latter issue doesn’t matter so much because you are copying the tweets anyway.

    It’s a bit of a shame that Google Spreadsheets can’t handle the time calculations directly – would a different online app do this for you? Zoho or another service?

    Owen Stephens

    March 8, 2009 at 9:10 pm

  2. [...] this to the idea of tweeted Youtube movie subtitles (Twitter Powered Subtitles for Conference Audio/Videos on Youtube) it strikes me that a similar model is [...]

  3. [...] Twitter Powered Subtitles for Conference Audio/Videos on Youtube « OUseful.Info, the blog&hell… – The method is a bit labor intensive (and some might say technical), but it can be used to create subtitles for a YouTube video – where the subtitles are Tweets that happened during the event in the video, such as a presentation for instance. Very cool. I suspect this will be much easier soon. [...]

  4. [...] Tags: subtitles, youtube Pretty much all the sentiment I’ve picked from my post on Twitter Powered Subtitles for Conference Audio/Videos on Youtube is that the process for generating the subtitles is too complicated, so I’ve had a go at [...]

  5. [...] For more info on manipulating Twitter search feeds, see Twitter Powered Subtitles for Conference Audio/Videos on Youtube. [...]

  6. [...] other people's recorded viewing 'as live' tweets). I've pondered this before, e.g. in the sense of Twitter subtitles or anytime commenting (will Wave be able to do that, I [...]

  7. [...] possible use for this data is to combine timestamped tweets with audio/video streams to subtitle a talk with the live tweets. Probably not something I’ve got the time to do but let me know if you try [...]

  8. [...] is brilliant at this – he treats data as a paint brush to create new information canvases (i.e. overlaying twitter feeds to YouTube presentations). Powerhouse Museum is channeling Tony: About NSW – an important post [...]

  9. [...] brilliant at this – he treats data as a paint brush to create new information canvases (i.e. overlaying twitter feeds to YouTube [...]

  10. [...] as a way of capturing subtitle like commentary for recordings of live presentations (e.g. Twitter Powered Subtitles for Conference Audio/Videos on Youtube, Twitter Powered Youtube Subtitles, Reprise: Anytime Commenting, Easier Twitter Powered Subtitles [...]

  11. [...] idea of Twitter Powered Subtitles for Conference Audio/Videos on Youtube was first proposed in March 2009 by Tony Hirst which presented a method for extracting conference [...]

  12. [...] can use the Twitter stream to augment/add commentary to conference videos: Twitter Powered Subtitles for Conference Audio/Videos on Youtube. THis has the added benefit of providing search hooks into the video: Searching the Backchannel – [...]

  13. [...] Each Other…,  Visualising Twitter User Timeline Activity in R, Blogging Academic Lectures, Twitter Powered Subtitles for Conference Audio/Videos on Youtube and  Searching the Backchannel – Martin Bean, OU VC, Twitter Captioned at [...]


Comments are closed.

Follow

Get every new post delivered to your Inbox.

Join 768 other followers

%d bloggers like this: