Search code examples
pythonvideo-streamingresolution

Python: Get resolution of videos from streaming links


I am pretty new to Python. I am currently using version 3.3.2. I have an array of links to sources of streaming videos. What I want to do is sort them between HD(>720p) and non-HD(<720p) videos. I have been searching the internet, but the only closest I got to was a ffmpeg python wrapper https://code.google.com/p/pyffmpeg/.

So I wanted to know if it is even possible? If yes, can you please link me to some resources, or what keywords I should be searching on google?

Regards


Solution

  • The easy way to do this is to use the web service API for each site.

    For example, the YouTube API lets you issue a search and get back metadata on all of the matching videos. If you look at the video, properties, you can check definition == 'hd', or you can iterate the videoStreams for the video and check whether heightPixels >= 720 or bitrateBps >= 8*1024*1024 or whatever you think is an appropriate definition for "HD" if you don't like theirs.

    You can find the APIs for most sites by just googling "Foo API", but here are links for the ones you asked about:

    • Daily Motion
    • Metacafe: I can't find the API docs anymore, but it's just simple RSS feeds.
    • YouTube

    The hard way to do this is to write a universal video downloader—which is very, very hard—and process the file with something like pyffmpeg after you download it (or, if you're lucky, after you've only downloaded part of it).