How to stream only audio data from youtube video on my application?

Aishwarya Shiva picture Aishwarya Shiva · Feb 12, 2012 · Viewed 23.6k times · Source

I want to develop an application that will display a list of videos from YouTube and when the user clicks a Youtube video, my application will start playing its audio. I came across a solution to download the YouTube video first and extract audio, but to speed up the process I want to directly transfer the audio bits to my application's audio player instead of video. In other words, I want to stream YouTube audio instead of video in my application.

Answer

Multimedia Mike picture Multimedia Mike · Mar 6, 2012

It sounds like you are already most of the way there. Your application has a way to list the videos and download selected ones. You just need an infrastructure for playing the audio directly from the video files.

YouTube videos can either be FLV or MP4 files. Inside these files can be MP3 or AAC audio (some other audio codecs are possible, but you won't encounter those on YouTube). This means your app needs to know how to take apart FLV and MP4 files directly, and how to decode MP3 and AAC audio directly to PCM. There are libraries to help with these tasks, depending on your language and platform.