!! A new, more fully-featured version of this application is available !!
. . . Please click HERE for more details. View a demo site!
- Download/Conversion of YouTube, Dailymotion, Vimeo, Facebook, and Metacafe videos
- Additional converted file types/formats
- Volume adjustment for converted files
- A (cell phone) ringtone creator
- Browser add-on/plugin to facilitate conversions
- And more !!
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!
!! NOW AVAILABLE :: SERVER CONFIG / SCRIPT INSTALLATION VIDEO TUTORIAL !!
I have recorded a 2-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.
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 enabled
6) ffmpeg.exe for Windows & XAMPP/WAMP; FFmpeg and ffmpeg-php packages enabled for Linux
7) That's it!
ATTENTION LINUX USERS. . .
(Important notice to Ubuntu/Debian users!)
If you already have FFmpeg and FFmpeg-PHP 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...
const _FFMPEG = 'ffmpeg.exe';
...depending on where the installation of FFmpeg is located on your server.
const _FFMPEG = '/absolute/path/to/ffmpeg';
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.
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...
// 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).
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.