Understanding Video Media Entries In flickr.photos.getSizes
The Problem
While most people think of photos when they consider Yahoo’s Flickr service, video media has also been supported for quite some time. When a software developer wants to use Flickr’s REST services to give a user the option to view the various video formats supported, the documentation for flickr.photos.getSizes does not go far enough, and there aren’t any definitive answers anywhere else on the Internet. Even Flickr’s example doesn’t list any video media or what to expect.
The Solution
Through experimentation, there does appear to be a method to the responses. With today being Thanksgiving Day 2016 in the US, I decided I’d try a search of videos with the text Thanksgiving in them.
- Go to Flickr’s API Explorer page for searching photos at https://www.flickr.com/services/api/explore/flickr.photos.search
- Enter thanksgiving in the field labeled text and be sure its check box is checked.
- Enter videos in the field labeled media and be sure its check box is checked.
- I use JSON response data, but you can choose XML for the Output option if you prefer.
- Click the Call Method… button.
- From the list of results, note or copy a value for any id key.
- Go to Flickr’s API Explorer page for getting the sizes of a photo at https://www.flickr.com/services/api/explore/flickr.photos.getSizes
- Enter the value from Step 6 in the field labeled photo_id.
- Click the Call Method… button.
- Depending on which video you chose, there may be video media entries with these values for the label key:
- Video Player: The URL value for the corresponding source key is a video playable by Adobe Flash.
- Site MP4: The URL value for the corresponding source key is an MPEG4 video apparently to be played on desktop computers. The dimensions for the corresponding width and height keys are usually 640 x 480.
- Mobile MP4: The URL value for the corresponding source key is an MPEG4 video apparently to be played on mobile devices. The dimensions for the corresponding width and height keys are usually 480 x 360.
- HD MP4: The URL value for the corresponding source key is an MPEG4 video in high-definition quality.
The MP4 format is fairly ubiquitous, but while I found no videos in any other container types, Flickr may return other types or may do so in the future. In my far-less-than-exhaustive testing, the data pointed to by the source URLs for Site MP4 and Mobile MP4 videos were always the same, but data returned by HD MP4 videos were always higher quality. While I haven’t examined all videos available on Flickr, those which I did, all had entries for Site MP4 and Mobile MP4 but not all had entries for HD MP4. Also, I didn’t encounter any 4K videos, so once videos in that size become available, they may use another label value, but hopefully Flickr will make that known so we don’t have to guess.