!! A new, more fully-featured version of this application is available !!
- Download/Conversion of YouTube, Dailymotion, Vimeo, Facebook, Metacafe, VK, and SoundCloud content
- Additional converted file types/formats
- Volume adjustment for converted files
- A (cell phone) ringtone creator + general audio/video cropping tool
- Browser add-on/plugin to facilitate conversions
- And more !!
. . . Please click HERE for more details. View a demo site!
PLEASE CONSIDER MAKING A DONATION if you find this script useful. I find myself providing a lot of free support and maintenance for this code. It would be a great help if I could make a little extra $$ here for my time and effort, and to justify further enhancements to the code. So whaddya say? Help a brother out? :) Thanks in advance!
!! IMPORTANT NOTICE REGARDING SUPPORT REQUESTS !!
A FAQ for troubleshooting common software/server issues is now online !!
Also, please read this post before requesting support for either the free or paid-for version of this software!
!! SIGN UP TO RECEIVE FREE UPDATES ABOUT THIS SOFTWARE !!
Now you can provide your email address to get free updates about new software version releases, features, and bug fixes!!
!! NOW AVAILABLE :: SERVER CONFIG / SCRIPT INSTALLATION VIDEO TUTORIAL !!
I have recorded a 3-part series of instructional videos explaining the configuration/installation steps required to install the free version of my software on an Ubuntu server.
!! IMPORTANT SOFTWARE VERSION UPDATES !!
As needed, I will periodically post updates here to this code. Each update will be accompanied by an attached ZIP file (with the date of the update as the ZIP file name) that contains the updated files.
3-5-11: An important update to the code is described HERE. You must implement this fix in order to continue using this app without issues!
8-3-11: YouTube changed their FLV URLs again! Get the fix HERE to continue using the app without issues.
12-3-11: YouTube changed the front end of their site again. Get the fix HERE to continue using the app without issues!
12-25-11: I added a download link after successful MP3 conversion, implemented a conversion process progress bar, and refactored some code. Get the latest version of the app HERE.
2-6-12: Improved progress bar so that it reflects download as well as conversion progress, and made significant changes to the code base/structure. Get the latest version of the app HERE.
2-12-12: Fixed various bugs associated with the download/conversion progress bars. Fully adapted code to work on Linux (Ubuntu) as well as XAMPP for Windows. Get the latest version of the app HERE.
7-24-12: Fixed bug that causes the script to crap out when the downloaded YouTube video is corrupt and/or less than 10kb. Some other minor updates, refactoring of code, and bug fixes. Get the latest version of the app HERE.
9-14-12: YouTube changed their video pages' source code, requiring some tweaking of my code to get the video file download links working again. Get the latest version of the app HERE.
10-6-12: Fixed a bug in which errors could possibly occur when two users simultaneously convert the same YouTube video. Get the latest version of the app HERE.
12-6-12: Per recent changes to YouTube's site front end, I fixed the script's ability to determine a given video's title. Get the latest version of the app HERE.
12-19-12: YouTube changed the format of video file URLs in the video page source code. This fix addresses this change. Get the latest version of the app HERE.
3-3-13: Code now accommodates variations in FFmpeg log file formats, which is required for building the conversion progress bar. Get the latest version of the app HERE.
3-21-13: There was a minor change to the format in which the YouTube video URLs are provided. This fix addresses that change. Get the latest version of the app HERE.
6-16-13: This fix addresses a problem with the conversion of Vevo videos. Get the latest version of the app HERE.
6-22-13: This fix addresses another problem with the conversion of Vevo videos. Get the latest version of the app HERE.
6-28-13: This fix addresses yet another problem with the conversion of Vevo videos. Get the latest version of the app HERE.
7-26-13: YouTube changed the encryption used on video signatures again, and this fix addresses that change. (Vevo and other similar channels were affected.) Get the latest version of the app HERE.
8-1-13: I have introduced an auto-updating feature that automatically updates YouTube video signature decryption code as needed. Get the latest version of the app HERE.
9-18-13: Fixed a bug that periodically caused video downloads to fail on Windows and XAMPP platforms. Get the latest version of the app HERE.
10-18-13: I have improved the auto-updating feature that automatically updates YouTube video signature decryption code as needed. You must update to this version in order to continue converting encrypted videos! Get the latest version of the app HERE.
8-6-14: Fixed a bug with the download progress bar that affects people using PHP 5.5+. Get the latest version of the app HERE.
12-6-14: Fixed bugs affecting video download speed and the ability to download certain YouTube videos in general. Get the latest version of the app HERE.
SERVER REQUIREMENTS. . .
1) Linux, Windows, or XAMPP/WAMP server (important notice to Ubuntu/Debian users)
2) For commercial servers: Shared, Dedicated, and VPS hosting supported
3) Apache or IIS
4) PHP 5.3+
5) cURL and PHP cURL extension enabled
6) ffmpeg.exe for Windows & XAMPP/WAMP; FFmpeg and codecs packages installed on Linux
7) That's it!
Recently, I reeeaally wanted an MP3 audio version of a certain YouTube.com video. I was tired of the online apps that either didn't work or charged you for this service, so I decided to write my own. It was a tad confusing, so I thought I'd share my mini-app with the world to help others who might undertake such an endeavor.Quote:
ATTENTION LINUX USERS. . .
(Important notice to Ubuntu/Debian users!)
If you already have FFmpeg installed on your Linux web server (those with sites hosted on shared servers will need to verify this), then you absolutely can run this app on your site. In this case, Linux configuration is identical to Windows configuration with the following exceptions:
1) ffmpeg.exe is no longer required, so you don't need the file on your server.
2) Change the following line of code in config.class.php:
...to something like...PHP Code:
const _FFMPEG = 'ffmpeg.exe';
...depending on where the installation of FFmpeg is located on your server.PHP Code:
const _FFMPEG = '/absolute/path/to/ffmpeg';
I created the app for my own personal use to run on my Windows development machine using the latest version of XAMPP. I chose this environment for my app because, in this way, I have complete control over server and PHP configurations. And manipulating video and audio files is just plain easier that way. Thus, I suspect that this app won't run in most shared hosting environments (i.e., on a commercial server run by a web hosting company). You'll have to tweak my code in that case...
So, first of all, you will need to download the latest FFmpeg build. I used the Windows 32-bit version. FFmpeg is the software that will ultimately enable you to convert YouTube's FLV video files into MP3 audio files.
Inside the FFmpeg distribution is a /bin/ folder that contains the only file that you'll need: ffmpeg.exe. I have the file in my project/app folder in the web root (htdocs in XAMPP), but you may want to put the file (and other app files/directories) beneath the web root and reference it there (i.e., in a production environment). It's not required for my app to function, but, on a production server, I'm in the habit of putting files there that don't need to be publicly accessible, for extra security. It's your prerogative.
With that in place, you can put both the converter class (YouTubeToMp3Converter.class.php) and example implementation (index.php) into your web root project directory as well. See below for both files:
// Download latest version above to see this code...
Now, add 2 writable sub-directories to your app directory: I called them "mp3" (where the resulting MP3 files appear) and "videos" (where YouTube FLV files are temporarily stored during conversion).PHP Code:
// Download latest version above to see this code...
To help you visualize, in XAMPP, my final directory structure appears as follows:
I'll let you figure out the majority of the code on your own. In a nutshell, the converter class grabs the YouTube FLV url using some regex, downloads the video with cURL, then converts the FLV to MP3 audio by invisibly running FFmpeg in a command shell (with PHP's exec()).
A few things:
1) As I said earlier, the app won't run on commercial servers that have disabled shell access (see use of exec() function in code).
2) The regex to get the FLV urls (and other video information) will undoubtedly break the next time Google drastically overhauls their site....which they did recently....Alternatively, there is probably some API available for grabbing the videos, and maybe one of these days I will integrate that into the code.
3) If you need help with FFmpeg command line flags and general syntax, take a look at the FFmpeg documentation.
4) You will probably want to add some additional data validation/sanitization, as I only coded the minimum required for my needs.
I may update this app periodically if I feel like it. I'm sure it can be improved.
Let me know if you have any questions.