views:

254

answers:

2

I'm building some YouTube search functionality into an iPhone app and want to ensure that I only receive results that will be playable on the device. According to the Searching for videos section in the API reference doc this seems to be relatively straightforward:

The format parameter specifies that videos must be available in a particular video format. Your request can specify any of the following formats:

I've tried setting "format=1" to limit to:

RTSP streaming URL for mobile video playback. H.263 video (up to 176x144) and AMR audio.

This provides a high proportion of playable videos but some are still unplayable and I'm worried that it's not returning others that would be playable.

When I leave the format field blank I receive an even higher proportion of non-streamable URLs.

+2  A: 

This does not sound appropriate. My understanding is that iPhone does not stream RTSP rather it supports Apple's HTTP Streaming of segmented files for live and HTTP streaming of MPEG4 video files via range requests. I'd also expect the video to be H.264 and AAC audio.

Your setting sounds appropriate for low-end cellphones In particular, the 176x144 is a QCIF resolution commonly used on non-smartphones.

J. Fritz Barnes
Yeah I expected to see a H.264 option for filtering too but it doesn't seem to be there. I actually seem to receive better (higher proportion playable) results by leaving out this filter option altogether.
prendio2
I take that back — I am now receiving a huge amount of unplayable videos when searching without filtering
prendio2
A: 

When you look at the XML file returned by a call to

http://gdata.youtube.com/feeds/api/videos/<your video id>

then you will notice that videos which are not playable on the iPhone will have the following tag:

<yt:state name='restricted' reasonCode='limitedSyndication'>Syndication of this video was restricted by its owner.</yt:state>

Just make sure to look for the above tag and ignore the video if the tag is present.

Mike Holenderski