YouTube Video Workflow Using the API
This week has been completely consumed with getting video from the Iowa State Fair processed and up on our website. On an average week, we process 2 or 3 videos. This week, it's been 12-15 videos a day. We normally host our online video on an external CDN, serving it up on our site via a custom implementation of JW Player. For Fair, we publish the videos to YouTube, to maximize the exposure they can get that way (we also process the stills and upload them to Flickr with links back to the video). Unfortunately, publishing videos to YouTube adds a couple of steps to our process, which is obviously not ideal when you're processing 15 videos a day.
To illustrate, here's our regular video publishing workflow:
- Export the video from Avid to QuickTime.
- Grab stills from the video and resize/crop to three sizes (full size, video poster and thumbnail).
- Upload resized stills to our server.
- Drop the QuickTime video on a Rhozet Carbon Coder watch folder. Rhozet then encodes and resizes the video into the final format (512x288, H.264, MP4) and FTPs the encoded file to our CDN.
- Create a record in our Media Library admin and fill in the metadata, including the locations of the stills and the video files.
- Preview the record and publish.
Here's the YouTube publishing workflow:
- Export the video from Avid to QT.
- Grab stills and resize/crop.
- Upload resized stills to our servers.
- Drop the QuickTime on a watch folder. Rhozet adds bumpers on the front and back ends, resizes and encodes the video.
- Manually upload the video to YouTube (set in unlisted mode) and wait for it to encode (again).
- Upload the stills to Flickr.
- Create a record in the Media Library and fill in the metadata, including the location of the video on YouTube, once it's encoded, and the relevant Flickr tags, to pull in photos.
- Copy the metadata to Flickr.
- Copy the metadata to YouTube.
- Preview the record and publish on our admin.
- Publish the video on YouTube.
- Any time you change the metadata, replicate the changes on YouTube.
In an effort to simplify this process, I added a feature to the Media Library admin a year or so ago that eliminates the last step. I made use of a ColdFusion component called YouTube CFC to hook up our admin to YouTube's servers. Basically, any time you save a record in our admin:
- It checks to see if the attached video file is from YouTube,
- If it is, it updates the YouTube record with the metadata from our admin.
- If you publish the record in our admin, it also publishes in YouTube (the reverse also works).
- If you don't have a thumbnail and poster image set, it grabs those from YouTube and upadates our admin to reference them. (For Fair, we're still processing stills manually for finer control, but when that level of control isn't needed, it's a big time-saver.)
Here's the relevant scrap of CF code:
<cfset var youtube_data = {
title = '', desc = '', categories = '', keywords = '', active = '', vid_id = ''
} />
<!--- update youtube video --->
<cfif StructKeyExists(data, 'vid_filename')
AND data.vid_filename CONTAINS "youtube.com">
<!--- get youTube video ID --->
<cfset youtube_data.vid_id = ReReplaceNoCase(data.vid_filename,
'http://(www\.)?youtube.com(/watch\?v=([^&]+)(.*)?)?', '\3')>
<!--- set video thumb and poster from YouTube if none exist --->
<cfif data.vid_thumb EQ ''>
<cfset data.vid_thumb =
'http://i.ytimg.com/vi/' & data.youtube_id & '/default.jpg'>
</cfif>
<cfif data.vid_poster_image EQ ''>
<cfset data.vid_poster_image =
'http://i.ytimg.com/vi/' & data.youtube_id & '/hqdefault.jpg'>
</cfif>
<cfif data.vid_is_local EQ 1 AND youtube_data.vid_id NEQ ''
AND youtube_data.vid_id DOES NOT CONTAIN '/'>
<!--- get data to send to YouTube --->
<cfset youtube_data.title = XMLFormat(data.vid_title)>
<cfset youtube_data.keywords = XMLFormat(data.vid_tags)>
<cfset youtube_data.desc = strip_tags(data.vid_desc_long)>
<cfset youtube_data.desc = XMLFormat(youtube_data.desc
& chr(10) & chr(13) & "View IPTV's videos, photos and on-the ground
coverage of the Iowa State Fair at http://www.iptv.org/fair")>
<cfset youtube_data.active = data.vid_active>
<cfset youtube_data.categories = "Travel">
<cftry>
<!--- instantiate youtube API object --->
<cfset yt = createObject("component", "uberadmin.components.youtube")>
<!--- log in to YouTube --->
<cfset yt.setDeveloperKey("Your developer key goes here")>
<cfset yt.login("YouTube username", "YouTube password")>
<!--- update el youtube video --->
<cfset ytresponse = yt.update(
<!--- Title --->youtube_data.title,
<!--- description --->youtube_data.desc,
<!--- categories --->youtube_data.categories,
<!--- keywords --->youtube_data.keywords,
<!--- active? true/false --->youtube_data.active,
<!--- videoID --->youtube_data.vid_id
)>
<cfcatch></cfcatch>
</cftry>
</cfif>
</cfif>
This has been an enormous time-saver this week. With this in place, our YouTube process is back down to 8 steps:
- Export the video from Avid to QT.
- Grab stills and resize/crop. Upload resized stills to our servers.
- Drop the QuickTime on a watch folder. Rhozet adds bumpers on the front and back ends, resizes and encodes the video.
- Manually upload the video to YouTube (set in unlisted mode) and wait for it to encode (again).
- Upload the stills to Flickr.
- Create a record in the Media Library and fill in the metadata, including the location of the video on YouTube, once it's encoded, and the relevant Flickr tags, to pull in photos.
- Copy the metadata to Flickr.
- Preview the record and publish on our admin.
Post new comment