PDA

View Full Version : YouTube-to-MP3 conversion - PHP class and script



Pages : [1] 2 3 4 5 6 7 8

chump2877
09-20-2010, 01:14 PM
♫… Discover Our Entire Product Line! . . . ♫

http://rajwebconsulting.com/CodingForums/prods3.png (http://rajwebconsulting.com)

. . . . . . . . . . .Something for every need and budget (http://rajwebconsulting.com/#pricing) !! :) :)


!! A new, more fully-featured version (http://www.codingforums.com/showpost.php?p=1217444&postcount=321) of this application is available !!
http://rajwebconsulting.com/VideoConverterDemos/sale2.png (http://www.codingforums.com/showpost.php?p=1217444&postcount=321)



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 (http://www.codingforums.com/showpost.php?p=1217444&postcount=321) for more details. View the official demo (http://www.grabfrom.com/Converter/) as well as a customized demo site (http://www.grabfrom.com)!
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!

https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif (https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=W5SHWS5L4WMDG)
!! IMPORTANT NOTICE REGARDING SUPPORT REQUESTS !!

A FAQ for troubleshooting common software/server issues (https://www.facebook.com/pages/Youtube-to-Mp3-Conversion-Script-Free-Commercial-PHP-Software/128039504063914?sk=app_137541772984354) is now online !!

Also, please read this post (http://www.codingforums.com/showpost.php?p=1312449&postcount=626) 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 (http://www.codingforums.com/showpost.php?p=1344684&postcount=752)!!
!! NOW AVAILABLE :: SERVER CONFIG / SCRIPT INSTALLATION VIDEO TUTORIAL !!

I have recorded a 3-part series of instructional videos (http://www.codingforums.com/showpost.php?p=1338835&postcount=681) 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 (http://www.codingforums.com/post-a-php-snippet/205066-youtube-mp3-conversion-php-class-script-post1061707.html#post1061707): An important update to the code is described HERE (http://www.codingforums.com/post-a-php-snippet/205066-youtube-mp3-conversion-php-class-script-post1061707.html#post1061707). You must implement this fix in order to continue using this app without issues!
8-3-11 (http://www.codingforums.com/showpost.php?p=1119900&postcount=66): YouTube changed their FLV URLs again! Get the fix HERE (http://www.codingforums.com/showpost.php?p=1119900&postcount=66) to continue using the app without issues.
12-3-11 (http://www.codingforums.com/showpost.php?p=1166269&postcount=111): YouTube changed the front end of their site again. Get the fix HERE (http://www.codingforums.com/showpost.php?p=1166269&postcount=111) to continue using the app without issues!
12-25-11 (http://www.codingforums.com/showpost.php?p=1173973&postcount=116): 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 (http://www.codingforums.com/showpost.php?p=1173973&postcount=116).
2-6-12 (http://www.codingforums.com/showpost.php?p=1189685&postcount=136): 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 (http://www.codingforums.com/showpost.php?p=1189685&postcount=136).
2-12-12 (http://www.codingforums.com/showpost.php?p=1192147&postcount=153): 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 (http://www.codingforums.com/showpost.php?p=1192147&postcount=153).
7-24-12 (http://www.codingforums.com/showpost.php?p=1254374&postcount=411): 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 (http://www.codingforums.com/showpost.php?p=1254374&postcount=411).
9-14-12 (http://www.codingforums.com/showpost.php?p=1270108&postcount=449): 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 (http://www.codingforums.com/showpost.php?p=1270108&postcount=449).
10-6-12 (http://www.codingforums.com/showpost.php?p=1277067&postcount=499): 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 (http://www.codingforums.com/showpost.php?p=1277067&postcount=499).
12-6-12 (http://www.codingforums.com/showpost.php?p=1297972&postcount=568): 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 (http://www.codingforums.com/showpost.php?p=1297972&postcount=568).
12-19-12 (http://www.codingforums.com/showpost.php?p=1301087&postcount=573): 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 (http://www.codingforums.com/showpost.php?p=1301087&postcount=573).
3-3-13 (http://www.codingforums.com/showpost.php?p=1317386&postcount=648): 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 (http://www.codingforums.com/showpost.php?p=1317386&postcount=648).
3-21-13 (http://www.codingforums.com/showpost.php?p=1322220&postcount=656): 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 (http://www.codingforums.com/showpost.php?p=1322220&postcount=656).
6-16-13 (http://www.codingforums.com/showpost.php?p=1341336&postcount=689): This fix addresses a problem with the conversion of Vevo videos. Get the latest version of the app HERE (http://www.codingforums.com/showpost.php?p=1341336&postcount=689).
6-22-13 (http://www.codingforums.com/showpost.php?p=1342524&postcount=718): This fix addresses another problem with the conversion of Vevo videos. Get the latest version of the app HERE (http://www.codingforums.com/showpost.php?p=1342524&postcount=718).
6-28-13 (http://www.codingforums.com/showpost.php?p=1343635&postcount=738): This fix addresses yet another problem with the conversion of Vevo videos. Get the latest version of the app HERE (http://www.codingforums.com/showpost.php?p=1343635&postcount=738).
7-26-13 (http://www.codingforums.com/showpost.php?p=1345753&postcount=761): 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 (http://www.codingforums.com/showpost.php?p=1345753&postcount=761).
8-1-13 (http://www.codingforums.com/showpost.php?p=1349221&postcount=807): 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 (http://www.codingforums.com/showpost.php?p=1349221&postcount=807).
9-18-13 (http://www.codingforums.com/showpost.php?p=1358334&postcount=925): Fixed a bug that periodically caused video downloads to fail on Windows and XAMPP platforms. Get the latest version of the app HERE (http://www.codingforums.com/showpost.php?p=1358334&postcount=925).
10-18-13 (http://www.codingforums.com/showpost.php?p=1364524&postcount=971): 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 (http://www.codingforums.com/showpost.php?p=1364524&postcount=971).
8-6-14 (http://www.codingforums.com/post-php-snippet/205066-youtube-mp3-conversion-php-class-script-79.html#post1407447): Fixed a bug with the download progress bar that affects people using PHP 5.5+. Get the latest version of the app HERE (http://www.codingforums.com/post-php-snippet/205066-youtube-mp3-conversion-php-class-script-79.html#post1407447).
12-6-14 (http://codingforums.com/post-php-snippet/205066-youtube-mp3-conversion-php-class-script-88.html#post1425065): Fixed bugs affecting video download speed and the ability to download certain YouTube videos in general. Get the latest version of the app HERE (http://codingforums.com/post-php-snippet/205066-youtube-mp3-conversion-php-class-script-88.html#post1425065).
1-14-15 (http://codingforums.com/post-php-snippet/205066-youtube-mp3-conversion-php-class-script-92.html#post1430688): YouTube recently made a minor change to the way it identifies videos that require signature decryption. This fix addresses that change. Get the latest version of the app HERE (http://codingforums.com/post-php-snippet/205066-youtube-mp3-conversion-php-class-script-92.html#post1430688).
SERVER REQUIREMENTS. . .

1) Linux, Windows, or XAMPP/WAMP server (important notice to Ubuntu/Debian users (http://www.codingforums.com/showpost.php?p=1317352&postcount=646))
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 (http://www.codingforums.com/showpost.php?p=1222520&postcount=323) for Windows & XAMPP/WAMP; FFmpeg and codecs packages installed on Linux
7) That's it!
ATTENTION LINUX USERS. . .

(Important notice to Ubuntu/Debian users! (http://www.codingforums.com/showpost.php?p=1317352&postcount=646))

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:


const _FFMPEG = 'ffmpeg.exe';...to something like...


const _FFMPEG = '/absolute/path/to/ffmpeg';...depending on where the installation of FFmpeg is located on your server.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 (http://www.apachefriends.org/en/xampp-windows.html). 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 (http://www.codingforums.com/showpost.php?p=1222520&postcount=323). 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:

YouTubeToMp3Converter.class.php

// Download latest version above to see this code...index.php

// 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:

C:\xampp\htdocs\VideoToMp3Converiter\mp3
C:\xampp\htdocs\VideoToMp3Converter\videos
C:\xampp\htdocs\VideoToMp3Converter\ffmpeg.exe
C:\xampp\htdocs\VideoToMp3Converter\index.php
C:\xampp\htdocs\VideoToMp3Converter\YouTubeToMp3Converter.class.php

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 (http://ffmpeg.org/ffmpeg-doc.html).

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.

Enjoy!

Lerura
09-21-2010, 12:56 AM
Nice Work!

But I am quite sure that this is against YouTube's TOS (http://www.youtube.com/t/terms):
4.C. says:
"You agree not to access Content through any technology or means other than the video playback pages of the Service itself, the Embeddable Player, or other explicitly authorized means YouTube may designate."

chump2877
09-21-2010, 03:47 AM
Good point, and you are certainly correct to bring that up.

I suppose if using some regex to scrape the HTML of YouTube's public pages is a crime, then my script is guilty as charged. (*Trying not to roll my eyes at corporate bureaucracy*)

So the conclusion that I draw here is that, if you use my app in production, on the internet and/or for commercial gain, you'll need to get the explicit written consent/authorization of YouTube first.

In lieu of that, I presume that YouTube authorizes use of it's own API to gain access to its videos repository: http://www.youtube.com/dev. (This is something that I just discovered 5 minutes ago, actually, and substantiates my proposed use of such an API for future versions of my code, as suggested in my original post...)

One can only hope that the large number of sites out there that advertise YouTube video-to-mp3 audio file conversion are using this API. Only YouTube knows for sure, if they even bother to check.

Nevertheless, thanks again for adding this disclaimer regarding use of my app here and for those that similarly endeavor to piggyback YouTube's web services in general.

Lerura
09-21-2010, 07:10 PM
(*Trying not to roll my eyes at corporate bureaucracy*) Me too!

Looking at 5.C. versus www.youtube.com/dev:

It seems that they don't care THAT you use their files, but if, then want to control HOW you use them. *SIGH*

chump2877
09-23-2010, 08:57 PM
I took a look at the YouTube API, and, unless I'm missing something, even it doesn't expose a method or property that gives the exact URL of a given YouTube FLV video. The API will give you all kinds of information about a video except for the FLV location. See the following URLs:

http://code.google.com/apis/youtube/2.0/developers_guide_php.html#Retrieving_Video_Entry
http://framework.zend.com/apidoc/core/Zend_Gdata/YouTube/Zend_Gdata_YouTube_VideoEntry.html

I guess I'm disappointed, but not entirely surprised. :(

chump2877
09-26-2010, 09:53 AM
Soon after posting my last message on this thread, I realized that the YouTube API does reveal a 3GP file URL for every YouTube video (albeit, presumably inadvertently). 3GP is a mobile device video file extension, for those of you that don't know. It's not FLV, but it is video.

So, with a viable video file source now available to me, I decided to give this video-to-MP3 audio conversion business another stab.

First, you'll need to get yourself a copy of the latest release of the Google Data Client Library (http://framework.zend.com/download/gdata/), as that will provide you with the core classes required to manipulate the YouTube API. Download the ZIP archive, and unpack the contents to your web server, per the instructions detailed here (http://code.google.com/apis/gdata/articles/php_client_lib.html#gdata-installation). I put the files below the web root (for reasons outlined in my initial post of this thread), but let's put it directly in your project folder -- in the web root -- for the sake of simplicity.

Also, for this version of my app, I decided to nix the temporary download of videos in favor of using FFmpeg. I decided to let FFmpeg directly intercept the 3GP video stream and do the MP3 file conversion, all in one easy step. Thus, allowing FFmpeg to shoulder more of the work enables us to no longer need and ultimately delete the 'videos' folder I described in the set up of (for lack of a better name) 'MyApp 1.0' above...

So, again to help you visualize, in XAMPP, my UPDATED final directory structure appears as follows:

C:\xampp\htdocs\VideoToMp3Converter\GoogleDataClientLibrary
C:\xampp\htdocs\VideoToMp3Converter\mp3
C:\xampp\htdocs\VideoToMp3Converter\ffmpeg.exe
C:\xampp\htdocs\VideoToMp3Converter\index.php
C:\xampp\htdocs\VideoToMp3Converter\YouTubeToMp3Converter.class.php

The 'GoogleDataClientLibrary' directory contains the same directory structure as the unzipped API distribution:

C:\xampp\htdocs\VideoToMp3Converter\GoogleDataClientLibrary\demos
C:\xampp\htdocs\VideoToMp3Converter\GoogleDataClientLibrary\documentation
C:\xampp\htdocs\VideoToMp3Converter\GoogleDataClientLibrary\library
C:\xampp\htdocs\VideoToMp3Converter\GoogleDataClientLibrary\tests
C:\xampp\htdocs\VideoToMp3Converter\GoogleDataClientLibrary\INSTALL.txt
C:\xampp\htdocs\VideoToMp3Converter\GoogleDataClientLibrary\LICENSE.txt
C:\xampp\htdocs\VideoToMp3Converter\GoogleDataClientLibrary\README.txt

You only really need the /library/ directory (as that is where you will tell PHP to look for the API files), but I included the rest of the files for the sake of future reference.

With your new directory structure in place, it's time to look at the new versions of the converter class (YouTubeToMp3Converter.class.php) and example implementation (index.php) (both located in your web root project directory). See below for both files:

YouTubeToMp3Converter.new.class.php

<?php
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(dirname(dirname(__FILE__))).'\GoogleDataClientLibrary\library');
require_once 'Zend/Loader.php';

// Conversion Class
class YouTubeToMp3Converter
{
// Private Fields
private $_songFileName = '';
private $_vidUrls = array();
private $_audioQualities = array(64, 128, 160);

// Constants
const _SONGFILEDIR = 'mp3/';
const _FFMPEG = 'ffmpeg.exe';

#region Public Methods
function __construct()
{
}

function ConvertVideo($youTubeUrl, $audioQuality)
{
$videoEntry = $this->CreateVideoEntry($youTubeUrl);
if ($videoEntry != null)
{
$this->SetVidUrls($videoEntry);
$this->SetSongFileName($videoEntry->getVideoTitle());
return ($this->GetSongFileName() != '' && $this->GetVidUrls() != array()) ? $this->GenerateMP3($audioQuality) : false;
}
return false;
}

function ExtractSongTrackName($youTubeUrl)
{
$videoEntry = $this->CreateVideoEntry($youTubeUrl);
return ($videoEntry != null) ? $videoEntry->getVideoTitle() : '';
}

function ExtractVideoId($youTubeUrl)
{
$urlQueryStr = parse_url($youTubeUrl, PHP_URL_QUERY);
if ($urlQueryStr !== false && !empty($urlQueryStr))
{
$kvPairs = explode('&', $urlQueryStr);
foreach ($kvPairs as $v)
{
$kvPair = explode('=', $v);
if (count($kvPair) == 2 && $kvPair[0] == 'v' && !empty($kvPair[1]))
{
return $kvPair[1];
}
}
}
return '';
}
#endregion

#region Private "Helper" Methods
private function CreateVideoEntry($youTubeUrl)
{
$videoEntry = null;
$vidID = $this->ExtractVideoId($youTubeUrl);
if (!empty($vidID))
{
Zend_Loader::loadClass('Zend_Gdata_YouTube');
$yt = new Zend_Gdata_YouTube();
try
{
$videoEntry = $yt->getVideoEntry($vidID);
}
catch (Exception $e)
{
$videoEntry = null;
}
}
return $videoEntry;
}

private function GenerateMP3($audioQuality)
{
$qualities = $this->GetAudioQualities();
$quality = (in_array($audioQuality, $qualities)) ? $audioQuality : $qualities[1];
$vidUrls = $this->GetVidUrls();
foreach ($vidUrls as $url)
{
exec(self::_FFMPEG.' -i '.$url.' -y -acodec libmp3lame -ab '.$quality.'k '.$this->GetSongFileName());
if (is_file($this->GetSongFileName())) break;
}
return is_file($this->GetSongFileName());
}
#endregion

#region Properties
public function GetSongFileName()
{
return $this->_songFileName;
}
private function SetSongFileName($trackName)
{
$this->_songFileName = (!empty($trackName)) ? self::_SONGFILEDIR . preg_replace('/_{2,}/','_',preg_replace('/ /','_',preg_replace('/[^A-Za-z0-9 _-]/','',$trackName))) . '.mp3' : '';
}

public function GetVidUrls()
{
return $this->_vidUrls;
}
private function SetVidUrls(Zend_Gdata_YouTube_VideoEntry $videoEntry)
{
$urlArray = array();
foreach ($videoEntry->mediaGroup->content as $content)
{
if ($content->type === "video/3gpp")
{
$urlArray[] = $content->url;
}
}
$this->_vidUrls = $urlArray;
}

public function GetAudioQualities()
{
return $this->_audioQualities;
}
#endregion
}
?>

index.php

<?php echo '<?xml version="1.1" encoding="iso-8859-1"?>'; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>YouTube-To-Mp3 Converter</title>
<style type="text/css">
body
{
text-align:center;
font:13px Verdana,Arial;
margin-top:50px;
}

p
{
margin:15px 0;
font-weight:bold;
}

form
{
width:450px;
margin:0 auto;
padding:15px;
border:1px solid #ccc;
}

form input[type="text"]
{
width:385px;
}

form p
{
margin:10px 0;
font-weight:normal;
}
</style>
</head>
<body>
<h2>YouTube-To-Mp3 Converter</h2>
<?php
// Execution settings
ini_set('max_execution_time',0);
ini_set('display_errors',0);

// On form submission...
if ($_POST['submit'])
{
// Instantiate converter class
include 'YouTubeToMp3Converter.new.class.php';
$converter = new YouTubeToMp3Converter();

// Print "please wait" message and preview image
$vidID = $converter->ExtractVideoId(trim($_POST['youtubeURL']));
if (!empty($vidID))
{
echo '<div id="preview" style="display:block"><p>...Please wait while I try to convert:</p>';
echo '<p><img src="http://img.youtube.com/vi/'.$vidID.'/1.jpg" alt="preview image" /></p>';
echo '<p>'.$converter->ExtractSongTrackName(trim($_POST['youtubeURL'])).'</p></div>';
flush();
}

// Main Program Execution
echo ($converter->ConvertVideo(trim($_POST['youtubeURL']), $_POST['quality'])) ? '<p>Success!</p>' : '<p>Error generating MP3 file!</p>';
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<p>Enter a valid YouTube.com video URL:</p>
<p><input type="text" name="youtubeURL" /></p>
<p><i>(i.e., "<span style="color:red">http://www.youtube.com/watch?v=HMpmI2F2cMs</span>")</i></p>
<p style="margin-top:20px">Choose the audio quality (better quality results in larger files):</p>
<p style="margin-bottom:25px"><input type="radio" value="64" name="quality" />Low &nbsp; <input type="radio" value="128" name="quality" checked="checked" />Medium &nbsp; <input type="radio" value="160" name="quality" />High</p>
<p><input type="submit" name="submit" value="Create MP3 File" /></p>
</form>
<script type="text/javascript">
window.onload = function()
{
if (document.getElementById('preview'))
{
document.getElementById('preview').style.display = 'none';
}
};
</script>
</body>
</html>

Again, I'll mostly let you figure out how the code works. But I will say this:

You'll notice the code is shorter in this version (for you code efficiency purists) and there is no reliance on arbitrary regex patterns scraping the HTML source code to acquire video information. Instead I get my video data via the YouTube API. In fact, the only regex I use is to find the rtsp:// link of the 3GP file located inside a var_export() dump of a Zend_Gdata_YouTube_VideoEntry (http://framework.zend.com/apidoc/core/Zend_Gdata/YouTube/Zend_Gdata_YouTube_VideoEntry.html) object (the object that represents all data pertaining to a given YouTube video using the API). Also, I'm no longer using cURL.

A few comments:

1) Seeing how I eliminated the need for a temporary video download directory in this version of my app, you might be wondering if it's possible to do the same for 'MyApp 1.0'. I think it might be possible, but I haven't tried it yet. It would entail grabbing the FLV url generated by YouTubeToMp3Converter::SetFlvUrl and placing that directly into the FFmpeg command executed in YouTubeToMp3Converter::GenerateMP3. The resulting code would look something like the following:


$exec_string = self::_FFMPEG.' -i '.$this->GetFlvUrl().' -y -acodec libmp3lame -ab '.$quality.'k '.$this->GetSongFileName();
exec($exec_string);

Again, at this time, I don't know if this would work, but it would certainly simplify the code of 'MyApp 1.0'.

2) Obviously, removing the code's reliance on regex to scrape a video page's source code, in favor of acquiring the same data via the YoutTube API, makes my app virtually impervious to future YouTube.com updates and changes. At the very least, use of the API is a generally more reliable and long term solution to converting YouTube videos.

3) And with that said in #2, I have noticed some problems with manipulating the 3GP files exposed by the API:

- It seems that you can save YouTube 3GP files at a bit rate no higher than 160 kbps (using my app). Whether this is a fault of my app, a restriction imposed by YouTube, or a limitation of converting files with the .3gp extension, I cannot say for sure.

- Sometimes conversion of the YouTube supplied 3gp files will fail (using my app) because the rtsp:// links don't work. I'm inclined to think that this is a shortcoming of YouTube, and not some error in my code. In fact, the issue has been documented here (http://groups.google.com/group/youtube-api-gdata/browse_thread/thread/5375e6cde95afc0b#), and the problem seems ongoing (as of today's date).

4) As I said earlier, I obtain the rtsp:// link (3GP file link) by digging around inside a dump of the API's Zend_Gdata_YouTube_VideoEntry object. From what I saw, the dump revealed "protected" as well as "public" class members. The 3GP link is a "protected" class value, and is therefore not conventionally exposed by the API. But the value is present in the var_export() dump of the object, and that is why I derive my 3GP file location in this way.


Well, there you have...Yet another way to accomplish the same end...Each way has its pros and its cons; ultimately, you have to decide what is best for you...

Again, I'm sure that any of my code could be improved, and I welcome your suggestions and feedback.

Have fun!


Edit: I completely missed the fact that the API does in fact expose the 3GP file location via conventional means...Ooops!....I'll have to fix that later...Apparently version 2.0 of my app is still a work-in-progress...;)...Stay tuned for further updates to the code!


Edit: I have updated the code to take full advantage of the YouTube API...But I am having a lot of problems converting 3GP to MP3...In addition to faulty 3GP locations exposed by the API (as I noted earlier), it seems that, since 3GP is a mobile device media standard, audio track quality of 3GP files generally isn't the best...I noticed that, in my tests, YouTube's 3GP files are encoded using the AMR or AMR-NB audio codec, which doesn't transcode well to MP3 (libmp3lame in ffmpeg) according to this article (http://en.wikipedia.org/wiki/Adaptive_Multi-Rate_audio_codec), which contains the following excerpt:

"Many modern mobile telephone handsets will allow you to store short recordings in the AMR format, both open source and commercial programs exist (see Software support) to convert between this and other formats such as MP3, although it should be remembered that AMR is a speech format and is unlikely to give ideal results for other audio."

That's enough for me to throw my hands up in the air and quit on this second version of my app....You are more than welcome to try to make the second version work for you, and I'd love to know how you did it, but I'm going to have to settle for 'MyApp 1.0' for now, which still works beautifully, but unfortunately doesn't take advantage of the YouTube API.

simwatts
11-02-2010, 05:42 AM
I have found something here which I have tested and works incredibely fast. http://www.ngcoders.com/downloads/freedown-downloader-video-downloader-script.

It is a free script just using Curl and PHP. It gives three options MP4, 3gp and flv. I want to try and get it to work with mp3, and was wondering if someone can take a look. I think just a little change similar to what you have done before with 3gp conversion could achieve this. I tried myself but I am just learning.:)

chump2877
12-22-2010, 02:24 PM
pls am having problem with ur youtube2mp3 app v1. each time i try to use it, i get an error message saying "Error downloading video!". i think am doing everything rite but i still cant get it to work rite. pls i would appreciate any tip u can offer me. thanx in anticipation.

Take a look at the DownloadVideo method in the class. If it returns false, then you get the error message you described. Many things could cause the method to return false.

The first thing I would do is comment out this line:

ini_set('display_errors',0);

...to see what PHP errors you are getting, if any.

Also, I would prefer it that you ask your questions within the forum post itself. Chances are that you are not the only person who has had such a problem, so others could benefit from hearing your questions and my responses.

I took the liberty of posting your original message in the forum thread dedicated to this topic (http://www.codingforums.com/showthread.php?t=205066).

talooz
01-21-2011, 03:27 PM
Hi, i used your code and translated it to Hebrew..
I couldn't hide the FFMPEG output text and instead put a nice loading animation... I tried with the ffmpeg documentation and didnt find nothing...

can you help and publish the change for it?

thanks,
Tal

chump2877
01-21-2011, 04:07 PM
Hi, i used your code and translated it to Hebrew..
I couldn't hide the FFMPEG output text and instead put a nice loading animation... I tried with the ffmpeg documentation and didnt find nothing...

can you help and publish the change for it?

thanks,
Tal

Can you explain what you mean by "FFMPEG output text"? Maybe provide a screen shot or something?

talooz
01-21-2011, 04:23 PM
http://www.tubeit.co.il/capture.jpg
^^this is it - don't mind the hebrew part it's the download link
http://www.tubeit.co.il/converter/

chump2877
01-21-2011, 05:33 PM
Hi, I just downloaded the latest static build of FFMPEG, and I have no problems running the app (nothing like the screen shot you provided)...

I downloaded the Jan 17 2011 build here: http://ffmpeg.arrozcru.org/autobuilds/ffmpeg/mingw32/static/

Which version of FFMPEG did you download? What kind of system are you running FFMPEG on?

talooz
01-21-2011, 06:01 PM
hey,
I replaced the FFMPEG file and it still shows the output text..
The first one i used was the one published first in this topic

I'm running the site under a Windows server with Plesk
php 5.2.5 as CGI application
i have full control for the server so i can change anything if necessary..

chump2877
01-21-2011, 07:53 PM
Well I'm currently running this script on the latest version of XAMPP on a Windows 7 Pro 64-bit machine. I've also used it in XAMPP on my older Windows XP Pro 32-bit machine. No problems either way.

You may want to compare your server's configuration to the settings inside XAMPP (Apache and PHP settings). I've only tested this script inside of XAMPP.

I did have to enable the PHP cURL extension in the php.ini for the XAMPP installation, but I don't think that will solve your particular issue here.

Good luck with this. Sorry I can't help more -- but I am unable to reproduce the issue. If you figure out what the problem is, it would be great if you could report back here with a solution. Others with a similar server setup like your own would certainly benefit from it.

talooz
01-21-2011, 08:49 PM
I will keep trying to solve this
if i will find a way i will publish it here...

Thanks anyways.. awesome script!

talooz
01-22-2011, 04:35 PM
OK, i solved this and I feel kind of dumb because it was so simple...
In plesk go to your domain -> setup -> and run PHP as ISAPI

anyways, i was looking up for solution for
Error in my_thread_global_end(): 1 threads didn't exit
and i got two birds in one hit :)

domasgel
03-05-2011, 12:40 PM
Anyone know why I can get "Error generating MP3 file!".?

chump2877
03-06-2011, 01:08 AM
YouTube recently made some changes to the front end of their web site. As a result, a very minor tweak to my class code is required to keep it working properly.

The following code in the SetFlvUrl() method in YouTubeToMp3Converter.class.php:


private function SetFlvUrl($file_contents)
{
$vidUrl = '';
if (eregi('fmt_url_map',$file_contents))
{
$vidUrl = end(explode('&fmt_url_map=',$file_contents));
$vidUrl = current(explode('&',$vidUrl));
$vidUrl = current(explode('%2C',$vidUrl));
$vidUrl = urldecode(end(explode('%7C',$vidUrl)));
}
$this->_flvUrl = $vidUrl;
}

...needs to change like so:


private function SetFlvUrl($file_contents)
{
$vidUrl = '';
if (eregi('fmt_url_map',$file_contents))
{
$vidUrl = end(explode('fmt_url_map=',$file_contents));
$vidUrl = current(explode('&',$vidUrl));
$vidUrl = current(explode('%2C',$vidUrl));
$vidUrl = urldecode(end(explode('%7C',$vidUrl)));
}
$this->_flvUrl = $vidUrl;
}

After doing that, everything should work as it has before! (Please notify me if you experience otherwise.)

domasgel
03-06-2011, 12:38 PM
chump2877 Thank you so much :)

Sim
03-29-2011, 06:57 PM
I am having some problems with this class..

I always get this:

...Please wait while I try to convert:

preview image

DirtBall Ft Johnny Ritcher-Grind

Error generating MP3 file!

http://www.youtube.com/watch?v=_Vt9wlbzt5E

I look in my video dir and I don't even see teh video file.

Also, my error log says "[29-Mar-2011 11:58:06] PHP Warning: Module 'ffmpeg' already loaded in Unknown on line 0" not sure if this could be the problem



Edit again: I commented the delete video line and the video's there. It just doesn't convert for some reason... ;[

chump2877
03-30-2011, 04:02 AM
my error log says "[29-Mar-2011 11:58:06] PHP Warning: Module 'ffmpeg' already loaded in Unknown on line 0" not sure if this could be the problem

The "Error generating MP3 file!" usually is a sign that something is wrong with your FFmpeg installation, and the above error message seems to reinforce that.

My best guess is that you already have FFmpeg loaded on your server.

See this forum thread: http://motionmods.com/forum/topic?id=690&p=5467

Do you have a copy of FFmpeg already installed in the user/bin/ directory? (Also, how are you running PHP -- what is your server configuration?)

Edit: BTW, I had no problem grabbing the MP3 for that video....

expertmac
03-31-2011, 04:03 PM
I am using this script but how can download mp3 file from webpage?
after convert file is stored in mp3 folder but i want download from webpage so how to add link?

Wating for your reply.


Thanks for this nice script!

kbluhm
03-31-2011, 11:21 PM
Easy: display a link to it and then right-click, save as...

chump2877
04-01-2011, 05:12 AM
I am using this script but how can download mp3 file from webpage?
after convert file is stored in mp3 folder but i want download from webpage so how to add link?

Wating for your reply.


Thanks for this nice script!

You could do what kbluhm suggested, or you could try this: http://www.lmgtfy.com/?q=php+prompt+for+download

You'll find lots of solutions at that link :)

expertmac
04-01-2011, 02:50 PM
Done! thanks for reply...i just add download link & its works thanks again

unu1
04-10-2011, 03:31 PM
someone has an idea on Linux version ?

expertmac
05-11-2011, 10:10 PM
hello,
i am using this script...its work fine but i want add one more feature.I want add ID3 editor can you help me for that.if you have any tips please give me


thanks

chump2877
05-11-2011, 10:26 PM
http://multimedia.cx/eggs/supplying-ffmpeg-with-metadata/

fatslave
05-22-2011, 06:02 PM
heyy , i am unable to infact get the script to fetch video, so i think it gets stuck there .. i can see the thumbnail .. and then nothing happens.. no errors, nothing

i verified that safemode is off for php .. and ffmpeg is working otherwise..

i can see a file of 0kb in videos folders.. and that continues to stay like that !!


EDIT: it works, i had to turn on the curl, thanks a lot mate!!

fatslave
05-22-2011, 06:03 PM
http://www.youtube.com/watch?v=gWqI0U3pBdA


for testing sake, please verify that this is working for u


No need now :P

DangerD
05-22-2011, 11:30 PM
@chump2877, very impresive... thanks for the code =)

expertmac
05-23-2011, 10:56 PM
Hello,
I am trying to make faster this script but i fail,can you tell me how can improve script speed? now mp3 convert time is 3min & i want max 1min or less so how can do this?

waiting for reply


thanks for this awesome script

chump2877
05-23-2011, 11:07 PM
You might be interested in this: http://www.codingforums.com/showthread.php?t=225446

That's the only potential way I can think of to increase the speed of conversion. And I don't know exactly how that could be accomplished because I haven't tried anything like that (yet).

If you figure this out, please share with the rest of us :)

expertmac
05-24-2011, 07:54 AM
ya if i got any solution i will share...here i got same...

script is not take time for convert file...file convert speed is good but download speed is slow i also working on this issue, if you got any solution to improve download speed then please share.




Thanks

chump2877
05-24-2011, 11:01 AM
file convert speed is good but download speed is slow

Well, you'll notice that the FLV video download is performed by PHP cURL extension. So, while I don't have an exact answer for you, the first thing I would do is search these keywords in Google (http://www.google.com/search?client=opera&rls=en&q=speed+up+curl+php&sourceid=opera&ie=utf-8&oe=utf-8&channel=suggest).

This (http://www.paulbain.com/2011/03/29/speeding-up-curl-requests-in-php/) might help a little. If zlib decompression (http://www.php.net/manual/en/intro.zlib.php) is faster than cURL download speeds, you might try downloading a compressed version of the video and then decompressing the file on the server. I don't know if it would improve speed significantly (or even if it will work), but it's worth a try.

Also, you could check out the cURL flags (http://us2.php.net/manual/en/function.curl-setopt.php) in general to see if there are any there that could improve performance in this case.

Inigoesdr
05-25-2011, 01:22 AM
cURL is just an HTTP client, so the speed is mostly limited by the connection on the machine that is running it. Also note that zlib compression has to be supported by the server(YouTube) in order to take advantage of the compression using cURL.

Elements
06-11-2011, 07:57 PM
How can I use this with ffmpeg installed on server instead on windows.

thanks

chump2877
06-12-2011, 05:57 AM
How can I use this with ffmpeg installed on server instead on windows.

thanks

I haven't tried it. I imagine its pretty similar to the way I've set it up in XAMPP.

Have you tried to set it up on a server? Are you experiencing any specific problems?

If you figure this out, and you notice glaring differences in implementation, then please share with the rest of us. :)

Vicar
06-17-2011, 09:34 PM
What code should I use to make sure that the script works?

The first post okay?

chump2877
06-17-2011, 11:00 PM
What code should I use to make sure that the script works?

The first post okay?

Not sure what your question is. The app is working for me.

Please make sure you followed the instructions carefully and applied the applicable patches.

What specific problems are you experiencing?

Vicar
06-17-2011, 11:06 PM
Thanks for the reply, now works.

I followed this post and it works:
http://www.codingforums.com/showpost.php?p=997511&postcount=6

There is only an error:
when you

includes 'YouTubeToMp3Converter.new.class.php';

you have to do:

includes 'YouTubeToMp3Converter.class.php';

because the files you have listed above are:
- YouTubeToMp3Converter.class.php
- Index.php

Now I try to improve it, after the place in the forum!

chump2877
06-17-2011, 11:21 PM
There is only an error:
when you

includes 'YouTubeToMp3Converter.new.class.php';

you have to do:

includes 'YouTubeToMp3Converter.class.php';

because the files you have listed above are:
- YouTubeToMp3Converter.class.php
- Index.php


I will fix that. I meant for the file to actually be named YouTubeToMp3Converter.new.class.php because that class differs from the one that precedes it in this thread. Also, the class you are using only grabs 3GP files, which are lower quality videos, and the resulting MP3 conversion is unreliable and the sound quality is poorer.

I would love to see if you can improve the 2nd version of the code (that manipulates 3GP) -- because it uses the YouTube API, but I would not presently rely on it for optimal results.

Vicar
06-17-2011, 11:40 PM
But in that post, the script does not always work?

chump2877
06-17-2011, 11:42 PM
Correct. The functioning version, that produces the best quality, is here: http://www.codingforums.com/showpost.php?p=1061707&postcount=18

Vicar
06-18-2011, 12:11 AM
If I download the zip, after what should I do?

The converter works properly at localhost, if I put it on a server not, why?

Pwnubis
06-21-2011, 01:08 AM
any updates on this?

Vicar
06-21-2011, 07:40 PM
The reason is the version of PHP. XAMPP use PHP5 while my server use PHP4 :)

No?

Rapso
06-25-2011, 08:34 PM
The reason is the version of PHP. XAMPP use PHP5 while my server use PHP4 :)

No?

It's possible that the server you are using is Linux, ffmpeg.exe only works on Windows

Vicar
06-27-2011, 10:40 AM
And there is nothing for linux?

kbluhm
06-27-2011, 02:54 PM
http://www.lmgtfy.com/?q=ffmpeg+php+linux+install

expertmac
07-21-2011, 08:45 PM
hello,

i am using this script & its working fine till yesteday..but today i got error Error generating MP3 file

I got this error after 2 month so please tell me you also got this error or this is my server problem?

chump2877
07-21-2011, 09:15 PM
I just converted a YouTube video successfully, so it's working for me.

What is the URL of the video you are trying to convert?

expertmac
07-22-2011, 09:07 AM
I trying with many videos but i got same error.i can't convert single video

http://www.youtube.com/watch?v=6g6g2mvItp4
this url i trying

UPDATE:

I can convert only one Video here this URL: http://www.youtube.com/watch?v=abRmvlSKknc

but other videos cant convert so what a problem?

chump2877
07-22-2011, 10:15 AM
I trying with many videos but i got same error.i can't convert single video

http://www.youtube.com/watch?v=6g6g2mvItp4
this url i trying

I was able to convert the video at that URL (the Maroon 5 song)...

So if the code is working for me, and I was able to convert a video that you are not able to convert, then I can only assume the problem is with your server setup...

If it was working for you before, then your server setup must have changed recently. I would:

1) Turn error handling on in the code (comment out ini_set('display_errors',0);)
2) Check your server error logs
3) Make sure FFmpeg is functional within your server setup
4) Download a fresh copy of FFmpeg
5) Make sure that you can execute commands on the server with PHP's exec()

Also I saw a comment somewhere else in this thread about which PHP version can run this code. Since my code uses PHP 5 OOP, it should be run on PHP 5 or higher.

Good luck!

expertmac
07-22-2011, 10:16 PM
i found error in error log:
[22-Jul-2011 16:07:22] PHP Fatal error: Maximum execution time of 1 second exceeded in /home/user/public_html/YouTubeToMp3Converter.class.php on line 78

waiting for your reply

chump2877
07-22-2011, 10:36 PM
http://www.php.net/manual/en/info.configuration.php#ini.max-execution-time

Try adjusting this value:

ini_set('max_execution_time',0);

in my index.php....Or just comment that line out....I honestly can't remember why I set that to '0'...It might be some left over code that I never removed, and possibly an error on my part?

Hope it helps.


I honestly can't remember why I set that to '0'...

This must be the reason why: http://www.php.net/manual/en/function.set-time-limit.php

From that URL:


The maximum execution time, in seconds. If set to zero, no time limit is imposed.

Whether or not the following 2 lines of code are equivalent in terms of what they accomplish, I'm not sure:


set_time_limit(0); // or

ini_set('max_execution_time',0);

So you might also try replacing the existing ini_set() call with a set_time_limit() call, as illustrated above.

This (http://stackoverflow.com/questions/6523164/on-using-ini-setmax-execution-time-0) seems to corroborate that the following lines of code do in fact do the same thing:


set_time_limit(0); // or

ini_set('max_execution_time',0);

...even though this is not made abundantly clear in the PHP manual (at least per my understanding of it)...

Also, you could try adding either of those lines of code to the top of YouTubeToMp3Converter.class.php, since that is where the error occurred for you...

expertmac
07-23-2011, 10:48 AM
it's converting now but one more error found.
when i start ripping i got error Error downloading video!

can't download many videos but same videos can download & convert succesfully.
So why i geting Error downloading video! even videos are playing fine on youtube.

chump2877
07-23-2011, 01:55 PM
How experienced are you with PHP? With some knowledge of PHP programming, this shouldn't be that hard to troubleshoot...

The error you are receiving is due to the DownloadVideo() method failing:


function DownloadVideo($youTubeUrl)
{
$file_contents = file_get_contents($youTubeUrl);
if ($file_contents !== false)
{
$this->SetSongFileName($file_contents);
$this->SetFlvUrl($file_contents);
if ($this->GetSongFileName() != '' && $this->GetFlvUrl() != '')
{
return $this->SaveVideo($this->GetFlvUrl());
}
}
return false;
}

Whch means any of the following could be an issue here:

1) You have entered an invalid YouTube URL into the application
2) The regex used to obtain the FLV file name is not working
3) The regex used to extract the song name is not working

But before you start investigating those possibilities, you should do as I said earlier for your previous problem:

1) Turn error handling on in the code (comment out ini_set('display_errors',0)
2) Check your server error logs

expertmac
07-23-2011, 03:13 PM
hey i just try this script on my another server & there working fine.
that means problem in my server,so can you give me server requirement then i can check,whats problem in server.

chump2877
07-23-2011, 03:59 PM
compare the php.ini of one server to the other...You could also download XAMPP and check the default PHP configuration there...I run the app inside XAMPP successfully

expertmac
07-26-2011, 09:35 AM
yes after Php.ini update its working fine & also its working faster.

thanks for you help.:)

mathieu67
08-04-2011, 01:49 AM
I'm using your script "YoutubeToMp3Converter.class.php" Everything was working fine yesterday from the same server but today I woke and tested the script and now getting this error:

Error downloading video, Please check your URL.!

Can you think of anything? did youtube changed their video URL code again?

My site convert youtube to mp3 (http://www.convert-youtube-to-mp3.com)

Thanks for your help.

mathieu67
08-04-2011, 01:50 AM
@expertmac,

What did you do to fix it? I'm having the same issue as you.

chump2877
08-04-2011, 02:52 AM
I'm using your script "YoutubeToMp3Converter.class.php" Everything was working fine yesterday from the same server but today I woke and tested the script and now getting this error:

Error downloading video, Please check your URL.!

Can you think of anything? did youtube changed their video URL code again?

My site convert youtube to mp3 (http://www.convert-youtube-to-mp3.com)

Thanks for your help.

I'm getting the same error...I'll look into it and post a fix when I find one...

chump2877
08-04-2011, 03:53 AM
It does appear that YouTube has changed the format of FLV URLs in the source code...

Unfortunately, I don't have any more time right now to investigate this...I'll dabble with developing a fix in my spare time...

In the meantime, anyone is welcome to provide the regex or series of regular expressions required to parse and grab the FLV video URL from YouTube's source code...

To be continued...;)

chump2877
08-04-2011, 04:39 AM
As I was typing my last post, I realized what the problem was...

Here is the fix (pending further testing?):

The SetFlvUrl() method has been revised as follows:


private function SetFlvUrl($file_contents)
{
$vidUrl = '';
if (eregi('url_encoded_fmt_stream_map',$file_contents))
{
$vidUrl = end(explode('url_encoded_fmt_stream_map=',$file_contents));
$vidUrl = urldecode(urldecode(current(explode('&',$vidUrl))));
$vidUrl = current(explode(';',$vidUrl));
$vidUrl = urldecode(end(explode('url=',$vidUrl)));
}
$this->_flvUrl = $vidUrl;
}

Download the revised YouTubeToMp3Converter.class.php below! ...And please let me know if you experience any issues with the code....

supercwis
08-04-2011, 10:50 AM
As I was typing my last post, I realized what the problem was...

Here is the fix (pending further testing?):

The SetFlvUrl() method has been revised as follows:


private function SetFlvUrl($file_contents)
{
$vidUrl = '';
if (eregi('url_encoded_fmt_stream_map',$file_contents))
{
$vidUrl = end(explode('url_encoded_fmt_stream_map=',$file_contents));
$vidUrl = urldecode(urldecode(current(explode('&',$vidUrl))));
$vidUrl = current(explode(';',$vidUrl));
$vidUrl = urldecode(end(explode('url=',$vidUrl)));
}
$this->_flvUrl = $vidUrl;
}

Download the revised YouTubeToMp3Converter.class.php below! ...And please let me know if you experience any issues with the code....

Hello,
Don't work any more :(

chump2877
08-04-2011, 11:40 AM
Hello,
Don't work any more :(

What is the YouTube video page URL that you are using? I may have to tinker with the regular expressions some more so that they work on all YouTube URLs?

FWIW, I haven't had any problems yet...

supercwis
08-04-2011, 12:11 PM
Here is an example :
http://www.youtube.com/watch?v=2ZCUtnuAXg8&feature=r_and_b

i use firefox.

Laugh
08-04-2011, 01:57 PM
Hey Chump I'm registering JUST to say thank you! You saved me man! Thank you so much.

But one question, could you show us how to do this ourselves just incase youtube updates again?

chump2877
08-04-2011, 04:15 PM
Here is an example :
http://www.youtube.com/watch?v=2ZCUtnuAXg8&feature=r_and_b

i use firefox.

I just tried "http://www.youtube.com/watch?v=2ZCUtnuAXg8" and it works fine for me...I'm not sure if anything other than "v" in the query string would cause the app to fail, but like the app front end says:


Enter a valid YouTube.com video URL:
(i.e., "http://www.youtube.com/watch?v=HMpmI2F2cMs")

If other types of YouTube URLs dont work for you, then you'll need to write your own code to handle those URLs, or write some code to validate URLs so that they conform to the example URL format. (I didn't really program any validation because I'm just using this app recreationally, for my own personal use.)

Hope that helps....Good luck!

chump2877
08-04-2011, 04:42 PM
Hey Chump I'm registering JUST to say thank you! You saved me man! Thank you so much.

But one question, could you show us how to do this ourselves just incase youtube updates again?

Unfortunately, I can't really give you a magic formula for how to tweak the regex when YouTube updates their site...It's mostly just "educated" guessing and a vague familiarity with how YouTube stores and encodes video data in their source code.

What I can say is that, this time, video data is found in this part of the source code (of any given video page):

(Extracted from source at http://www.youtube.com/watch?v=hWGUnrIiOoI)


<embed type="application/x-shockwave-flash" src="http://s.ytimg.com/yt/swfbin/watch_as3-vfl3rocf3.swf" width="640" id="movie_player" height="363" flashvars="fexp=900081&amp;enablecsi=1&amp;watermark=http%3A%2F%2Fs.ytimg.com%2Fyt%2Fswf%2Flogo-vfl_bP6ud.swf%2Chttp%3A%2F%2Fs.ytimg.com%2Fyt%2Fswf%2Fhdlogo-vfloR6wva.swf&amp;timestamp=1312468085&amp;allow_embed=1&amp;rvs=view_count%3D9133%26author%3DWinkSound%26url%3D http%253A%252F%252Fwww.youtube.com%252Fwatch%253Fv%253DGEF12tbkwsw%26title%3DPro%2BTools%253A%2BCrea ting%2Ba%2BGlitch%2BEffect%2Bwith%2BElastic%2BAudio%26length_seconds%3D212%26featured%3D1%26thumbnai lUrl%3Dhttp%253A%252F%252Fi4.ytimg.com%252Fvi%252FGEF12tbkwsw%252Fdefault.jpg%26id%3DGEF12tbkwsw%2Cv iew_count%3D604604%26author%3DIndoleMugen%26url%3Dhttp%253A%252F%252Fwww.youtube.com%252Fwatch%253Fv %253DnfwD05XA2YQ%26title%3DAutechre%2B-%2BGantz%2BGraf%26length_seconds%3D236%26thumbnailUrl%3Dhttp%253A%252F%252Fi3.ytimg.com%252Fvi%252Fn fwD05XA2YQ%252Fdefault.jpg%26id%3DnfwD05XA2YQ%2Cview_count%3D311362%26author%3Dcrawler23%26url%3Dhtt p%253A%252F%252Fwww.youtube.com%252Fwatch%253Fv%253DFLK70Ipe-tI%26title%3DAutechre%2B-%2BClipper%26length_seconds%3D474%26thumbnailUrl%3Dhttp%253A%252F%252Fi3.ytimg.com%252Fvi%252FFLK70I pe-tI%252Fdefault.jpg%26id%3DFLK70Ipe-tI%2Cview_count%3D208837%26author%3Dchangoelectrico%26url%3Dhttp%253A%252F%252Fwww.youtube.com%252Fw atch%253Fv%253DQPEcjQXIHX0%26title%3DAutechre%2B-%2BBasscadet%26length_seconds%3D280%26thumbnailUrl%3Dhttp%253A%252F%252Fi2.ytimg.com%252Fvi%252FQPEc jQXIHX0%252Fdefault.jpg%26id%3DQPEcjQXIHX0%2Cview_count%3D1528748%26author%3Dnonameno5%26url%3Dhttp% 253A%252F%252Fwww.youtube.com%252Fwatch%253Fv%253DdQEmaj9C6ko%26title%3DBoards%2Bof%2BCanada%2B-%2BEverything%2BYou%2BDo%2Bis%2Ba%2BBalloon%26length_seconds%3D421%26thumbnailUrl%3Dhttp%253A%252F%2 52Fi1.ytimg.com%252Fvi%252FdQEmaj9C6ko%252Fdefault.jpg%26id%3DdQEmaj9C6ko%2Cview_count%3D190273%26au thor%3DChubeMania%26url%3Dhttp%253A%252F%252Fwww.youtube.com%252Fwatch%253Fv%253DQLXzSefzVWU%26title %3DAutechre%2B-%2B444%26length_seconds%3D538%26thumbnailUrl%3Dhttp%253A%252F%252Fi2.ytimg.com%252Fvi%252FQLXzSefzVW U%252Fdefault.jpg%26id%3DQLXzSefzVWU%2Cview_count%3D12698859%26author%3Doptionalinfo%26url%3Dhttp%25 3A%252F%252Fwww.youtube.com%252Fwatch%253Fv%253DEjAoBKagWQA%26title%3DAll%2Bis%2Bfull%2Bof%2Blove%26 length_seconds%3D249%26thumbnailUrl%3Dhttp%253A%252F%252Fi2.ytimg.com%252Fvi%252FEjAoBKagWQA%252Fdef ault.jpg%26id%3DEjAoBKagWQA%2Cview_count%3D3062%26author%3DMrNightmare92%26url%3Dhttp%253A%252F%252F www.youtube.com%252Fwatch%253Fv%253DKFuIB9hsI1s%26title%3DAutechre%2B-%2BRotar%26length_seconds%3D485%26thumbnailUrl%3Dhttp%253A%252F%252Fi4.ytimg.com%252Fvi%252FKFuIB9hs I1s%252Fdefault.jpg%26id%3DKFuIB9hsI1s%2Cview_count%3D85572%26author%3DXyrofen%26url%3Dhttp%253A%252 F%252Fwww.youtube.com%252Fwatch%253Fv%253D7nXcLBXR70M%26title%3DAutechre-%2Bsee%2Bon%2Bsee%26length_seconds%3D262%26thumbnailUrl%3Dhttp%253A%252F%252Fi4.ytimg.com%252Fvi%252 F7nXcLBXR70M%252Fdefault.jpg%26id%3D7nXcLBXR70M&amp;vq=auto&amp;showpopout=1&amp;hl=en_US&amp;autohide=3&amp;url_encoded _fmt_stream_map=url%3Dhttp%253A%252F%252Fo-o.preferred.att-ord1.v24.lscache5.c.youtube.com%252Fvideoplayback%253Fsparams%253Did%25252Cexpire%25252Cip%25252Cipb its%25252Citag%25252Cratebypass%25252Coc%25253AU0hQR1RUT19FSkNOMF9MTlNH%2526fexp%253D900081%2526itag %253D43%2526ip%253D0.0.0.0%2526signature%253D2DF581FE56F207F9B0CAA10EBBC5BF6C7E4B3EEB.47DFB1991F4622 66CD66DEDE6439D32969D10DA1%2526sver%253D3%2526ratebypass%253Dyes%2526expire%253D1312491600%2526key%2 53Dyt1%2526ipbits%253D0%2526id%253D8561949eb2223a82%26quality%3Dmedium%26fallback_host%3Dtc.v24.cach e5.c.youtube.com%26type%3Dvideo%252Fwebm%253B%2Bcodecs%253D%2522vp8.0%252C%2Bvorbis%2522%26itag%3D43 %2Curl%3Dhttp%253A%252F%252Fo-o.preferred.att-ord1.v11.lscache3.c.youtube.com%252Fvideoplayback%253Fsparams%253Did%25252Cexpire%25252Cip%25252Cipb its%25252Citag%25252Calgorithm%25252Cburst%25252Cfactor%25252Coc%25253AU0hQR1RUT19FSkNOMF9MTlNH%2526 fexp%253D900081%2526algorithm%253Dthrottle-factor%2526itag%253D34%2526ip%253D0.0.0.0%2526burst%253D40%2526sver%253D3%2526signature%253DA34A8A17 D276340ED85A110313E2FEF15EE38B0F.C873EE99BF3B2667F3F819FA90420E9900D8CA69%2526expire%253D1312491600% 2526key%253Dyt1%2526ipbits%253D0%2526factor%253D1.25%2526id%253D8561949eb2223a82%26quality%3Dmedium% 26fallback_host%3Dtc.v11.cache3.c.youtube.com%26type%3Dvideo%252Fx-flv%26itag%3D34%2Curl%3Dhttp%253A%252F%252Fo-o.preferred.att-ord1.v2.lscache7.c.youtube.com%252Fvideoplayback%253Fsparams%253Did%25252Cexpire%25252Cip%25252Cipbi ts%25252Citag%25252Cratebypass%25252Coc%25253AU0hQR1RUT19FSkNOMF9MTlNH%2526fexp%253D900081%2526itag% 253D18%2526ip%253D0.0.0.0%2526signature%253D789913C8B56F2644997E5D8CC761D3B862770A68.6A8AC65B5E2D7F2 E269E82A422601441AB2B33D9%2526sver%253D3%2526ratebypass%253Dyes%2526expire%253D1312491600%2526key%25 3Dyt1%2526ipbits%253D0%2526id%253D8561949eb2223a82%26quality%3Dmedium%26fallback_host%3Dtc.v2.cache7 .c.youtube.com%26type%3Dvideo%252Fmp4%253B%2Bcodecs%253D%2522avc1.42001E%252C%2Bmp4a.40.2%2522%26ita g%3D18%2Curl%3Dhttp%253A%252F%252Fo-o.preferred.att-ord1.v9.lscache6.c.youtube.com%252Fvideoplayback%253Fsparams%253Did%25252Cexpire%25252Cip%25252Cipbi ts%25252Citag%25252Calgorithm%25252Cburst%25252Cfactor%25252Coc%25253AU0hQR1RUT19FSkNOMF9MTlNH%2526f exp%253D900081%2526algorithm%253Dthrottle-factor%2526itag%253D5%2526ip%253D0.0.0.0%2526burst%253D40%2526sver%253D3%2526signature%253D0AB728A9D 6A142C109D06CEA277C6C523F2D6FB5.86BBF1C4078758244707B1B65C0E26F4B6A03F7B%2526expire%253D1312491600%2 526key%253Dyt1%2526ipbits%253D0%2526factor%253D1.25%2526id%253D8561949eb2223a82%26quality%3Dsmall%26 fallback_host%3Dtc.v9.cache6.c.youtube.com%26type%3Dvideo%252Fx-flv%26itag%3D5&amp;csi_page_type=watch&amp;keywords=Autechre%2Celectronica%2Cdropp%2Cwarp%2Caphex%2Cep7%2Cid m%2Cmusic%2Cvideo&amp;cr=US&amp;no_get_video_log=1&amp;endscreen_module=http%3A%2F%2Fs.ytimg.com%2Fyt%2Fswfbin%2 Fendscreen-vfl6JSdY7.swf&amp;fmt_list=43%2F640x360%2F99%2F0%2F0%2C34%2F640x360%2F9%2F0%2F115%2C18%2F640x360%2F9%2F0 %2F115%2C5%2F320x240%2F7%2F0%2F0&amp;referrer=None&amp;video_id=hWGUnrIiOoI&amp;length_seconds=195&amp;enablejsapi=1 &amp;sk=gb-MJ0HISRAnJxp-4dgRnf_1oE6YdH8bC&amp;theme=dark&amp;t=vjVQa1PpcFP7QuLQ4LWFlW0XZNVbeU4UAKSWcbwwkMs%3D&amp;plid=AASprsoGU23a2Fa8&amp; tmi=1" allowscriptaccess="always" allowfullscreen="true" bgcolor="#000000">

The code in red is the URL-encoded FLV file location (I think I highlighted the right code -- it's hard to tell when it's encoded like that -- but that is the general vicinity in the source code)...It's just a matter of picking out the correct URL from that garbled mess and then URL-decoding it...

Also, as an aside, the series of regular expressions that I used in SetFlvUrl() could probably be made more efficient (from a coding perspective), but:

1) I wrote the code quickly, and
2) The code does what I need it to do, so I guess I don't care

As always, if something (namely, the regex) doesn't work, let me know and I'll try to fix it....But as long as it works, no matter how ugly it might look, I'm good with it :D

mathieu67
08-04-2011, 07:11 PM
@chump2877,

I made the changes but now i'm getting this error:

Error generating MP3 file!

Anyone else? I think youtube is still making changes.


my site: Youtube Mp3 Converter (http://www.convert-youtube-to-mp3.com)

chump2877
08-04-2011, 07:46 PM
@chump2877,

I made the changes but now i'm getting this error:

Error generating MP3 file!

Anyone else? I think youtube is still making changes.


my site: Youtube Mp3 Converter (http://www.convert-youtube-to-mp3.com)

what is the URL of the YouTube video page?

mathieu67
08-04-2011, 11:13 PM
what is the URL of the YouTube video page?

I tried several but here's one that is not working that worked 2 days ago.

http://www.youtube.com/watch?v=o8Y9-JlSRXw


my site: http://www.convert-youtube-to-mp3.com

chump2877
08-05-2011, 01:24 AM
I tried several but here's one that is not working that worked 2 days ago.

http://www.youtube.com/watch?v=o8Y9-JlSRXw


my site: http://www.convert-youtube-to-mp3.com

I just tried to convert that video, and I was able to do it just fine....

mathieu67
08-05-2011, 05:07 AM
I just tried to convert that video, and I was able to do it just fine....

You were able to convert that video on http://www.convert-youtube-to-mp3.com?? I cleared my cache and history and tried again and still getting the error: Error generating MP3 file!

supercwis
08-05-2011, 08:37 AM
chump2877 you are the best it work's fine for me :thumbsup:

kbluhm
08-05-2011, 01:02 PM
You were able to convert that video on http://www.convert-youtube-to-mp3.com?? I cleared my cache and history and tried again and still getting the error: Error generating MP3 file!

Worked here as well.

Rowsdower!
08-05-2011, 02:42 PM
The "convert-youtube-to-mp3.com" website isn't working for me on any of the 6 videos I have tried...

chump2877
08-05-2011, 03:33 PM
You were able to convert that video on http://www.convert-youtube-to-mp3.com?? I cleared my cache and history and tried again and still getting the error: Error generating MP3 file!

No, I meant I was able to convert the video using my code on my server. Which means there is something wrong with your server setup. In this thread, I have previously posted several troubleshooting steps you can employ to try to isolate and correct the problem (in relation to the error message that you are receiving). I suggest that you try some of those things and, if you are not able to fix the problem, then report back here with what you find out, and I will try to help you further.

mathieu67
08-10-2011, 10:39 AM
I tried all the troubleshooting tips you gave and even got the server company to look it up and I still cannot convert videos and getting: Error generating MP3 file!

Here's what I've tried:

1) Turn error handling on in the code (comment out ini_set('display_errors',0);)
2) Check your server error logs
3) Make sure FFmpeg is functional within your server setup
4) Download a fresh copy of FFmpeg
5) Make sure that you can execute commands on the server with PHP's exec()

Can anyone try http://www.convert-youtube-to-mp3.com to see if they are having any issues converting videos?

Please help me fix this.

Thanks you.

chump2877
08-10-2011, 11:41 AM
mathieu,

In addition to what I've already suggested, all I can think of is to:

1) Make sure folders and files are where they are supposed to be (as per my instructions in this thread's first post)

2) Try the code/files on another server. If it works on another server, then compare server configurations (see #3 in this list).

3) Download XAMPP and try configuring and running the code/files from there. If it works, compare the server config inside XAMPP to your server config (i.e., compare php.ini files or maybe even Apache httpd.conf files -- if you are running Apache).

It might also be helpful for me to know:

1) Server OS (windows or linux?)
2) Server software (Apache or IIS?)
3) PHP version

Maybe someone else has additional suggestions. That's all I can think of at the moment.

Good luck...

mathieu67
08-11-2011, 07:13 AM
@chump2877,

I've tried everything with no luck. Still getting: Error generating MP3 file!. Just a few days ago the codes were working on all 3 servers but now not working on all 3 servers even though I've tried your exact codes without any modification.

Server OS: linux
Server software: Apache
PHP version: 5.2.11

Here's 2 separate servers the codes used to work on but not anymore.

http://www.convert-youtube-to-mp3.com (modified codes)
http://www.facebookblog.us (your exact codes)

Beironjohn
08-11-2011, 12:29 PM
i know it defeats the object of writing your own, but i use this one, free and you download an extention that adds a download button on youtube pages for ease of use

http://www.video2mp3.net

after the button is pressed, it open a new browser tab with the url of the youtube page

http://www.video2mp3.net/?url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DVuoJHF6MjL4

converts and downloads, no fuss :)

chump2877
08-11-2011, 10:00 PM
i know it defeats the object of writing your own, but i use this one, free and you download an extention that adds a download button on youtube pages for ease of use

http://www.video2mp3.net

after the button is pressed, it open a new browser tab with the url of the youtube page

http://www.video2mp3.net/?url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DVuoJHF6MjL4

converts and downloads, no fuss :)

I like the browser extension idea...I wonder if the extension could be programmed so that it doesn't force a new tab to open, and instead does everything behind the scenes? Unfortunately, I know nothing about programming browser extensions...But it seems like it might be possible with some AJAX and a little ingenuity?..

mathieu67
08-13-2011, 12:24 AM
can anyone help with my issue? site is http://www.convert-youtube-to-mp3.com

mathieu67
08-13-2011, 08:59 PM
This is crazy. all video links from youtube.com/music are working but not from the main site.

jasminder singh
08-25-2011, 04:50 AM
Hello!
THanks a lot for the script .

ithink its not working anymore , its saying Error downloading video! everytime.
Please fix the error sir .

chump2877
08-25-2011, 05:05 AM
Hello!
THanks a lot for the script .

ithink its not working anymore , its saying Error downloading video! everytime.
Please fix the error sir .

I just converted a video successfully, so you might want to try some of the troubleshooting steps I suggested earlier in this thread.

fytmc411
08-30-2011, 05:22 PM
I'm getting the error: Error generating MP3 file!. Can anyone help me fix?

chump2877
08-30-2011, 08:01 PM
I'm getting the error: Error generating MP3 file!. Can anyone help me fix?

Works for me! See the troubleshooting steps outlined in earlier posts in this thread.

fytmc411
08-30-2011, 10:28 PM
I have the script installed on a dedicated server and a shared host that is configure to run video scripts.

I noticed on my directories that I don't have ffmpeg.exe anywhere. Could that be a problem?

chump2877
08-30-2011, 11:15 PM
I have the script installed on a dedicated server and a shared host that is configure to run video scripts.

I noticed on my directories that I don't have ffmpeg.exe anywhere. Could that be a problem?

Remember this?


To help you visualize, in XAMPP, my final directory structure appears as follows:

C:\xampp\htdocs\VideoToMp3Converiter\mp3
C:\xampp\htdocs\VideoToMp3Converter\videos
C:\xampp\htdocs\VideoToMp3Converter\ffmpeg.exe
C:\xampp\htdocs\VideoToMp3Converter\index.php
C:\xampp\htdocs\VideoToMp3Converter\YouTubeToMp3Converter.class.php

The script obviously won't generate an mp3 file without ffmpeg.exe (that explains your error message). FFmpeg is the external program (executed at the command line level) that actually performs the conversion! So you need to have ffmpeg.exe somewhere on your server. And if it's not in the same folder like I have it, then you need to change the following code accordingly:


const _FFMPEG = 'ffmpeg.exe';

...to...


const _FFMPEG = '/path/to/ffmpeg/ffmpeg.exe';

fytmc411
08-31-2011, 12:59 AM
Remember this?



The script obviously won't generate an mp3 file without ffmpeg.exe (that explains your error message). FFmpeg is the external program (executed at the command line level) that actually performs the conversion! So you need to have ffmpeg.exe somewhere on your server. And if it's not in the same folder like I have it, then you need to change the following code accordingly:


const _FFMPEG = 'ffmpeg.exe';

...to...


const _FFMPEG = '/path/to/ffmpeg/ffmpeg.exe';

I changed the path to /usr/local/bin/ffmpeg/ffmpeg.exe where ffmpeg is located but the result is the same: Error generating MP3 file!

HG3
09-07-2011, 05:52 PM
Hello Chump2877 , I am also with the error (Error generating MP3 file!) My server is Linux, and ffmpeg is to be Windowns this is problem, has another program equal to ffmpeg for linux?

chump2877
09-07-2011, 09:48 PM
There appears to be a way(s) to install FFmpeg on Linux: http://www.google.com/search?client=opera&rls=en&q=ffmpeg&sourceid=opera&ie=utf-8&oe=utf-8&channel=suggest#sclient=psy&hl=en&safe=off&client=opera&tbo=1&rls=en&channel=suggest&tbs=qdr:y&source=hp&q=ffmpeg+linux&pbx=1&oq=ffmpeg+linux&aq=f&aqi=&aql=&gs_sm=s&gs_upl=0l0l0l29370l0l0l0l0l0l0l0l0ll0l0&bav=on.2,or.r_gc.r_pw.&fp=eea4b248a1d1f6f6&biw=1355&bih=835

kappi
09-14-2011, 04:50 PM
hello chump2877

i found this thread buy googling

and i wana thank you for the hard work to coding this nice script

please can upload the latest and working copy of that script ?

can this script work n shared hosting ?

thanks in advance

chump2877
09-14-2011, 07:59 PM
please can upload the latest and working copy of that script ?

The latest working version is available in this thread. You can't miss it. (Or so I thought? :eek:)


can this script work n shared hosting ?

Only if you can upload FFMpeg and/or access FFMpeg at the command line level via PHP's exec() function. Check with your web hosting provider.

freakZ
09-16-2011, 05:29 PM
hello,

i habe a problem with the download script when i uncommand the line -> #const _FFMPEG = '/usr/bin/ffmpeg'; thank the script load not the video.

When comment with # the line thank the script download the vid to /video ;)

But i have debian and the script says when convert -> Mp3 error -> Fatal error: Undefined class constant '_FFMPEG' in /var/www/grouves/YouTubeToMp3Converter.class.php on line 44

Please help me to fix it ;)))

Server debian with actually ffmpeg version and ffpmeg-php

chump2877
09-16-2011, 05:50 PM
i habe a problem with the download script when i uncommand the line -> #const _FFMPEG = '/usr/bin/ffmpeg'; thank the script load not the video.

Is there a reason why you are commenting out this line?

If you comment out that line, then the script does not know where to look for FFMpeg. So you can't comment out that line and expect the script to work as it is written.

Rather, you should change _FFMPEG to wherever FFMpeg is located on your server.


Edit: Are you using this: http://ffmpeg-php.sourceforge.net/ ? If so, then I assume you are replacing:


$exec_string = self::_FFMPEG.' -i '.$this->GetTempVidFileName().' -y -acodec libmp3lame -ab '.$quality.'k '.$this->GetSongFileName();
exec($exec_string);

...in my script with the provided API. And if that is the case, then you should not be getting the error that you're getting because, at that point, the constant _FFMPEG is not used anywhere in the script....

freakZ
09-16-2011, 08:07 PM
hello,

i comment the line out with this line i have NO DOWNLOAD in /video directory.
Withe the line without comment from me i become this error:
Fatal error: Undefined class constant '_FFMpeg' in /var/www/soundz/YouTubeToMp3Converter.class.php on line 46

And when comment the line then i have ONLY the .flv into the /video directory.

And ffmpeg is installed ;(( when constan_ffmpeg /usr/local/bin/ffmpeg than say the script -> Error generating MP3 file!

Edit: Normaly i convert files with:
system(”/usr/local/bin/ffmpeg -i input.mov -ar 22050 -ab 56 -aspect 4:3 -b 200 -r 12 -f flv -s 320×240 -acodec mp3 -ac 1 output.flv”);

chump2877
09-17-2011, 02:24 AM
I need to see your modified script to have any idea why you are having these issues.

freakZ
09-17-2011, 03:30 PM
hello,

i have not modified @ your script - i have only # commented ..

and i have a script to convert my holiday movie to flv and this was the command line - and not YOUR script.

Your script downloads the movie but say - error generating mp3.

Can you say me a little code to see what version and if is ffmpeg on my another vserver installed? in the phpinfo it is listed.

chump2877
09-17-2011, 06:07 PM
i have not modified @ your script - i have only # commented ..

Great! Then uncomment the lines of code that you have commented, and you should be all set...The original script works fine for me.

The error that you are receiving ("error generating mp3") could be fixed by doing that, or you could try troubleshooting the script using the various methods already documented in this thread. Also reread the instructions for setting up the script -- you may have something configured incorrectly -- or a file misplaced or missing -- on your server.


Can you say me a little code to see what version and if is ffmpeg on my another vserver installed? in the phpinfo it is listed.

My script does not use a PHP FFMpeg extension...It only uses ffmpeg.exe at the command line level. Again, please reread the instructions for setting up the script...If you want or need to use a PHP extension (like http://ffmpeg-php.sourceforge.net/), then you must modify my script. I have as yet written no code to accommodate such an API.

Good luck!

freakZ
09-17-2011, 06:29 PM
hello,

i use ffmpeg and ffmpeg-php , to convert i use normaly ffmpeg without php support.

I have linux can you say me a way in your script that works with linux and not with an .exe (windows). I have debian (linux).

thank you

chump2877
09-17-2011, 07:39 PM
I have not tried to run this application in anything other than XAMPP for Windows (because I only use it for my own personal use). The script is provided as is. If you need the script to run on a Linux server, there are ways to install FFmpeg on Linux (http://www.google.com/search?client=opera&rls=en&q=ffmpeg+linux&sourceid=opera&ie=utf-8&oe=utf-8&channel=suggest#pq=ffmpeg+linux&hl=en&sugexp=gsis%2Ci18n%3Dtrue&cp=4&gs_id=h&xhr=t&q=install+ffmpeg+linux&qe=aW5zdGZmbXBlZyBsaW51eA&qesig=V8HnWLpj-DJE9Sm9tsFk5Q&pkc=AFgZ2tmH5sjh7LY3uS21d1Zs8JPsw1GjMQxxL1zOkx46AYv-vl017orm5lTwkcabnMLlOLw7SHCeU3au3TsgqGF0tnngkup0uA&pf=p&sclient=psy-ab&safe=off&client=opera&tbo=1&rls=en&channel=suggest&tbs=qdr:y&source=hp&pbx=1&oq=instffmpeg+linux&aq=0c&aqi=g-c1g-b1&aql=&gs_sm=&gs_upl=&bav=on.2,or.r_gc.r_pw.&fp=3b98a7b5ec25983b&biw=1355&bih=863) / Debian (http://www.google.com/search?client=opera&rls=en&q=ffmpeg+linux&sourceid=opera&ie=utf-8&oe=utf-8&channel=suggest#sclient=psy-ab&hl=en&safe=off&client=opera&tbo=1&rls=en&channel=suggest&tbs=qdr:y&source=hp&q=install+ffmpeg+debian&pbx=1&oq=install+ffmpeg+debian&aq=f&aqi=g2g-v1&aql=&gs_sm=e&gs_upl=334098l334982l0l335492l6l5l0l1l1l0l474l1164l0.1.1.1.1l4l0&bav=on.2,or.r_gc.r_pw.&fp=3b98a7b5ec25983b&biw=1355&bih=863). Once installed, you may also have to modify the relevant script code (as I indicated earlier).

missenlinx
11-07-2011, 11:13 AM
Hi chump2877,

Is your script still working. I have tried debugging your code and it seems to be failing at;

eregi('fmt_url_map',$file_contents);

fmt_url_map does not even exist in the page.

Any suggestions?

chump2877
11-14-2011, 12:56 PM
Hi chump2877,

Is your script still working. I have tried debugging your code and it seems to be failing at;

eregi('fmt_url_map',$file_contents);

fmt_url_map does not even exist in the page.

Any suggestions?

Please use the latest version of the code. You are using an older version.

itsmeanthony
11-24-2011, 12:50 PM
@chump2877: First of all thanks for the code, it works like a charm. You really are the PHP master =D

I have one question about youtube video size. Can you get/read flv size before you download the video on your computer? Is there any way to do that?

Thank you,
Tony

chump2877
12-03-2011, 03:02 PM
YouTube recently changed the front end of their site again. The following fix to my code is required:


private function SetFlvUrl($file_contents)
{
$vidUrl = '';
if (eregi('"url_encoded_fmt_stream_map": "url=',$file_contents))
{
$vidUrl = end(explode('"url_encoded_fmt_stream_map": "url=',$file_contents));
$vidUrl = urldecode(urldecode(current(explode('\u0026',$vidUrl))));
}
$this->_flvUrl = $vidUrl;
}

Download the revised YouTubeToMp3Converter.class.php below! ...And please let me know if you experience any issues with the code....

chump2877
12-03-2011, 03:39 PM
@chump2877: First of all thanks for the code, it works like a charm. You really are the PHP master =D

I have one question about youtube video size. Can you get/read flv size before you download the video on your computer? Is there any way to do that?

Thank you,
Tony

Hi Tony,

My first inclination would be to try and acquire that kind of information via the YouTube API. For example, here (http://code.google.com/apis/youtube/2.0/developers_guide_php.html#Retrieving_Video_Entry) is the API-way to grab a variety of data pertaining to a particular video. Further exploration (http://code.google.com/apis/youtube/2.0/reference.html#youtube_data_api_tag_entry) reveals all of the possible data that can be retrieved for a given video "entry" object. Unfortunately, the API does not appear to provide individual video file size information (I think that's what you are after?). But you might try digging around a little more and see if I missed something.

Apart from the API you might try the following link (https://www.google.com/search?client=opera&rls=en&q=php+get+file+size+of+remote+file&sourceid=opera&ie=utf-8&oe=utf-8&channel=suggest#sclient=psy-ab&hl=en&safe=off&client=opera&hs=Wcr&rls=en&channel=suggest&source=hp&q=php+get+file+size+of+remote+file&pbx=1&oq=php+get+file+size+of+remote+file&aq=f&aqi=&aql=&gs_sm=s&gs_upl=0l0l0l55036l0l0l0l0l0l0l0l0ll0l0&bav=on.2,or.r_gc.r_pw.,cf.osb&fp=a432ee3ec8892393&biw=1449&bih=834). This solution (http://www.php.net/manual/en/function.filesize.php#92462) looks promising because it involves cURL (which my script already uses to download videos), so you might incorporate this technique into the SaveVideo method, just prior to actually downloading the video. There you could institute a check for file size, and if the size was either too big (or too small?), then you could cancel the video save operation and make the method return false.

migara
12-10-2011, 08:33 AM
it didnt work.help me.

chump2877
12-10-2011, 09:19 AM
it didnt work.help me.

Just tried it here again, and it works fine.

And please: If you are going to request help, kindly describe the specific issue(s) that you are having. I almost didn't bother replying to your post because of the lack of effort that went into it. Thanks!

jibreel
12-25-2011, 02:27 AM
Hey chump, This is a great script but i'm having a problem, i'm not amazing at php and the conversion works perfectly its just i can't seem to get it to make a download.
I saw some posts about making a link to it, and then you replyed with a link to some php forum and how to do it but i just don't understand it.

Basicly i need a link after the conversion finished like "DOWNLOAD NOW" that is linked to the mp3 that they just converted, If this helps i'm hosting the website on a shared host.

Please help as soon as possible Thankyou

chump2877
12-25-2011, 06:05 AM
Basicly i need a link after the conversion finished like "DOWNLOAD NOW" that is linked to the mp3 that they just converted, If this helps i'm hosting the website on a shared host.

I've gotten several requests for this feature, so I have modified the code as follows:

1) Added download link after successful conversion
2) Added conversion process progress bar
3) Some general refactoring of code

Download the revised files below. ...And please let me know if you experience any issues with the code....

Happy Holidays!


Edit: The progress bar feature will only work for PHP versions 5.3 and above. To disable the progress bar, you need only comment out the following lines of code in YouTubeToMp3Converter.class.php:


private function SaveVideo($url)
{
$this->_percentVidDownloaded = 0;
$this->SetTempVidFileName(time());
$file = fopen($this->GetTempVidFileName(), 'w');
$ch = curl_init();
curl_setopt($ch, CURLOPT_FILE, $file);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
//curl_setopt($ch, CURLOPT_NOPROGRESS, false);
//curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, array($this, 'UpdateVideoDownloadProgress'));
//curl_setopt($ch, CURLOPT_BUFFERSIZE, 4096000);
curl_exec($ch);
curl_close($ch);
fclose($file);
return is_file($this->GetTempVidFileName());
}
...and change the following line of code in index.php:

echo '<div id="progress-bar"><div id="progress">0%</div></div></div>';
...to:

echo '</div>';

jibreel
12-25-2011, 01:00 PM
Thankyou chump, But im afraid that has not fixed my problem.
My website is www.free-youtube-mp3.org

My website folder consists of the index.php and the youtubetomp3converter.class.php that you sent me, aswell as Mp3 and videos folder that have full writes.

When i press convert it takes time, then a page full of codes comes up :/ please help :(


- After attempting to convert the video and apart from what i said up above an error log appeared in my files on my shared server and i saw this when i was using filezilla. I'm giving the mp3 file full permission (777) but i don't think it saves the permission?.
Error Log-

[25-Dec-2011 06:29:13] PHP Warning: fopen(videos/1324816153.flv) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory in /home/freeyou1/public_html/YouTubeToMp3Converter.class.php on line 101
[25-Dec-2011 06:29:13] PHP Warning: curl_setopt(): supplied argument is not a valid File-Handle resource in /home/freeyou1/public_html/YouTubeToMp3Converter.class.php on line 103
[25-Dec-2011 06:29:16] PHP Warning: fclose(): supplied argument is not a valid stream resource in /home/freeyou1/public_html/YouTubeToMp3Converter.class.php on line 111

chump2877
12-25-2011, 02:20 PM
It looks like something is going wrong with cURL when the FLV file is being downloaded from YouTube. The likely offending code is in the SaveVideo() method:


$file = fopen($this->GetTempVidFileName(), 'w');
$ch = curl_init();
curl_setopt($ch, CURLOPT_FILE, $file);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_NOPROGRESS, false);
curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, array($this, 'UpdateVideoDownloadProgress'));
curl_setopt($ch, CURLOPT_BUFFERSIZE, 256);
curl_exec($ch);

Are you sure you have cURL enabled, or running correctly, for your server's PHP installation?

Can you use cURL to read from and write to any other files?

Can you use fopen() to open and create other files?

That's all I have off the top of my head. I run the code here with no issues.

jibreel
12-25-2011, 06:43 PM
Sorry for making you waste your time by assisting me but i'm not good at these type of things, And yes Curl is enabled.

I think i'v just mixed the wrong files up, Sorry for asking but would it be tomuch to ask if you uploaded the full website folder with all the files in it needed to work, Please :)

If not it's fine i'll just keep trying :/

chump2877
12-25-2011, 06:54 PM
Are your 'videos' and 'mp3' folders directly in '/home/freeyou1/public_html/' (your web root)? They should be. Your errors indicate that perhaps these directories are elsewhere...

The required directory structure for all files/directories involved is outlined in the the first post of this thread.

BTW - I just added a progress bar to 12-25-11.zip distribution, so you may want to download the zip again to get the updated files with progress bar included.

jibreel
12-25-2011, 08:21 PM
Before you read further my website is www.free-youtube-mp3.org Try converting and you will see

Okay i put the files together, In my folder it consists of Mp3,Videos,Ffmpeg.exe,index.php,youtubetomp3converter.class.php

So on filezilla it says public.html consists of 4 files and 2 directories, The directories being Mp3 and videos with their permission being set at 777.
When i attempt to convert a video it says error converting mp3 but... for an odd reason it seems to convert this video
http://www.youtube.com/watch?v=ELEc33PRjnw
By converting i mean the converted file goes into the video folder as i saw on filezilla but on the actual website nothing happens abit from you see the browser loading icon?No progress bar, Nothing to tell me it is converting, Nothing at all. :/

This is the error message. (From reading the error it seems to be line 75 and 26, but i don't have any idea on how to fix this)

[25-Dec-2011 12:57:41] PHP Warning: file_get_contents(www.youtube.com/watch?v=KYA1-TF_6FY) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: No such file or directory in /home/freeyou1/public_html/YouTubeToMp3Converter.class.php on line 75
[25-Dec-2011 12:57:41] PHP Warning: file_get_contents(www.youtube.com/watch?v=KYA1-TF_6FY) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: No such file or directory in /home/freeyou1/public_html/YouTubeToMp3Converter.class.php on line 26
[25-Dec-2011 12:57:45] PHP Warning: file_get_contents() [<a href='function.file-get-contents'>function.file-get-contents</a>]: Filename cannot be empty in /home/freeyou1/public_html/YouTubeToMp3Converter.class.php on line 75
[25-Dec-2011 12:57:45] PHP Warning: file_get_contents() [<a href='function.file-get-contents'>function.file-get-contents</a>]: Filename cannot be empty in /home/freeyou1/public_html/YouTubeToMp3Converter.class.php on line 26
[25-Dec-2011 12:58:45] PHP Warning: file_get_contents(www.youtube.com/watch?v=KYA1-TF_6FY) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: No such file or directory in /home/freeyou1/public_html/YouTubeToMp3Converter.class.php on line 75
[25-Dec-2011 12:58:45] PHP Warning: file_get_contents(www.youtube.com/watch?v=KYA1-TF_6FY) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: No such file or directory in /home/freeyou1/public_html/YouTubeToMp3Converter.class.php on line 26
[25-Dec-2011 12:58:47] PHP Warning: file_get_contents() [<a href='function.file-get-contents'>function.file-get-contents</a>]: Filename cannot be empty in /home/freeyou1/public_html/YouTubeToMp3Converter.class.php on line 75
[25-Dec-2011 12:58:47] PHP Warning: file_get_contents() [<a href='function.file-get-contents'>function.file-get-contents</a>]: Filename cannot be empty in /home/freeyou1/public_html/YouTubeToMp3Converter.class.php on line 26
[25-Dec-2011 12:58:48] PHP Warning: file_get_contents() [<a href='function.file-get-contents'>function.file-get-contents</a>]: Filename cannot be empty in /home/freeyou1/public_html/YouTubeToMp3Converter.class.php on line 75
[25-Dec-2011 12:58:48] PHP Warning: file_get_contents() [<a href='function.file-get-contents'>function.file-get-contents</a>]: Filename cannot be empty in /home/freeyou1/public_html/YouTubeToMp3Converter.class.php on line 26
[25-Dec-2011 12:58:50] PHP Warning: file_get_contents() [<a href='function.file-get-contents'>function.file-get-contents</a>]: Filename cannot be empty in /home/freeyou1/public_html/YouTubeToMp3Converter.class.php on line 75
[25-Dec-2011 12:58:50] PHP Warning: file_get_contents() [<a href='function.file-get-contents'>function.file-get-contents</a>]: Filename cannot be empty in /home/freeyou1/public_html/YouTubeToMp3Converter.class.php on line 26
[25-Dec-2011 12:58:51] PHP Warning: file_get_contents() [<a href='function.file-get-contents'>function.file-get-contents</a>]: Filename cannot be empty in /home/freeyou1/public_html/YouTubeToMp3Converter.class.php on line 75
[25-Dec-2011 12:58:51] PHP Warning: file_get_contents() [<a href='function.file-get-contents'>function.file-get-contents</a>]: Filename cannot be empty in /home/freeyou1/public_html/YouTubeToMp3Converter.class.php on line 26
[25-Dec-2011 12:58:52] PHP Warning: file_get_contents() [<a href='function.file-get-contents'>function.file-get-contents</a>]: Filename cannot be empty in /home/freeyou1/public_html/YouTubeToMp3Converter.class.php on line 75
[25-Dec-2011 12:58:52] PHP Warning: file_get_contents() [<a href='function.file-get-contents'>function.file-get-contents</a>]: Filename cannot be empty in /home/freeyou1/public_html/YouTubeToMp3Converter.class.php on line 26
[25-Dec-2011 12:58:53] PHP Warning: file_get_contents() [<a href='function.file-get-contents'>function.file-get-contents</a>]: Filename cannot be empty in /home/freeyou1/public_html/YouTubeToMp3Converter.class.php on line 75
[25-Dec-2011 12:58:53] PHP Warning: file_get_contents() [<a href='function.file-get-contents'>function.file-get-contents</a>]: Filename cannot be empty in /home/freeyou1/public_html/YouTubeToMp3Converter.class.php on line 26
[25-Dec-2011 12:58:54] PHP Warning: file_get_contents() [<a href='function.file-get-contents'>function.file-get-contents</a>]: Filename cannot be empty in /home/freeyou1/public_html/YouTubeToMp3Converter.class.php on line 75
[25-Dec-2011 12:58:54] PHP Warning: file_get_contents() [<a href='function.file-get-contents'>function.file-get-contents</a>]: Filename cannot be empty in /home/freeyou1/public_html/YouTubeToMp3Converter.class.php on line 26
[25-Dec-2011 12:58:55] PHP Warning: file_get_contents() [<a href='function.file-get-contents'>function.file-get-contents</a>]: Filename cannot be empty in /home/freeyou1/public_html/YouTubeToMp3Converter.class.php on line 75
[25-Dec-2011 12:58:55] PHP Warning: file_get_contents() [<a href='function.file-get-contents'>function.file-get-contents</a>]: Filename cannot be empty in /home/freeyou1/public_html/YouTubeToMp3Converter.class.php on line 26
[25-Dec-2011 12:58:56] PHP Warning: file_get_contents() [<a href='function.file-get-contents'>function.file-get-contents</a>]: Filename cannot be empty in /home/freeyou1/public_html/YouTubeToMp3Converter.class.php on line 75
[25-Dec-2011 12:58:56] PHP Warning: file_get_contents() [<a href='function.file-get-contents'>function.file-get-contents</a>]: Filename cannot be empty in /home/freeyou1/public_html/YouTubeToMp3Converter.class.php on line 26
[25-Dec-2011 12:58:57] PHP Warning: file_get_contents() [<a href='function.file-get-contents'>function.file-get-contents</a>]: Filename cannot be empty in /home/freeyou1/public_html/YouTubeToMp3Converter.class.php on line 75
[25-Dec-2011 12:58:57] PHP Warning: file_get_contents() [<a href='function.file-get-contents'>function.file-get-contents</a>]: Filename cannot be empty in /home/freeyou1/public_html/YouTubeToMp3Converter.class.php on line 26
[25-Dec-2011 12:58:57] PHP Warning: file_get_contents() [<a href='function.file-get-contents'>function.file-get-contents</a>]: Filename cannot be empty in /home/freeyou1/public_html/YouTubeToMp3Converter.class.php on line 75
[25-Dec-2011 12:58:57] PHP Warning: file_get_contents() [<a href='function.file-get-contents'>function.file-get-contents</a>]: Filename cannot be empty in /home/freeyou1/public_html/YouTubeToMp3Converter.class.php on line 26



I'm so sorry i'v been posting on your thread all day asking for your help, I guess i'm a hopeless person haha..
Please fix this for me :(

chump2877
12-26-2011, 02:47 AM
It just occurred to me that you are trying to install this script on a Linux server....ffmpeg.exe, as I am using it, won't work correctly on a Linux server....Please see this post in this thread: http://www.codingforums.com/showpost.php?p=1136965&postcount=107

jibreel
12-26-2011, 04:20 AM
I'm pretty sure that my shared host is windows, I'm hosting the website on cirtex.com and it is the basic plan. I was actually using your script but it was modified by a user on a different forum it worked only the progress bar did not load.

Would you be able to send me the full website folder please?
By this I mean everything is in the folder and ready to upload, because I think I'm not puting the files in the folder properly , I'm sorry for wasting your time :(

chump2877
12-26-2011, 04:50 AM
I looked at your web host provider's Basic package, and it looks like you have Linux shared hosting, but FFmpeg and FFmpeg-PHP are actually already installed on the server. (Good deal!) So what happens if you change this line in YouTubeToMp3Converter.class.php:


const _FFMPEG = 'ffmpeg.exe';

...to


const _FFMPEG = 'ffmpeg';

Theoretically, on a Linux server with FFmpeg-PHP extension installed, that might be enough to point the script to the correct location of FFmpeg on your server. If not, you need to find out the location (absolute path) of FFmpeg on your server.

And the reason the progress bar doesnt work for you is because your server appears to have PHP 5.2 installed, and not PHP 5.3 or greater (http://www.codingforums.com/showpost.php?p=1173973&postcount=116).

chump2877
12-26-2011, 05:01 AM
https://support.cirtex.com/index.php?_m=knowledgebase&_a=viewarticle&kbarticleid=11

Try this:


const _FFMPEG = '/usr/local/bin/ffmpeg';

xeondream
12-26-2011, 04:12 PM
Hi Chump,

Thank you for sharing this great script with us!
I will design a template to it soon. I have just installed it and it works great locally!
Jibreel pointed out this thread to me as we both try to launch a youtube to mp3 website. We are also on the same host Cirtex.

Do you think its possible to have a progressbar at all on PHP 5.2 ?
Maybe a small part could be recoded so that it would work on php 5.2?
I just need to know if it is possible.

Thanks for all the effort and enjoy the holidays!

chump2877
12-26-2011, 04:35 PM
Do you think its possible to have a progressbar at all on PHP 5.2 ?
Maybe a small part could be recoded so that it would work on php 5.2?
I just need to know if it is possible.

I appreciate what you are saying here, but I have no plans to write more code to cater to a previous version of PHP. For now, you can disable the progress bar until such time as your server is updated to PHP 5.3.

Or you can always write your own progress bar that is compatible with PHP 5.2. Here is a link to get you started: http://stackoverflow.com/questions/1939029/curl-download-progress-in-php-not-working. I have not tried the method outlined there, but it sounds like it could work.

Also check here: http://docs.php.net/function.stream-notification-callback

xeondream
12-26-2011, 04:54 PM
I understand you don't want to go back but at least now I know its possible.
Thanks for the links also, I will get into it :-)

teslia2
01-18-2012, 11:15 AM
Hai,
i just installed:
FFmpeg, FFmpeg-php, libmp3lame, Libogg + Libvorbis, Mplayer + Mencoder on my dedicated server to use this script.

Here is php info output for ffmpeg:

http://s5.postimage.org/swelkymit/fffmpeg.png

But after i change this:

$exec_string = self::_FFMPEG.' -i '.$this->GetTempVidFileName().' -y -acodec libmp3lame -ab '.$quality.'k '.$this->GetSongFileName();

to


$exec_string = self::FFMPEG.' -i '.$this->GetTempVidFileName().' -y -acodec libmp3lame -ab '.$quality.'k '.$this->GetSongFileName();


FFMPEG

i become .flv files in videos folder on my server:

http://s5.postimage.org/c9x1bvtl1/ftp.png

YouTubeToMp3Converter.class code:
http://pastebin.com/2sUdrchj

But i with this or without i can not download or convert youtube videos...
Any help plz!?

P.S
cURL is enabled, and fopen() too

chump2877
01-18-2012, 12:26 PM
Have you commented out this line in index.php, like so:


// Execution settings
ini_set('max_execution_time',0);
//ini_set('display_errors',0);

To see what PHP errors (if any) that you are getting?

teslia2
01-18-2012, 01:49 PM
Yh i have, but i dont become any error_log files.

But after i add this:
die($exec_string);
after line:
$exec_string = self::_FFMPEG.' -i '.$this->GetTempVidFileName().' -y -acodec libmp3lame -ab '.$quality.'k '.$this->GetSongFileName();


i become this output on blank page:
/usr/bin/ffmpeg -i videos/1326890570.flv -y -acodec libmp3lame -ab 128k mp3/YoutubeuMp3net_-_Kako_skidat_sa_youtube.mp3

itsmeanthony
01-23-2012, 09:40 PM
Thank you, i'll try that :)


Hi Tony,

My first inclination would be to try and acquire that kind of information via the YouTube API. For example, here (http://code.google.com/apis/youtube/2.0/developers_guide_php.html#Retrieving_Video_Entry) is the API-way to grab a variety of data pertaining to a particular video. Further exploration (http://code.google.com/apis/youtube/2.0/reference.html#youtube_data_api_tag_entry) reveals all of the possible data that can be retrieved for a given video "entry" object. Unfortunately, the API does not appear to provide individual video file size information (I think that's what you are after?). But you might try digging around a little more and see if I missed something.

Apart from the API you might try the following link (https://www.google.com/search?client=opera&rls=en&q=php+get+file+size+of+remote+file&sourceid=opera&ie=utf-8&oe=utf-8&channel=suggest#sclient=psy-ab&hl=en&safe=off&client=opera&hs=Wcr&rls=en&channel=suggest&source=hp&q=php+get+file+size+of+remote+file&pbx=1&oq=php+get+file+size+of+remote+file&aq=f&aqi=&aql=&gs_sm=s&gs_upl=0l0l0l55036l0l0l0l0l0l0l0l0ll0l0&bav=on.2,or.r_gc.r_pw.,cf.osb&fp=a432ee3ec8892393&biw=1449&bih=834). This solution (http://www.php.net/manual/en/function.filesize.php#92462) looks promising because it involves cURL (which my script already uses to download videos), so you might incorporate this technique into the SaveVideo method, just prior to actually downloading the video. There you could institute a check for file size, and if the size was either too big (or too small?), then you could cancel the video save operation and make the method return false.

atanas
01-31-2012, 06:16 PM
Hello. Thanks to chump2877 for the nice code. I use it but i have a problem with progress bar. It shows only on firefox and it load me 3 times- about 7% - 28% and 97% of every videos. How to create new progress bar that shows actual progress bar - 1% 2% 3% 4%.... 98% 99% .

chump2877
01-31-2012, 09:16 PM
Hello. Thanks to chump2877 for the nice code. I use it but i have a problem with progress bar. It shows only on firefox and it load me 3 times- about 7% - 28% and 97% of every videos. How to create new progress bar that shows actual progress bar - 1% 2% 3% 4%.... 98% 99% .

I've just tested this code in Firefox, IE, and Opera, and it seems to work for me in all 3 browsers.

What video are you trying to convert?

You may have experienced a temporary glitch due to (possibly) difficulty connecting to/downloading from YouTube, or javascript (in any of your open tabs) slowing down the browser. Try waiting a few minutes, restarting your browser, and then converting again.

atanas
02-02-2012, 04:23 PM
I try it again and yes it works, but when i click Create Mp3 File it load about 30-40 sec and after that show progress bar and load 3 times about 30% 90% and finish. How to correct it to show progress bar of all operating (download flv + convert flv to mp3) and progress bar to show every percent, not only 3 times.

chump2877
02-06-2012, 03:09 PM
I try it again and yes it works, but when i click Create Mp3 File it load about 30-40 sec and after that show progress bar and load 3 times about 30% 90% and finish. How to correct it to show progress bar of all operating (download flv + convert flv to mp3) and progress bar to show every percent, not only 3 times.

I'm not experiencing the "choppy" progress bar for the FLV file download. But you did bring to my attention something that I hadn't noticed before: The progress bar is only measuring the FLV file download and "not" the progress of the FLV-to-MP3 file conversion as well. So I did some research into the issue (more than I bargained for!), and I discovered a fix for this.

The solution is anything but simple. I added several more files and an additional directory into the mix. The new file structure (as installed in XAMPP) is as follows:

C:\xampp\htdocs\VideoToMp3Converiter\logs
C:\xampp\htdocs\VideoToMp3Converiter\mp3
C:\xampp\htdocs\VideoToMp3Converter\videos
C:\xampp\htdocs\VideoToMp3Converter\config.class.php
C:\xampp\htdocs\VideoToMp3Converter\exec_ffmpeg.php
C:\xampp\htdocs\VideoToMp3Converter\ffmpeg.exe
C:\xampp\htdocs\VideoToMp3Converter\ffmpeg_progress.php
C:\xampp\htdocs\VideoToMp3Converter\index.php
C:\xampp\htdocs\VideoToMp3Converter\YouTubeToMp3Converter.class.php

In a nutshell, after the FLV download is complete, gauging file conversion progress entails the following:

1) Using cURL to connect to another PHP file (exec_ffmpeg.php) whose only job is to execute the FFMPEG process. The cURL connection times out after 10 milliseconds, forcing YouTubeToMp3Converter::GenerateMP3() to "hang up" on exec_ffmpeg.php -- allowing the FFMPEG command to essentially run in parallel to the main program (by severing their connection).

2) Using the FFMPEG command (in exec_ffmpeg.php) to create a log file of the current running FFMPEG process (the file conversion). The log file is a temporary file (stored in the /logs directory), and it's instrumental to figuring conversion progress.

3) Using AJAX (jQuery) to repeatedly access a PHP file (ffmpeg_progress.php) that subsequently polls the log file to find out what percent of the conversion is completed. (The log file contains information that enables this calculation.) We then use this changing percentage to construct the conversion progress bar.


A few things worth noting:

1) Initially, I was against creating/manipulating log files for every conversion because it seemed like a lot of overhead (if you were to scale the application up to fit a larger user base and heavy usage patterns). But I could not find any other way to gauge conversion progress. So take it or leave it, I guess...

2) There is very little in the way of validation here, and you will definitely need to add that for a production-ready application. Of specific note: The exec() call in exec_ffmpeg.php takes a POST variable directly as its parameter. Please, if you are using this for more than your own personal use (as I am), sanitize the command before you place it in exec(). You may even want to password-protect this code in some way (i.e., run exec() only if some unique token is present) to prevent abuse. Additional possibilities include some application of escapeshellcmd (http://www.php.net/manual/en/function.escapeshellcmd.php) and/or escapeshellarg (http://www.php.net/manual/en/function.escapeshellarg.php). When I get some more time, I may implement one or a combination of these methods myself.

3) Again, when I have more time, I would like to refactor some of the code and clean things up a bit (per my tastes).


So that's pretty much the long and short of things. I definitely value any feedback that you can provide regarding bugs, suggestions, criticisms, and improvements to the code/functionality.

Download the revised files below:

Brunob
02-06-2012, 04:23 PM
prejudice dear excuse my English, I'm testing the script in a linux server with ffmpeg installed and running, I put in config.class.php parameters: / / Constants
= const _TEMPVIDDIR 'videos /';
_SONGFILEDIR const = 'mp3 /';
_FFMPEG const = '/ usr / local / bin / ffmpeg';
_LOGSDIR const = 'logs /';
inserting in input the url of youtube nothing happens I see the preview image tells me the title, the Progressed bar is paralyzed, nothing happens something wrong?
Tanks

zemaitis
02-06-2012, 06:16 PM
Okay i installed in my VPS server:

Ubuntu 10.04 Lucid Lynx (32Bit)
Newest version of this youtube files (2-6-12)

Did as this guide told me to

sudo apt-get install apache2
sudo apt-get install php5
sudo apt-get install php5-ffmpeg
(restart system)
sudo apt-get install curl libcurl3 libcurl3-dev php5-curl php5-mcrypt
/etc/php5/apache2/php.ini chmod 777 it and enable curl by adding line extension=curl.so
(restart system or apache)
$ sudo /etc/init.d/apache2 restart
download file and put in www
chmod 777 mp3
chmod 777 videos
get the lame mp3 encoder
sudo apt-get install ffmpeg libavcodec-extra-52
changed const _FFMPEG = 'ffmpeg.exe'; path ffmpeg.exe to /usr/bin/ffmpeg


My result: http://91.224.92.69/

Php info: http://91.224.92.69/test.php

File is downloaded to my VPS as flv, but it is not converted (looked at mp3 directory, its empty)

/var/log/apache2 logs show:


[Mon Feb 06 17:06:59 2012] [error] [client 212.12.201.191] File does not exist: /var/www/favicon.ico
[Mon Feb 06 17:07:09 2012] [error] [client 212.12.201.191] PHP Fatal error: Class 'Config' not found in /var/www/ffmpeg_progress.php on line 14, referer: http://91.224.92.69/index.php
[Mon Feb 06 17:08:24 2012] [error] [client 212.12.201.191] File does not exist: /var/www/favicon.ico
[Mon Feb 06 17:08:26 2012] [error] [client 212.12.201.191] PHP Warning: Division by zero in /var/www/YouTubeToMp3Converter.class.php on line 103, referer: http://91.224.92.69/index.php
[Mon Feb 06 17:08:27 2012] [error] [client 212.12.201.191] File does not exist: /var/www/favicon.ico
[Mon Feb 06 17:08:47 2012] [error] [client 84.32.224.63] PHP Notice: Undefined index: submit in /var/www/index.php on line 142
[Mon Feb 06 17:08:47 2012] [error] [client 84.32.224.63] File does not exist: /var/www/favicon.ico
[Mon Feb 06 17:08:47 2012] [error] [client 84.32.224.63] File does not exist: /var/www/favicon.ico
[Mon Feb 06 17:08:47 2012] [error] [client 84.32.224.63] File does not exist: /var/www/favicon.ico
[Mon Feb 06 17:09:03 2012] [error] [client 84.32.224.63] PHP Warning: Division by zero in /var/www/YouTubeToMp3Converter.class.php on line 103, referer: http://91.224.92.69/index.php
[Mon Feb 06 17:09:03 2012] [error] [client 84.32.224.63] PHP Warning: Division by zero in /var/www/YouTubeToMp3Converter.class.php on line 103, referer: http://91.224.92.69/index.php
[Mon Feb 06 17:09:03 2012] [error] [client 84.32.224.63] PHP Warning: Division by zero in /var/www/YouTubeToMp3Converter.class.php on line 103, referer: http://91.224.92.69/index.php
[Mon Feb 06 17:09:03 2012] [error] [client 84.32.224.63] PHP Warning: Division by zero in /var/www/YouTubeToMp3Converter.class.php on line 103, referer: http://91.224.92.69/index.php
[Mon Feb 06 17:09:03 2012] [error] [client 84.32.224.63] PHP Warning: Division by zero in /var/www/YouTubeToMp3Converter.class.php on line 103, referer: http://91.224.92.69/index.php
[Mon Feb 06 17:09:04 2012] [error] [client 84.32.224.63] PHP Warning: Division by zero in /var/www/YouTubeToMp3Converter.class.php on line 103, referer: http://91.224.92.69/index.php
[Mon Feb 06 17:11:37 2012] [error] [client 212.12.201.191] File does not exist: /var/www/favicon.ico
[Mon Feb 06 17:11:39 2012] [error] [client 212.12.201.191] PHP Warning: Division by zero in /var/www/YouTubeToMp3Converter.class.php on line 103, referer: http://91.224.92.69/index.php
[Mon Feb 06 17:11:39 2012] [error] [client 212.12.201.191] File does not exist: /var/www/favicon.ico
[Mon Feb 06 17:16:00 2012] [error] [client 212.12.201.191] PHP Notice: Undefined index: submit in /var/www/index.php on line 142
[Mon Feb 06 17:16:01 2012] [error] [client 212.12.201.191] File does not exist: /var/www/favicon.ico
[Mon Feb 06 17:18:00 2012] [error] [client 212.12.201.191] File does not exist: /var/www/favicon.ico
[Mon Feb 06 17:18:10 2012] [error] [client 212.12.201.191] PHP Notice: Undefined index: submit in /var/www/index.php on line 142
[Mon Feb 06 17:18:10 2012] [error] [client 212.12.201.191] File does not exist: /var/www/favicon.ico

chump2877
02-06-2012, 08:44 PM
Thanks for the responses...I'll look into the issues that you are having here later this evening and get back to you...

zemaitis
02-06-2012, 09:08 PM
And oh i had to reinstall my OS on VPS so there aren't any result pages left, but what i can tell:

The script downloaded flv files sucessfully, but didn't converted them (mp3's directory was empty)

Also talking about phpinfo (it was reading all the configs, curl was on as fopen, also ffmpeg.ini files were readed to)

chump2877
02-07-2012, 01:13 AM
And oh i had to reinstall my OS on VPS so there aren't any result pages left, but what i can tell:

The script downloaded flv files sucessfully, but didn't converted them (mp3's directory was empty)

Also talking about phpinfo (it was reading all the configs, curl was on as fopen, also ffmpeg.ini files were readed to)

A few things to try:

1) Is your path to FFMPEG correct? Try '/usr/local/bin/ffmpeg'?

2) Are you using at least PHP 5.3?

3) Try chmod'ing the 'logs/' directory to 0777 as well?

4) You had the following error message in your server log: PHP Fatal error: Class 'Config' not found in /var/www/ffmpeg_progress.php on line 14. Make sure that this line of code:


include 'config.class.php';

...appears at the top of ffmpeg_progress.php.

5) Comment out this line in index.php, like so:


// Execution settings
ini_set('max_execution_time',0);
//ini_set('display_errors',0);

To see what PHP errors (if any) that you are getting?


I have the code running great in my local XAMPP development environment, so everything should work if set up correctly.

chump2877
02-07-2012, 03:35 AM
Hi guys, I went back and retested the code, and it's not working right for me either...it was working last night, so I'm sure I just need to tweak something somewhere...I'll get back to you with a fix when I get the chance...

Edit: And now it's working for me again. This clearly seems to be a hit-or-miss type of thing, so, again, I'll get back to you later with a fix.

chump2877
02-07-2012, 06:11 AM
Back again! I'm having a hard time making the code break again after playing with it some more.

So, for those having a problem with the most recent distribution of files (2-6-12.zip), please do the following for me:

1) Change the jQuery $.ajax() call in updateConversionProgress() in index.php to read:


$.ajax({
type : "POST",
url : "ffmpeg_progress.php",
data : "uniqueId=<?php echo $converter->GetUniqueID(); ?>&logLength=" + conversionLogLength + "&mp3File=" + encodeURI(songFile),
success : function(retVal, status, xhr) {
var retVals = retVal.split('|');
if (retVals[3] == 2)
{
progress.style.width = progress.innerHTML = parseInt(retVals[1]) + '%';
if (parseInt(retVals[1]) < 100)
{
conversionLogLength = parseInt(retVals[0]);
setTimeout(function(){updateConversionProgress(songFile);}, 10);
}
else
{
$("#preview").css("display", "none");
var convertSuccessMsg = (retVals[2] == 1) ? '<p>Success!</p><p><a href="<?php echo $_SERVER['PHP_SELF']; ?>?mp3=' + encodeURI(songFile) + '">Download your MP3 file</a>.</p>' : '<p>Error generating MP3 file!</p>';
$("#conversionSuccess").html(convertSuccessMsg);
$("#conversionForm").css("display", "block");
}
}
else
{
setTimeout(function(){updateConversionProgress(songFile);}, 1);
}
},
error : function(xhr, status, ex) {
setTimeout(function(){updateConversionProgress(songFile);}, 1);
}
});

All I did was add an error handler for a failed AJAX request (which retries the request). I wonder if that will fix some (or all?) of your problems?

2) If you are still having issues, please report the AJAX response text using either Firebug in Firefox or Dragonfly in Opera (http://superdit.com/2010/07/15/tools-for-analyzing-ajax-request-on-popular-web-browser/) (or any other way that you accomplish the task).

If there aren't any (PHP) errors in the response, the AJAX response text will generally look like the following (for example):


2577|95|2|2

...or


0|100|1|2

The first number indicates FFMPEG log file length, the second # indicates conversion progress (on a scale of 1-100), the third indicates conversion success, and the fourth indicates whether an error occurred.

I have periodically been getting file permission errors in the AJAX response text (which results in videos and log files not being deleted after the conversion process has finished). I'm not sure why because I think my permissions are set correctly. Please let me know if you experience the same.

chump2877
02-08-2012, 04:06 AM
Another thing to try is to increase the number of milliseconds in this line in YouTubeToMp3Converter::GenerateMP3() in YouTubeToMp3Converter.class.php:


curl_setopt($ch, CURLOPT_TIMEOUT_MS, 10);

...to...


curl_setopt($ch, CURLOPT_TIMEOUT_MS, 100);

...or even higher, perhaps...personally, I bumped it up to 100, and so far so good...Reasoning behind this: I noticed that sometimes the log file isn't created by FFMPEG, so I'm guessing that cURL hasn't had a chance to send everything to exec_ffmpeg.php before the CURL connection is severed by CURLOPT_TIMEOUT_MS?

Also CURLOPT_TIMEOUT_MS, per php.net (http://us.php.net/manual/en/function.curl-setopt.php), was added in cURL 7.16.2 and available since PHP 5.2.3. So it will only work for those versions and higher. If you don't have those versions, try CURLOPT_TIMEOUT instead (for example):


curl_setopt($ch, CURLOPT_TIMEOUT, 1);

Can someone let me know if any of these proposed fixes are helping?? Thanks.

neoanderson
02-09-2012, 02:42 AM
Same vps setting of zemaitis, testing it on my vps, and let you know ;)

zemaitis
02-10-2012, 05:00 PM
Ok launched my system for testing again, address

http://91.224.92.69/

PHP INFO http://91.224.92.69/test.php

Downloads, but doesn't compile the video to mp3. I have to mention that I'm doing everything with root account.

Setting in config.class.php :

const _FFMPEG = '/usr/bin/ffmpeg';


Looks like i wil need to get a windows VPS to run this script...

zemaitis
02-10-2012, 09:11 PM
It would be really nice if somebody would give a tutorial how to install this on Ubuntu or Debian.

zemaitis
02-10-2012, 10:55 PM
Um i have one request.

Can u make a custom prefix, setted by variable, for the outputed mp3 files? For example, John is downloading a song: Three Days Grace - Never too late, and the output is Three_days_grace_-_never_too_late.mp3, but i want that he would get the file named Three_days_grace-_-never_too_late_www.mysite.com.mp3

chump2877
02-11-2012, 08:24 AM
When I get a chance, I'll load Ubuntu into a virtual machine and come up with some instructions for installing the application in that environment. I know it has worked for others using Linux and ffmpeg-php.

I will also attach another updated copy of the distribution files with my recent fixes.

FWIW, the code seems to consistently work for me now using XAMPP on Windows.

Please remember that I work on this script in my spare time. I make no money from this. (Did I mention that your donations are welcome??) A lot of people have shown an interest in this application, and I will do my best to maintain this code as well as implement new functionality requests as time permits.


Can u make a custom prefix, setted by variable, for the outputed mp3 files? For example, John is downloading a song: Three Days Grace - Never too late, and the output is Three_days_grace_-_never_too_late.mp3, but i want that he would get the file named Three_days_grace-_-never_too_late_www.mysite.com.mp3

You should be able to change the downloaded file name in YouTubeToMp3Converter::DownloadMP3() via the following line of code:


header('Content-Disposition: attachment; filename="'.urldecode($file).'"');

AFAIK, the name given to the downloadable file attachment does not have to match the actual name of the MP3 file on the server. So you could modify the above code as follows, per your example:


$siteName = 'www.mysite.com';
$fname = preg_replace('/^((.+?)(\.mp3))$/', "$2_".$siteName."$3", urldecode($file));
header('Content-Disposition: attachment; filename="'.$fname.'"');

That code is untested, but you get the general idea. You could even make $siteName a class field or constant in either YouTubeToMp3Converter class or Config class -- depending on what you are doing.

zemaitis
02-11-2012, 09:52 AM
Okay, waiting forward for a guide for ubuntu :)

Also i have a problem, if file in youtube is called „ŽAS - Life is good“ the output name is „as_-life_is_good“ without he letter Ž. It would be okay if it would be replaced to Z.

P.S. i'm using older version of ur downloader

chump2877
02-12-2012, 08:19 AM
I've installed the files on Ubuntu and it's working. Just FYI. Will work on a tutorial. I mostly used the Synaptic Package Manager instead of the command line for installing packages. Will update this thread as soon as I can!

zemaitis
02-12-2012, 08:55 AM
Can you write guide with command line too? Cuz everyone will install on their VPS and there aren't desktop visualization.

chump2877
02-12-2012, 11:28 AM
OK, the new (updated and hopefully stable) distribution of files is located at the bottom of this post.


File system structure for XAMPP for Windows (you will need to download ffmpeg.exe from the FFMPEG site, as instructed earlier in this thread):

C:\xampp\htdocs\VideoToMp3Converter\logs
C:\xampp\htdocs\VideoToMp3Converter\mp3
C:\xampp\htdocs\VideoToMp3Converter\videos
C:\xampp\htdocs\VideoToMp3Converter\config.class.php
C:\xampp\htdocs\VideoToMp3Converter\exec_ffmpeg.php
C:\xampp\htdocs\VideoToMp3Converter\ffmpeg.exe
C:\xampp\htdocs\VideoToMp3Converter\ffmpeg_progress.php
C:\xampp\htdocs\VideoToMp3Converter\index.php
C:\xampp\htdocs\VideoToMp3Converter\YouTubeToMp3Converter.class.php


File system structure for Apache on Ubuntu 11.10 (Linux):

/home/user/public_html/youtube/logs
/home/user/public_html/youtube/mp3
/home/user/public_html/youtube/videos
/home/user/public_html/youtube/config.class.php
/home/user/public_html/youtube/exec_ffmpeg.php
/home/user/public_html/youtube/ffmpeg_progress.php
/home/user/public_html/youtube/index.php
/home/user/public_html/youtube/YouTubeToMp3Converter.class.php


In Config class in config.class.php, set _FFMPEG constant to:

1) For XAMPP for Windows:


const _FFMPEG = 'ffmpeg.exe';

2) For Ubuntu (Linux):


const _FFMPEG = '/usr/bin/ffmpeg';

(Note to Linux users: If the above is not the correct path to FFMPEG, you can type "whereis ffmpeg" into a command line for the correct path on your system.)


For Ubuntu (Linux) users, I will try to explain the additional steps required to configure this application. Warning: I am not a Linux expert nor am I a command line expert! Also, I installed the application on a full, desktop version of Ubuntu on my development machine. Thus, the burden falls on you to adapt these instructions for a commercially hosted VPS (that may only provide a command line interface):

1) Move the web root to /home/user/public_html/ from /var/www/ if you haven't already (if it's not already done for you) by following directions here (scroll to the "Changing the default localhost folder" subhead): http://maketecheasier.com/install-and-configure-apache-in-ubuntu/2011/03/09. (Doing this helped me solve all kinds of file permissions headaches when not operating as the 'root' user.)

2) A history of the packages I installed:

Installed the following packages:
apache2 (2.2.20-1ubuntu1.1)
apache2-mpm-worker (2.2.20-1ubuntu1.1)
apache2-utils (2.2.20-1ubuntu1.1)
apache2.2-bin (2.2.20-1ubuntu1.1)
apache2.2-common (2.2.20-1ubuntu1.1)
libapr1 (1.4.5-1)
libaprutil1 (1.3.12+dfsg-2)
libaprutil1-dbd-sqlite3 (1.3.12+dfsg-2)
libaprutil1-ldap (1.3.12+dfsg-2)

Removed the following packages:
apache2-mpm-worker

Installed the following packages:
apache2-mpm-itk (2.2.20-1ubuntu1.1)
libapache2-mod-php5filter (5.3.6-13ubuntu3.5)
php5 (5.3.6-13ubuntu3.5)
php5-cli (5.3.6-13ubuntu3.5)
php5-common (5.3.6-13ubuntu3.5)

Installed the following packages:
curl (7.21.6-3ubuntu3.2)
libcurl3 (7.21.6-3ubuntu3.2)

Installed the following packages:
ffmpeg (4:0.7.3-0ubuntu0.11.10.1)
libavcodec53 (4:0.7.3-0ubuntu0.11.10.1)
libavdevice53 (4:0.7.3-0ubuntu0.11.10.1)
libavfilter2 (4:0.7.3-0ubuntu0.11.10.1)
libavformat53 (4:0.7.3-0ubuntu0.11.10.1)
libavutil51 (4:0.7.3-0ubuntu0.11.10.1)
libdc1394-22 (2.1.3-4)
libgsm1 (1.0.13-3)
libpostproc52 (4:0.7.3-0ubuntu0.11.10.1)
libschroedinger-1.0-0 (1.0.10-2.1)
libswscale2 (4:0.7.3-0ubuntu0.11.10.1)
libva1 (1.0.12-2)
libvpx0 (0.9.6-1)

Installed the following packages:
php5-curl (5.3.6-13ubuntu3.5)

Installed the following packages:
php5-ffmpeg (0.6.0-2ubuntu2)
php5-gd (5.3.6-13ubuntu3.5)

Installed the following packages:
libmp3lame0 (3.98.4-0ubuntu1)

Removed the following packages:
libavcodec53
libavutil51

Installed the following packages:
libavcodec-extra-53 (4:0.7.3ubuntu0.11.10.1)
libavutil-extra-51 (4:0.7.3ubuntu0.11.10.1)
libdirac-encoder0 (1.0.2-4)
libopenjpeg2 (1.3+dfsg-4)
libvo-aacenc0 (0.1.1-1)
libvo-amrwbenc0 (0.1.1-1)
libx264-116 (2:0.116.2042+git178455c-1ubuntu1)
libxvidcore4 (2:1.3.2-3)

3) You may need to restart Apache after all packages have been installed (or in between installations?) via the command line:

$sudo service apache2 stop
$sudo service apache2 start

4) Make sure the following lines appear in your php.ini:

extension=curl.so
extension=ffmpeg.so

5) Set write permissions on the following directories: chmod 777 mp3, chmod 777 videos, chmod 777 logs

6) software.xml should be set to chmod 0777, or the lowest permissions possible that still enable programmatic modification of this file. There should be no need to edit software.xml, and thus modifying this file is strongly discouraged.

7) The root directory where my software is installed should also be set to the lowest permissions possible that still enable programmatic creation, opening, and modification of the containing files. In the example file system structures above, those directories are 'C:\xampp\htdocs\VideoToMp3Converter' and '/home/user/public_html/youtube/'.


Finally, zemaitis, or anyone else familiar with the Linux command line interface, it would be great if you could adapt all of this for the command line and publish the result here! It would certainly help me and any others using this script on commercially hosted servers.

As always, please let me know if you have any questions/concerns regarding the above and/or the code.

See the new zip file below:


. . . !! ALERT !!

Windows and XAMPP users, you MUST read this post (http://www.codingforums.com/showpost.php?p=1222520&postcount=323) first (before installing/configuring my app)! The latest static builds of ffmpeg.exe will not work with my code!
Please download the older build of ffmpeg.exe required for my app HERE. (https://mega.co.nz/#!5s1AWQpJ!WnLuD9nbizl5YSmVVsJplgEVDbZ1gamsDHZRkSITtkY)
(Because the file is over 4 MB and this forum doesn't allow large file attachments, the file is being hosted at MEGA instead.)
This does NOT affect Linux users.

zemaitis
02-12-2012, 12:09 PM
Now im searching for a commercial vps, cause i sold mine because of script not working properly ;D

Also there exists one problem, if video is with symbol ž, in the final name of the file, there aren't any replacement for it. It would need to be z... I dont know how is there with letters ąčęėįšųū

chump2877
02-12-2012, 01:10 PM
Now im searching for a commercial vps, cause i sold mine because of script not working properly ;D

Also there exists one problem, if video is with symbol ž, in the final name of the file, there aren't any replacement for it. It would need to be z... I dont know how is there with letters ąčęėįšųū

Can you give me a link to a YouTube video with characters like those in the title....I suspect there is a PHP extension that exposes functions capable of making the conversion...

zemaitis
02-12-2012, 01:35 PM
Can you give me a link to a YouTube video with characters like those in the title....I suspect there is a PHP extension that exposes functions capable of making the conversion...

http://www.youtube.com/watch?v=5bbZRMf2zzE
http://www.youtube.com/watch?v=2QbqawL_lL4

That letters dissapear while converting, should be

ą -> a
č -> c
ę -> e
ė -> e
į -> i
š -> s
ų -> u
ū -> u

Also would be great if you do that compatible for all ur plugin versions.

zemaitis
02-12-2012, 01:51 PM
Talking about dedicated host, the start should look like this (not all lines included..)

sudo apt-get update
sudo apt-get install apache2 apache2-mpm-worker apache2-utils apache2.2-bin apache2.2-common libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap
sudo apt-get remove apache2-mpm-worker
sudo apt-get install apache2-mpm-itk libapache2-mod-php5filter php5 php5-cli php5-common

Further i was unable to install nothing, for example it said that it is unable to find package libavcodec53

chump2877
02-12-2012, 02:45 PM
http://www.youtube.com/watch?v=5bbZRMf2zzE
http://www.youtube.com/watch?v=2QbqawL_lL4

That letters dissapear while converting, should be

ą -> a
č -> c
ę -> e
ė -> e
į -> i
š -> s
ų -> u
ū -> u

Also would be great if you do that compatible for all ur plugin versions.

Edit VideoToMp3Converter::ExtractSongTrackName as follows:


function ExtractSongTrackName($vidSrc, $srcType)
{
$name = '';
$vidSrcTypes = $this->GetVidSrcTypes();
if (in_array($srcType, $vidSrcTypes))
{
$vidSrc = ($srcType == $vidSrcTypes[1]) ? file_get_contents($vidSrc) : $vidSrc;
if ($vidSrc !== false && eregi('eow-title',$vidSrc))
{
$name = end(explode('eow-title',$vidSrc));
$name = current(explode('">',$name));
$name = ereg_replace('[^-_a-zA-Z,"\' :0-9]', "", iconv("UTF-8", "ISO-8859-1//TRANSLIT", end(explode('title="', $name))));
}
}
return $name;
}

The key here is the use of iconv() (http://us2.php.net/manual/en/function.iconv.php).

chump2877
02-12-2012, 02:57 PM
Talking about dedicated host, the start should look like this (not all lines included..)

sudo apt-get update
sudo apt-get install apache2 apache2-mpm-worker apache2-utils apache2.2-bin apache2.2-common libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap
sudo apt-get remove apache2-mpm-worker
sudo apt-get install apache2-mpm-itk libapache2-mod-php5filter php5 php5-cli php5-common

Further i was unable to install nothing, for example it said that it is unable to find package libavcodec53

I just regurgitated the (relevant) chronologically-listed package install history from Synaptic Package Manager in Ubuntu. You'll notice that some packages were installed and then removed. 'libavcodec53' is an example of that. It appears that 'libavcodec53' was installed/bundled with ffmpeg. Then, later, 'libavcodec53' is removed and replaced with 'libavcodec-extra-53' (probably because I realized that 'libavcodec53' wasn't doing the job).

zemaitis
02-12-2012, 05:40 PM
Thank you for the file name fixes, working very well!

Well, i decided to buy Windows VPS and to forget problems about linux :)

In my opinion, i have last question about the file names, how to fix the quotes, periods, brackets problem? For example, video

http://www.youtube.com/watch?v=nvmlr89qTTs called as „Žas- "Ji suka (gyvenimo ratu)" Gyvai 1997.“

extracts as „Zas- quotJi suka gyvenimo ratuquot Gyvai 1997“ (quotes written as the word quot,periods,brackets disappeared)

chump2877
02-12-2012, 07:36 PM
In my opinion, i have last question about the file names, how to fix the quotes, periods, brackets problem? For example, video

http://www.youtube.com/watch?v=nvmlr89qTTs called as „Žas- "Ji suka (gyvenimo ratu)" Gyvai 1997.“

extracts as „Zas- quotJi suka gyvenimo ratuquot Gyvai 1997“ (quotes written as the word quot,periods,brackets disappeared)

Try this code instead of the previous code that I posted earlier:


function ExtractSongTrackName($vidSrc, $srcType)
{
$name = '';
$vidSrcTypes = $this->GetVidSrcTypes();
if (in_array($srcType, $vidSrcTypes))
{
$vidSrc = ($srcType == $vidSrcTypes[1]) ? file_get_contents($vidSrc) : $vidSrc;
if ($vidSrc !== false && eregi('eow-title',$vidSrc))
{
$name = end(explode('eow-title',$vidSrc));
$name = current(explode('">',$name));
$name = html_entity_decode(iconv("UTF-8", "ISO-8859-1//TRANSLIT", end(explode('title="', $name))));
}
}
return $name;
}

zemaitis
02-13-2012, 05:49 PM
Are there any necessary ports required to run this service? i have rent my vps on http://77.241.193.246/index.php but the script doesnt download files. Opened ports 80, 3306

It creates a file, but doesn't download http://www.part.lt/img/2801508fc3110dba2cc00ba023a9dc1e281.JPG

or are there programs necessary like redistributable or newer media player?

chump2877
02-13-2012, 06:08 PM
Running the script in XAMPP on Windows and running the script on an actual Windows server with Apache/PHP installed are two different animals. I have not tested the script in the latter environment.

And if you are running XAMPP on a Windows server that already has Apache/PHP installed, then you will have 2 different web roots and only one can be assigned localhost. I imagine there might be additional conflicts as well.

Moral of the story: If you are aiming to publish this on the web, then don't use XAMPP for Windows. Use a regular Windows or Linux server.

To answer your question about the ports: I have no idea.

But if you run this on a Windows server with Apache and PHP installed (as it seems you are), you'll want to research the right way to install/configure cURL in that setup: https://www.google.com/search?client=opera&rls=en&q=php+curl+windows+apache&sourceid=opera&ie=utf-8&oe=utf-8&channel=suggest

zemaitis
02-13-2012, 06:25 PM
Enabled curl in php.ini, everything works like a charm :)

Thank you chump for supporting me this all time. Was unexpected from the script admin, started being developed before 2 yrs. If i will have some success, I will donate you.

chump2877
02-13-2012, 07:05 PM
Enabled curl in php.ini, everything works like a charm :)

Thank you chump for supporting me this all time. Was unexpected from the script admin, started being developed before 2 yrs. If i will have some success, I will donate you.

Glad to hear you got it working :).....I needed to test this script in a Linux installation anyway, so we helped each other...;)

cana888
02-13-2012, 10:52 PM
Hi, i have same problem in ubuntu 11.04

CURL is enabled:
http://i.minus.com/jbnK1QRm6maakt.jpg (http://min.us/mRdvdfedJ#1o)

File converting good:
http://i.minus.com/j6EQqVJxTwdup.jpg (http://min.us/mRdvdfedJ#2o)

Website still look like this:
http://i.minus.com/jlj87cDoooMH1.jpg (http://min.us/mbjSFjgy2A#1o)

No download link nothing heppend...!!!
What can I do?

chump2877
02-14-2012, 05:28 AM
1) cana888, for that conversion, is there a corresponding log file in the '/logs' directory? A corresponding video in the '/videos' directory?

2) If you are getting a log file, can you attach the file to your next post to this thread?

3) What is the link to the video that you are trying to convert?

4) Is this line of code included in your index.php:


<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

5) Using Firebug in Firefox, can you paste the AJAX response text here (if there is any), for the multiple AJAX requests?

6) Is this line included in YouTubeToMp3Converter::GenerateMP3():


curl_setopt($ch, CURLOPT_TIMEOUT, 1);

7) Have you edited the FFMPEG command in anyway (in YouTubeToMp3Converter::GenerateMP3)?

8) Have you edited any code anywhere in the app?

9) Also, try moving your web root from /var/www/ to /home/user/public_html/ (to combat any permissions issues). And set write permissions on the mp3, logs, and videos directories.

zemaitis
02-14-2012, 11:47 AM
Another problem - bad youtube video address. I get this error when trying to download this video from youtube - http://www.youtube.com/watch?v=222kQyGGoWg

Others don't cause this problem.

zemaitis
02-14-2012, 12:16 PM
I think it's the problem because address includes a letter Q, W or X which doesn't exist in UTF 8?

atanas
02-14-2012, 02:25 PM
The new progress bar is perfect but i try my old version and convert file faster. Before for 1 clip need 10 seconds, now for the same clip need 48 seconds to get mp3 file.

chump2877
02-14-2012, 03:25 PM
I think it's the problem because address includes a letter Q, W or X which doesn't exist in UTF 8?

The title of that video looks to contain russian or something? So iconv() is looking to transliterate to a ISO-8859-1 charset equivalent, can't figure it out, and subsequently returns an empty string (and a PHP notice if you turn on error reporting).

Honestly, for cases like this, I would probably institute a default track name/file name when iconv() fails and returns an empty string, i.e.:


function ExtractSongTrackName($vidSrc, $srcType)
{
$name = '';
$vidSrcTypes = $this->GetVidSrcTypes();
if (in_array($srcType, $vidSrcTypes))
{
$vidSrc = ($srcType == $vidSrcTypes[1]) ? file_get_contents($vidSrc) : $vidSrc;
if ($vidSrc !== false && eregi('eow-title',$vidSrc))
{
$name = end(explode('eow-title',$vidSrc));
$name = current(explode('">',$name));
$name = end(explode('title="', $name));
$name = iconv("UTF-8", "ISO-8859-1//TRANSLIT", $name);
$name = (!empty($name)) ? html_entity_decode($name) : 'unknown';
}
}
return $name;
}

You could spend some time and hunt around for a way to effectively translate the (russian?) characters, but, nevertheless, you will inevitably run into problems with the mp3 file name. As far as I know the file name can only contain English letters, right? So it seems to me that a default track name/file name is adequate for edge-case scenarios like this....


Edit: And it's probably best to randomize (or make unique) the 'unknown' track name in the code above to minimize naming conflicts (at least until you delete the mp3 from the mp3 directory at some point), i.e.:


$name = (!empty($name)) ? html_entity_decode($name) : 'unknown_'.time();

zemaitis
02-14-2012, 03:49 PM
Will be good for now :) Thank you again

chump2877
02-14-2012, 03:52 PM
The new progress bar is perfect but i try my old version and convert file faster. Before for 1 clip need 10 seconds, now for the same clip need 48 seconds to get mp3 file.

That's a side effect of using AJAX to incrementally check the converted file size via the corresponding log file generated by FFMPEG. Like I said earlier, I don't like the idea of retrieving log file contents every second or every so many milliseconds to build a progress bar (because not only is it slower, but it uses more server resources!), but I could not find a better way to gauge FFMPEG conversion progress. So it is what it is, take it or leave it. If you don't like the progress bar or bars, you can always use a loading animation instead.


Edit: I'm using file_get_contents (in ffmpeg_progress.php) to read the log file....you might use readfile() or fpassthru() instead, since the time trials documented here (http://raditha.com/wiki/Readfile_vs_include) seem to indicate that these functions could shave some time off a file-read operation...maybe I will experiment with this later when I get the chance...

cana888
02-14-2012, 05:23 PM
1) cana888, for that conversion, is there a corresponding log file in the '/logs' directory? A corresponding video in the '/videos' directory?

2) If you are getting a log file, can you attach the file to your next post to this thread?

3) What is the link to the video that you are trying to convert?

4) Is this line of code included in your index.php:


<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

5) Using Firebug in Firefox, can you paste the AJAX response text here (if there is any), for the multiple AJAX requests?

6) Is this line included in YouTubeToMp3Converter::GenerateMP3():


curl_setopt($ch, CURLOPT_TIMEOUT, 1);

7) Have you edited the FFMPEG command in anyway (in YouTubeToMp3Converter::GenerateMP3)?

8) Have you edited any code anywhere in the app?

9) Also, try moving your web root from /var/www/ to /home/user/public_html/ (to combat any permissions issues). And set write permissions on the mp3, logs, and videos directories.

Thanks for quick answer chump2877.

1. Yes logs files are in /logs folder and video files on /videos folder
2. here is logs file:
http://i.minus.com/jxajreXdvAA94.jpg (http://min.us/mVZC8NdNR#1o)
3. I'm traing alot of videos bat its dosend work here is a sample link of video:
http://www.youtube.com/watch?v=hnE-dTiBD7g
4. Yes
5. I don't know its that what you mean:
http://i.minus.com/joDtdlAy40ILa.jpg (http://min.us/mjOdr5dGj#1o)
6. Yes
7. No nothing.
8. No nothing.
9. I have moved root directory from /var/www o /home/user/public_html and gived chmod777 to logs, mp3, and videos folder:
http://i.minus.com/jJvwkjbIlfGCj.jpg (http://min.us/mVZC8NdNR#2o)

I don't know where the problem is?!!!

chump2877
02-14-2012, 05:57 PM
cana888, I can't reproduce the issue on my end. Everything worked as expected for me in Ubuntu when I tried to convert the video (link) that you posted.

There seems to be a problem with your AJAX requests - which explains why the conversion progress bar isn't updated and you don't see the download link after the conversion completes. It also could be the reason your log file and video aren't deleted after successful conversion.


5) Using Firebug in Firefox, can you paste the AJAX response text here (if there is any), for the multiple AJAX requests?

You were close (regarding your screen shot). That is the correct tab in Firebug. Now you just need to expand the various + marks next to each request, copy the response text, and paste it here.

Question: Do the AJAX requests in Firebug continue on indefinitely even after the page has stopped loading? In other words, do those lines keep getting generated in Firebug even after the page has loaded?

zemaitis
02-14-2012, 08:37 PM
If someday this script will be available on commercial Linux VPS, I'l grab it the first day :D

chump2877
02-14-2012, 11:28 PM
If someday this script will be available on commercial Linux VPS, I'l grab it the first day :D

I think it is available as long as you know the right sequence of commands to enter into the CLI....;)

zemaitis
02-15-2012, 08:09 AM
I dont know the commands ;>

Aimee11
02-15-2012, 09:23 AM
Maybe just use some program to convert the YouTube to MP3:
1. Zamzar – A free online site, which supports to download and convert YouTube videos to many file formats includes: Image formats, Music formats, Doc formats, Video formats, E-book format

2. Enolsoft YouTube to MP3 – A tool can easily and quickly extract audio tracks from YouTube videos (including HD) to MP3 formats. This YouTube to MP3 Converter supports to input multiple YouTube video URLs at a time for batch downloading to MP3 formats, as well as downloading YouTube videos to AIFF, M4A, AAC, WAV, WMA and OGG audio formats.

chump2877
02-15-2012, 11:04 AM
You can use FFMPEG to convert from just about any media file format to another media file format. So it would just be a matter of changing the FFMPEG command for different file formats and adjusting the user interface accordingly. One of these days when I have more time I might experiment with this feature.

FFMPEG resources (quick Google search):
http://ubuntumanual.org/posts/327/converting-videos-in-ubuntu-using-ffmpeg-the-ultimate-free-video-converter
http://linuxaria.com/howto/tricks-ffmpeg?lang=en
http://www.roman10.net/my-ffmpeg-commands-list/

zemaitis
02-15-2012, 04:51 PM
I'm thinking about saving youtube flv videos with the name of unique id. If user would input the link, which's unique id matches to the file in server, the file would be converted and given for the user with the song name from youtube.

For example, user inputs http://www.youtube.com/watch?v=222kQyGGoWg

It takes the id 222kQyGGoWg and checks if there's a 222kQyGGoWg.flv file in the directory /videos/ ,

if there isn't, it downloads the file named 222kQyGGoWg.flv, then converts it to /mp3/ with named song_name.mp3 ,

or

if there is, it converts it to /mp3/ with named song_name.mp3

the minuses are that you would need to keep the flv files in your server, but you would save a lot of bandwidth because the service would need only to convert the existing video and to give users the mp3 file which size is small

chump2877
02-15-2012, 06:31 PM
I'm thinking about saving youtube flv videos with the name of unique id. If user would input the link, which's unique id matches to the file in server, the file would be converted and given for the user with the song name from youtube.

You (maybe, in the long run) save on the cost of bandwidth, but you also increase the cost of disk space required (in the short term).

And I'm guessing that the only way to see tangible savings employing this strategy is if you were to drastically scale up the number of people using your application. And even then, how often do you think 2 or more users will want to convert the same video on YouTube? There are probably millions of videos on there, so how long would you have to run your app, and how many people would need to use it, before you actually start reaping any savings in terms of bandwidth?

What about rationing usage of your app so that only so many downloads/conversions can be performed for a given duration, and/or by a given user, for free?

zemaitis
02-16-2012, 08:41 AM
I have this issue with script execution speed a bit.

http://69.194.196.150/index.php

If I press download video, the script gives loading image and after ~20 seconds I can see quickly download appearing. How I could make it that after submitting youtube link, the YouTube video download proccess should appear without that waiting, and user could see the downloading percent bar normally?

It happened when i moved my service to the foreign VPS and on WAMP instead of XAMPP

php info here http://69.194.196.150/test.php apache logs show nothing

Tried to edit init_max waiting time or something like that to 1-2sec it worked purfect, but after clicking get mp3 button the file downloading was paralyzed

chump2877
02-16-2012, 10:06 AM
You've clearly changed the original code, so my advice to you is to try to get my original code to work wherever it is that you need to install it. Once you get it to work, gradually add your own code to find out what is causing the issue...

If my original code doesn't work, then let me know, and I'll see what I can do....

zemaitis
02-16-2012, 10:19 AM
Started using your new script - working like a charm except 1 function that I was unable to do, it's automatic downloading file prompt after submitting to download the video. Tried to iframe the dynamic url of file, but unsuccesfully.

chump2877
02-16-2012, 12:21 PM
Started using your new script - working like a charm except 1 function that I was unable to do, it's automatic downloading file prompt after submitting to download the video. Tried to iframe the dynamic url of file, but unsuccesfully.

Your site seems to be working for me except for a delay between the download and the conversion. Can't think of a reason why that would be happening off hand. I don't experience that on my end.

zemaitis
02-16-2012, 12:30 PM
Yes, but how i could make download to pop up? Because people are too lazy to search and click the down link :) Tried via iframing the direct link or setting headers, didn't worked at all..

chump2877
02-16-2012, 07:45 PM
Yes, but how i could make download to pop up? Because people are too lazy to search and click the down link :) Tried via iframing the direct link or setting headers, didn't worked at all..

You could do the following:

1) Change this code in index.php:


$("#preview").css("display", "none");
var convertSuccessMsg = (retVals[2] == 1) ? '<p>Success!</p><p><a href="<?php echo $_SERVER['PHP_SELF']; ?>?mp3=' + encodeURI(songFile) + '">Download your MP3 file</a>.</p>' : '<p>Error generating MP3 file!</p>';
$("#conversionSuccess").html(convertSuccessMsg);
$("#conversionForm").css("display", "block");

...to something like (I have not tested this)...


if (retVals[2] == 1)
{
window.location.href += '?mp3=' + encodeURI(songFile);
}
else
{
$("#preview").css("display", "none");
$("#conversionSuccess").html('<p>Error generating MP3 file!</p>');
$("#conversionForm").css("display", "block");
}

2) Change this code in index.php:


window.onload = function()
{
if (!document.getElementById('preview'))
{
$("#conversionForm").css("display", "block");
}
};

...to something like (again, code is not tested)...


window.onload = function()
{
if (!document.getElementById('preview'))
{
$("#conversionForm").css("display", "block");
}
<?php if (isset($_GET['mp3'])) { ?>
$("h2:first").after('<div id="conversionSuccess"><p>Success!</p></div>');
<?php } ?>
};

zemaitis
02-16-2012, 09:27 PM
First worked, thank you :) Is it possible to leave the old one „download from here....“ and the new one pop up download together?

Solved: left the first one old code instead of removing, and added the first solution of the code

skyice
02-17-2012, 01:44 PM
On ubuntu 11.04 i receive this error: http://xencraft.net/logs/1329405250_4f3d1d4291ef48.65734555.txt

Can you help me?

zemaitis
02-17-2012, 02:03 PM
1. You are working on commercial vps or your home computer?
2. Give us the url of your functioning script
3. Show your php info (by URL would be better, cause php info would take a very big height image)
4. Check you apache logs about errors and show what you have.
5. What youtube script version files are you using?

chump2877
02-17-2012, 02:13 PM
On ubuntu 11.04 i receive this error: http://xencraft.net/logs/1329405250_4f3d1d4291ef48.65734555.txt

Can you help me?

My gut tells me that you are missing one (or both) of the following packages (and any associated/dependent packages):

1) libmp3lame0
2) libavcodec-extra-53

...those should give you the libmp3lame codec that you need for your FFMPEG command, found in YouTubeToMp3Converter::GenerateMP3():


$exec_string = parent::_FFMPEG.' -i '.$this->GetTempVidFileName().' -y -acodec libmp3lame -ab '.$quality.'k '.$this->GetSongFileName() . ' 2> logs/' . $this->_uniqueID . '.txt';

See this post (http://www.codingforums.com/showpost.php?p=1192147&postcount=153) for more info regarding packages required.

skyice
02-17-2012, 02:30 PM
Thank you but;
I say: apt-get install libmp3lame0 libavcodec-extra-53

I receive: Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package libavcodec-extra-53

Sorry for my thery bad english

chump2877
02-17-2012, 02:45 PM
Thank you but;
I say: apt-get install libmp3lame0 libavcodec-extra-53

I receive: Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package libavcodec-extra-53

Sorry for my thery bad english

Hmmm...try libavcodec-extra-52 (http://packages.ubuntu.com/lucid/libavcodec-extra-52)? You have a lower version of Ubuntu, so maybe libavcodec-extra-53 is incompatible with your system (http://ubuntuforums.org/showthread.php?t=1117283)? That is my best guess.

skyice
02-17-2012, 02:52 PM
I said: apt-get install sudo apt-get install libavcodec-extra-52
I receive:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package libavcodec-extra-52 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
ffmpeg:i386 ffmpeg

E: Package 'libavcodec-extra-52' has no installation candidate

chump2877
02-17-2012, 02:56 PM
sudo apt-get install ffmpeg libavcodec-extra-52

...per the forum post that I linked to...you may need to uninstall ffmpeg and reinstall with that command (which gets you ffmpeg and the codecs)? I don't know --I'm just guessing....

zemaitis
02-17-2012, 03:49 PM
I think that we could buy a commercial Ubuntu VPS for a month from http://solarvps.com/ for paypal $1 and try to install working script, then write a complete guide.

chump2877
02-17-2012, 04:26 PM
I think that we could buy a commercial Ubuntu VPS for a month from http://solarvps.com/ for paypal $1 and try to install working script, then write a complete guide.

Well, I could just install another copy of Ubuntu into another VM, and this time configure everything via the CLI...maybe I'll do that at some point in the future....I don't have the time for it right now....

But I agree, it would be ideal to have a list of commands for people...It would be easier to install into a commercial VPS as well as other flavors of Linux that way...Any volunteers? :D

cana888
02-18-2012, 07:21 AM
ffmpeg version git-2012-02-18-c9ac082 Copyright (c) 2000-2012 the FFmpeg developers
built on Feb 18 2012 07:23:10 with gcc 4.4.3
configuration: --enable-gpl --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab
libavutil 51. 39.100 / 51. 39.100
libavcodec 54. 3.100 / 54. 3.100
libavformat 54. 1.100 / 54. 1.100
libavdevice 53. 4.100 / 53. 4.100
libavfilter 2. 62.101 / 2. 62.101
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 6.100 / 0. 6.100
libpostproc 52. 0.100 / 52. 0.100
Input #0, matroska,webm, from 'videos/1329546532_4f3f452405b650.36877783.flv':
Duration: 00:07:45.23, start: 0.000000, bitrate: 194 kb/s
Stream #0:0: Video: vp8, yuv420p, 480x360, SAR 1:1 DAR 4:3, 30 fps, 59.94 tbr, 1k tbn, 1k tbc (default)
Stream #0:1: Audio: vorbis, 44100 Hz, stereo, s16 (default)
Output #0, mp3, to 'mp3/Autechre_-_Puch.mp3':
Metadata:
TSSE : Lavf54.1.100
Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16, 128 kb/s (default)
Stream mapping:
Stream #0:1 -> #0:0 (vorbis -> libmp3lame)
Press [q] to stop, [?] for help
size= 259kB time=00:00:16.56 bitrate= 128.2kbits/s
size= 523kB time=00:00:33.43 bitrate= 128.1kbits/s
size= 780kB time=00:00:49.89 bitrate= 128.1kbits/s
size= 1029kB time=00:01:05.82 bitrate= 128.1kbits/s
size= 1286kB time=00:01:22.28 bitrate= 128.0kbits/s
size= 1540kB time=00:01:38.53 bitrate= 128.0kbits/s
size= 1668kB time=00:01:46.71 bitrate= 128.0kbits/s
size= 1848kB time=00:01:58.25 bitrate= 128.0kbits/s
size= 1978kB time=00:02:06.53 bitrate= 128.0kbits/s
size= 2226kB time=00:02:22.44 bitrate= 128.0kbits/s
size= 2485kB time=00:02:39.00 bitrate= 128.0kbits/s
size= 2744kB time=00:02:55.56 bitrate= 128.0kbits/s
size= 2989kB time=00:03:11.29 bitrate= 128.0kbits/s
size= 3234kB time=00:03:26.94 bitrate= 128.0kbits/s
size= 3484kB time=00:03:42.92 bitrate= 128.0kbits/s
size= 3723kB time=00:03:58.26 bitrate= 128.0kbits/s
size= 3968kB time=00:04:13.91 bitrate= 128.0kbits/s
size= 4214kB time=00:04:29.63 bitrate= 128.0kbits/s
size= 4463kB time=00:04:45.59 bitrate= 128.0kbits/s
size= 4728kB time=00:05:02.55 bitrate= 128.0kbits/s
size= 4987kB time=00:05:19.13 bitrate= 128.0kbits/s
size= 5249kB time=00:05:35.90 bitrate= 128.0kbits/s
size= 5506kB time=00:05:52.36 bitrate= 128.0kbits/s
size= 5772kB time=00:06:09.37 bitrate= 128.0kbits/s
size= 6031kB time=00:06:25.93 bitrate= 128.0kbits/s
size= 6287kB time=00:06:42.36 bitrate= 128.0kbits/s
size= 6549kB time=00:06:59.13 bitrate= 128.0kbits/s
size= 6710kB time=00:07:09.42 bitrate= 128.0kbits/s
size= 6882kB time=00:07:20.42 bitrate= 128.0kbits/s
size= 7072kB time=00:07:32.59 bitrate= 128.0kbits/s
size= 7257kB time=00:07:44.43 bitrate= 128.0kbits/s
size= 7266kB time=00:07:45.00 bitrate= 128.0kbits/s
video:0kB audio:7266kB global headers:0kB muxing overhead 0.006062%


Everething looks ok, mp3 files are generated to mp3 folder bat download links not showing, nothing heppend.

Check link: http://uhuuu.com/u2/

I dont know what is problem...!!!

chump2877
02-18-2012, 11:52 AM
cana888, that is very strange and I can't reproduce the issue here.

Try the following:

1) Check that you have at least PHP v5.3

2) You are running this in Ubuntu 11.04 instead of 11.10 (as I am), so you might have an incompatible package installed. Or perhaps a package (or package dependency) is missing?

3) You seem to be experiencing some output buffering issues. Try replacing the following code (in all files except inside YouTubeToMp3Converter::UpdateVideoDownloadProgress()):


flush();

...with...


ob_end_flush();
ob_flush();
flush();

4) Try to debug different PHP variables inside of ffmpeg_progress.php. While your log file size increases, your percent progress never goes above zero.

For example, to debug $totalTime and $currentTime in ffmpeg_progress.php, change the last line of that file to read:


echo $newLogLength . "|" . $progress . "|" . $conversionSuccess . "|" . $error . "|" . $totalTime . "|" . $currentTime;

(Additional variables must appear at the end of the echo statement separated by pipe characters.)

Then check the AJAX response text in FireBug (in Firefox) to see what those variables are (and why their division always equals zero).

5) Comment out this line in index.php, like so:


// Execution settings
ini_set('max_execution_time',0);
//ini_set('display_errors',0);

To see what PHP errors (if any) that you are getting?

cana888
02-18-2012, 05:50 PM
cana888, that is very strange and I can't reproduce the issue here.

Try the following:

1) Check that you have at least PHP v5.3

2) You are running this in Ubuntu 11.04 instead of 11.10 (as I am), so you might have an incompatible package installed. Or perhaps a package (or package dependency) is missing?

3) You seem to be experiencing some output buffering issues. Try replacing the following code (in all files except inside YouTubeToMp3Converter::UpdateVideoDownloadProgress()):


flush();

...with...


ob_end_flush();
ob_flush();
flush();

4) Try to debug different PHP variables inside of ffmpeg_progress.php. While your log file size increases, your percent progress never goes above zero.

For example, to debug $totalTime and $currentTime in ffmpeg_progress.php, change the last line of that file to read:


echo $newLogLength . "|" . $progress . "|" . $conversionSuccess . "|" . $error . "|" . $totalTime . "|" . $currentTime;

(Additional variables must appear at the end of the echo statement separated by pipe characters.)

Then check the AJAX response text in FireBug (in Firefox) to see what those variables are (and why their division always equals zero).

5) Comment out this line in index.php, like so:


// Execution settings
ini_set('max_execution_time',0);
//ini_set('display_errors',0);

To see what PHP errors (if any) that you are getting?

I have least php: http://uhuuu.com/phpinfo.php
No I'm using: Ubuntu 10.04.4 LTS (11.04 was on my local host)
I have successfull installed ffmpeg from this tutorial: http://ubuntuforums.org/showpost.php?p=9868359&postcount=1289 without any error or missing package.

config.class.php

<?php

// Config Class
class Config
{
// Protected Fields
protected $_audioQualities = array(64, 128, 320);

// Constants
const _TEMPVIDDIR = 'videos/';
const _SONGFILEDIR = 'mp3/';
const _FFMPEG = '/usr/local/bin/ffmpeg';
const _LOGSDIR = 'logs/';
}

?>

ffmpeg_progress.php


<?php

include 'config.class.php';
$newLogLength = 0;
$progress = 0;
$conversionSuccess = 2;
$error = 2;

if (isset($_POST['uniqueId']) && isset($_POST['logLength']) && isset($_POST['mp3File']))
{
$uniqueId = $_POST['uniqueId'];
$logLength = $_POST['logLength'];
$mp3File = urldecode($_POST['mp3File']);
$logFile = realpath(Config::_LOGSDIR . $uniqueId .".txt");
if (is_file($logFile))
{
$count = 0;
while (filesize($logFile) == $logLength && $count < 500)
{
$count++;
clearstatcache();
time_nanosleep(0, 10000000);
}
$log = file_get_contents($logFile);
$file_size = filesize($logFile);
if (preg_match('/(Duration: )(\d\d):(\d\d):(\d\d\.\d\d)/i', $log, $matches) == 1)
{
$totalTime = ((int)$matches[2] * 60 * 60) + ((int)$matches[3] * 60) + (float)$matches[4];
$numTimes = preg_match_all('/(time=)(.+?)(\s)/i', $log, $times);
if ($numTimes > 0)
{
$currentTime = (float)end($times[2]);
$progress = round(($currentTime / $totalTime) * 100);
if ($progress < 100)
{
$newLogLength = $file_size;
}
else
{
unlink($logFile);
if (is_file(realpath(Config::_TEMPVIDDIR . $uniqueId .'.flv')))
{
unlink(realpath(Config::_TEMPVIDDIR . $uniqueId .'.flv'));
}
if (is_file(realpath(Config::_SONGFILEDIR . $mp3File)))
{
$conversionSuccess = 1;
}
}
}
else
{
$error = 1;
}

}
else
{
$error = 1;
}
}
else
{
$error = 1;
}
}
echo $newLogLength . "|" . $progress . "|" . $conversionSuccess . "|" . $error . "|" . $totalTime . "|" . $currentTime;

?>

YouTubeToMp3Converter.class


<?php

// Conversion Class
include 'config.class.php';
class YouTubeToMp3Converter extends Config
{
// Private Fields
private $_songFileName = '';
private $_flvUrl = '';
private $_tempVidFileName;
private $_uniqueID = '';
private $_vidSrcTypes = array('source_code', 'url');
private $_percentVidDownloaded = 0;

#region Public Methods
function __construct()
{
$this->_uniqueID = time() . "_" . uniqid('', true);
}

function DownloadVideo($youTubeUrl)
{
$file_contents = file_get_contents($youTubeUrl);
if ($file_contents !== false)
{
$this->SetSongFileName($file_contents);
$this->SetFlvUrl($file_contents);
if ($this->GetSongFileName() != '' && $this->GetFlvUrl() != '')
{
return $this->SaveVideo($this->GetFlvUrl());
}
}
return false;
}

function GenerateMP3($audioQuality)
{
$qualities = $this->GetAudioQualities();
$quality = (in_array($audioQuality, $qualities)) ? $audioQuality : $qualities[1];
$exec_string = parent::_FFMPEG.' -i '.$this->GetTempVidFileName().' -y -acodec libmp3lame -ab '.$quality.'k '.$this->GetSongFileName() . ' 2> logs/' . $this->_uniqueID . '.txt';
$ffmpegExecUrl = preg_replace('/(([^\/]+?)(\.php))$/', "exec_ffmpeg.php", "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']);
$postData = "cmd=".urlencode($exec_string);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $ffmpegExecUrl);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_TIMEOUT_MS, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
curl_exec($ch);
curl_close($ch);
}

function DownloadMP3($file)
{
$filepath = parent::_SONGFILEDIR . urldecode($file);
if (is_file($filepath))
{
header('Content-Type: audio/mpeg3');
header('Content-Length: ' . filesize($filepath));
header('Content-Disposition: attachment; filename="'.urldecode($file).'"');
ob_clean();
flush();
readfile($filepath);
die();
}
else
{
$redirect = explode("?", $_SERVER['REQUEST_URI']);
header('Location: ' . $redirect[0]);
}
}

function ExtractSongTrackName($vidSrc, $srcType)
{
$name = '';
$vidSrcTypes = $this->GetVidSrcTypes();
if (in_array($srcType, $vidSrcTypes))
{
$vidSrc = ($srcType == $vidSrcTypes[1]) ? file_get_contents($vidSrc) : $vidSrc;
if ($vidSrc !== false && eregi('eow-title',$vidSrc))
{
$name = end(explode('eow-title',$vidSrc));
$name = current(explode('">',$name));
$name = ereg_replace('[^-_a-zA-Z,"\' :0-9]',"",end(explode('title="',$name)));
}
}
return $name;
}

function ExtractVideoId($youTubeUrl)
{
$v = '';
$urlQueryStr = parse_url(trim($youTubeUrl), PHP_URL_QUERY);
if ($urlQueryStr !== false && !empty($urlQueryStr))
{
parse_str($urlQueryStr);
}
return $v;
}

function UpdateVideoDownloadProgress($downloadSize, $downloaded, $uploadSize, $uploaded)
{
$percent = round($downloaded/$downloadSize, 2) * 100;
if ($percent > $this->_percentVidDownloaded)
{
$this->_percentVidDownloaded++;
echo '<script type="text/javascript">updateVideoDownloadProgress("'. $percent .'");</script>';
ob_end_flush();
ob_flush();
flush();
}
}
#endregion

#region Private "Helper" Methods
private function SaveVideo($url)
{
$this->_percentVidDownloaded = 0;
$this->SetTempVidFileName();
$file = fopen($this->GetTempVidFileName(), 'w');
$ch = curl_init();
curl_setopt($ch, CURLOPT_FILE, $file);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_NOPROGRESS, false);
curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, array($this, 'UpdateVideoDownloadProgress'));
curl_setopt($ch, CURLOPT_BUFFERSIZE, 4096000);
curl_exec($ch);
curl_close($ch);
fclose($file);
return is_file($this->GetTempVidFileName());
}
#endregion

#region Properties
public function GetSongFileName()
{
return $this->_songFileName;
}
private function SetSongFileName($file_contents)
{
$vidSrcTypes = $this->GetVidSrcTypes();
$trackName = $this->ExtractSongTrackName($file_contents, $vidSrcTypes[0]);
$this->_songFileName = (!empty($trackName)) ? parent::_SONGFILEDIR . preg_replace('/_{2,}/','_',preg_replace('/ /','_',preg_replace('/[^A-Za-z0-9 _-]/','',$trackName))) . '.mp3' : '';
}

public function GetFlvUrl()
{
return $this->_flvUrl;
}
private function SetFlvUrl($file_contents)
{
$vidUrl = '';
if (eregi('"url_encoded_fmt_stream_map": "url=',$file_contents))
{
$vidUrl = end(explode('"url_encoded_fmt_stream_map": "url=',$file_contents));
$vidUrl = urldecode(urldecode(current(explode('\u0026',$vidUrl))));
}
//die($vidUrl);
$this->_flvUrl = $vidUrl;
}

public function GetAudioQualities()
{
return $this->_audioQualities;
}

private function GetTempVidFileName()
{
return $this->_tempVidFileName;
}
private function SetTempVidFileName()
{
$this->_tempVidFileName = parent::_TEMPVIDDIR . $this->_uniqueID .'.flv';
}

public function GetVidSrcTypes()
{
return $this->_vidSrcTypes;
}

public function GetUniqueID()
{
return $this->_uniqueID;
}
#endregion
}

?>

index.php


<?php
// Execution settings
ini_set('max_execution_time',0);
ini_set('display_errors',0);

// Instantiate converter class
include 'YouTubeToMp3Converter.class.php';
$converter = new YouTubeToMp3Converter();

// On download of MP3
if (isset($_GET['mp3']))
{
$converter->DownloadMP3($_GET['mp3']);
}
?>
<?php echo '<?xml version="1.1" encoding="iso-8859-1"?>'; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>YouTube-To-Mp3 Converter</title>
<style type="text/css">
body
{
text-align:center;
font:13px Verdana,Arial;
margin-top:50px;
}

p
{
margin:15px 0;
font-weight:bold;
}

form
{
width:450px;
margin:0 auto;
padding:15px;
border:1px solid #ccc;
}

form input[type="text"]
{
width:385px;
}

form p
{
margin:10px 0;
font-weight:normal;
}

#progress-bar
{
width:200px;
padding:2px;
border:2px solid #aaa;
background:#fff;
margin:0 auto;
}

#progress
{
background:#000;
color:#fff;
overflow:hidden;
white-space:nowrap;
padding:5px 0;
text-indent:5px;
width:0%;
}

#conversion-status
{
width:200px;
padding:2px;
margin:0 auto;
color:#999;
text-align:center;
}
</style>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
var conversionLogLength = 0;

function updateVideoDownloadProgress(percentage)
{
var progress = document.getElementById('progress');
progress.style.width = progress.innerHTML = parseInt(percentage) + '%';
}

function updateConversionProgress(songFile)
{
var progress = document.getElementById('progress');
document.getElementById('conversion-status').innerHTML = "Converting video. . .";
$.ajax({
type : "POST",
url : "ffmpeg_progress.php",
data : "uniqueId=<?php echo $converter->GetUniqueID(); ?>&logLength=" + conversionLogLength + "&mp3File=" + encodeURI(songFile),
success : function(retVal) {
var retVals = retVal.split('|');
if (retVals[3] == 2)
{
progress.style.width = progress.innerHTML = parseInt(retVals[1]) + '%';
if (parseInt(retVals[1]) < 100)
{
conversionLogLength = parseInt(retVals[0]);
setTimeout(function(){updateConversionProgress(songFile);}, 10);
}
else
{
$("#preview").css("display", "none");
var convertSuccessMsg = (retVals[2] == 1) ? '<p>Success!</p><p><a href="<?php echo $_SERVER['PHP_SELF']; ?>?mp3=' + encodeURI(songFile) + '">Download your MP3 file</a>.</p>' : '<p>Error generating MP3 file!</p>';
$("#conversionSuccess").html(convertSuccessMsg);
$("#conversionForm").css("display", "block");
}
}
else
{
setTimeout(function(){updateConversionProgress(songFile);}, 1);
}
}
});
}

window.onload = function()
{
if (!document.getElementById('preview'))
{
$("#conversionForm").css("display", "block");
}
};
</script>
</head>
<body>
<h2>YouTube-To-Mp3 Converter</h2>
<?php
// On form submission...
if ($_POST['submit'])
{
// Print "please wait" message and preview image
echo '<div id="preview" style="display:block"><p>...Please wait while I try to convert:</p>';
echo '<p><img src="http://img.youtube.com/vi/'.$converter->ExtractVideoId(trim($_POST['youtubeURL'])).'/1.jpg" alt="preview image" /></p>';
echo '<p>'.$converter->ExtractSongTrackName(trim($_POST['youtubeURL']), 'url').'</p>';
echo '<div id="progress-bar"><div id="progress">0%</div></div>';
echo '<div id="conversion-status">Downloading video. . .</div></div>';
flush();

// Main Program Execution
if ($converter->DownloadVideo(trim($_POST['youtubeURL'])))
{
echo '<div id="conversionSuccess"></div>';
echo '<script type="text/javascript">var progressBar = document.getElementById("progress"); progressBar.style.width = progressBar.innerHTML = "0%"; updateConversionProgress("'.trim(strstr($converter->GetSongFileName(), '/'), '/').'");</script>';
flush();
$converter->GenerateMP3($_POST['quality']);
}
else
{
echo '<p>Error downloading video!</p>';
}
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" id="conversionForm" style="display:none">
<p>Enter a valid YouTube.com video URL:</p>
<p><input type="text" name="youtubeURL" /></p>
<p><i>(i.e., "<span style="color:red">http://www.youtube.com/watch?v=HMpmI2F2cMs</span>")</i></p>
<p style="margin-top:20px">Choose the audio quality (better quality results in larger files):</p>
<p style="margin-bottom:25px"><input type="radio" value="64" name="quality" />Low &nbsp; <input type="radio" value="128" name="quality" checked="checked" />Medium &nbsp; <input type="radio" value="320" name="quality" />High</p>
<p><input type="submit" name="submit" value="Create MP3 File" /></p>
</form>
</body>
</html>

chump2877
02-18-2012, 07:06 PM
1) It seems ffmpeg-php is not successfully and/or correctly installed with PHP because there is no ffmpeg section in php.ini: http://3.bp.blogspot.com/-j4E4kFLqXI0/TZweWkrIWlI/AAAAAAAAARk/jU6Tkm9LiuM/s640/Capture.JPG.

2) Make sure that this is the correct location of FFMPEG:


const _FFMPEG = '/usr/local/bin/ffmpeg';

3) Did you do this??:



4) Try to debug different PHP variables inside of ffmpeg_progress.php. While your log file size increases, your percent progress never goes above zero.

For example, to debug $totalTime and $currentTime in ffmpeg_progress.php, change the last line of that file to read:

PHP Code:
echo $newLogLength . "|" . $progress . "|" . $conversionSuccess . "|" . $error . "|" . $totalTime . "|" . $currentTime;
(Additional variables must appear at the end of the echo statement separated by pipe characters.)

Then check the AJAX response text in FireBug (in Firefox) to see what those variables are (and why their division always equals zero).

If you don't know how to use Firebug Console tab, then it's time to learn how:

-- https://www.google.com/search?client=opera&rls=en&q=Firebug&sourceid=opera&ie=utf-8&oe=utf-8&channel=suggest#sclient=psy-ab&hl=en&safe=off&client=opera&tbo=1&rls=en&channel=suggest&tbs=qdr:y&source=hp&q=firebug+console+debug+ajax+tutorial&psj=1&oq=firebug+console+debug+ajax+tutorial&aq=f&aqi=&aql=&gs_sm=3&gs_upl=53866l56581l0l57372l14l14l3l0l0l4l428l1812l3.5.1.1.1l11l0&bav=on.2,or.r_gc.r_pw.,cf.osb&fp=42d46c25b1d7fd1&biw=1916&bih=915

-- http://stackoverflow.com/questions/5618668/how-to-debug-ajax-request

4) Did you do this?:



5) Comment out this line in index.php, like so:

PHP Code:
// Execution settings
ini_set('max_execution_time',0);
//ini_set('display_errors',0);
To see what PHP errors (if any) that you are getting?

5) Did you do this??:



3) You seem to be experiencing some output buffering issues. Try replacing the following code (in all files except inside YouTubeToMp3Converter::UpdateVideoDownloadProgress()):

PHP Code:
flush();
...with...

PHP Code:
ob_end_flush();
ob_flush();
flush();

It seems to me that you didn't try to do some of the things that I suggested. I can't help you if you don't follow my instructions. :eek:

bedo1975
02-22-2012, 02:35 PM
Nicely job, but I have some bugs.

in fact the script download and encode correctly the flv that I choose but, the progress bar downloading are okay, but the progress bar for converter don't appears. and I have debug this I have this error :

Warning: Division by zero in /home/online/public_html/Dev3/phptube2/YouTubeToMp3Converter.class.php on line 108

Warning: Division by zero in /home/online/public_html/Dev3/phptube2/YouTubeToMp3Converter.class.php on line 108

Warning: Division by zero in /home/online/public_html/Dev3/phptube2/YouTubeToMp3Converter.class.php on line 108

Warning: Division by zero in /home/online/public_html/Dev3/phptube2/YouTubeToMp3Converter.class.php on line 108

Warning: Division by zero in /home/online/public_html/Dev3/phptube2/YouTubeToMp3Converter.class.php on line 108

Warning: Division by zero in /home/online/public_html/Dev3/phptube2/YouTubeToMp3Converter.class.php on line 108

Warning: Division by zero in /home/online/public_html/Dev3/phptube2/YouTubeToMp3Converter.class.php on line 108

Warning: Division by zero in /home/online/public_html/Dev3/phptube2/YouTubeToMp3Converter.class.php on line 108

Warning: Division by zero in /home/online/public_html/Dev3/phptube2/YouTubeToMp3Converter.class.php on line 108

Warning: Division by zero in /home/online/public_html/Dev3/phptube2/YouTubeToMp3Converter.class.php on line 108

Warning: Division by zero in /home/online/public_html/Dev3/phptube2/YouTubeToMp3Converter.class.php on line 108

Warning: Division by zero in /home/online/public_html/Dev3/phptube2/YouTubeToMp3Converter.class.php on line 108


do you know where this bug provide ?

thanks

chump2877
02-22-2012, 03:01 PM
That warning message appears to be generated by this line in YouTubeToMp3Converter.class.php:


$percent = round($downloaded/$downloadSize, 2) * 100;

The easiest way to get rid of the warning is by either turning off error reporting (which you should be doing anyway for a production-grade application) or doing the following:


$percent = @round($downloaded/$downloadSize, 2) * 100;

But that PHP warning should not be causing your code to malfunction. And, in fact, that code has nothing to do with the "conversion" progress bar (instead, it helps build the "download" progress bar).

So you should focus your troubleshooting efforts elsewhere. Perhaps try some of the troubleshooting strategies that I've already outlined in this thread.

bedo1975
02-22-2012, 03:31 PM
yes I look with firebug, but i don't see any errors.

So in the youtube class if I keep this :

$exec_string = parent::_FFMPEG.' -i '.$this->GetTempVidFileName().' -y -acodec libmp3lame -ab '.$quality.'k '.$this->GetSongFileName() . ' 2> logs/' . $this->_uniqueID . '.txt';


the curl fonction don't work, so if I remplace with :

= 'ffmpeg -i '.$this->GetTempVidFileName().' -y -acodec libmp3lame -ab '.$quality.'k '.$this->GetSongFileName() . ' 2> logs/' . $this->_uniqueID . '.txt';

curl run correctly, but the progress conversion not show too with this modification

I've verify, in config and my contant _FFMPEG are correctly /usr/local/bin/ffmpeg

I search , I search but

chump2877
02-22-2012, 04:05 PM
If constant _FFMPEG equals '/usr/local/bin/ffmpeg', then your FFMPEG command should read:


$exec_string = '/usr/local/bin/ffmpeg -i '.$this->GetTempVidFileName().' -y -acodec libmp3lame -ab '.$quality.'k '.$this->GetSongFileName() . ' 2> logs/' . $this->_uniqueID . '.txt';

bedo1975
02-22-2012, 04:36 PM
okay chump, with firebug this is that I'm detected :

data : "uniqueId=1329924692_4f450a54152a66.99442542&logLength=" + conversionLogLength + "&mp3File=" + encodeURI(songFile),


as you see, the uniqueId is not empty but the rest converisonLogLength etc ... are empty ! is it normal ?

bedo1975
02-22-2012, 08:10 PM
sorry chump, but I just see this in firebug :

the AJAX requests in Firebug continue on indefinitely even after the page has stopped loading. Mark : jquery.min.js

chump2877
02-22-2012, 10:16 PM
sorry chump, but I just see this in firebug :

the AJAX requests in Firebug continue on indefinitely even after the page has stopped loading. Mark : jquery.min.js

What is the video you are trying to convert? I can try to convert it here and see if it works.

What kind of server setup do you have?

Can you at least temporarily put your code online, give me the URL, and let me have a look at the AJAX requests?

bedo1975
02-23-2012, 08:11 AM
hi chump, this is the url, the video that I can to convert is, the url of example.

http://onlinemyclip.com/Dev3/phptube2/

I use a linux server based on centos

ffmpeg-php are correctly enabled is the phpinfo

chump2877
02-23-2012, 09:08 AM
Your AJAX response text indicates that you are getting an error in ffmpeg_progress.php -- most likely your FFMPEG command is not generating a log file. Without a log file, no conversion progress bar can be generated, and the entire process will stall (as it's doing).

The log file is generated by the code in red:


$exec_string = parent::_FFMPEG.' -i '.$this->GetTempVidFileName().' -y -acodec libmp3lame -ab '.$quality.'k '.$this->GetSongFileName() . ' 2> logs/' . $this->_uniqueID . '.txt';

Few things to try:

1) Check that 'logs/' and 'mp3/' directories have write privileges

2) Check to make sure cURL is not "hanging up" on exec_ffmpeg.php before the full FFMPEG command can be executed. Try increasing the number of seconds in this line in YouTubeToMp3Converter::GenerateMP3():


curl_setopt($ch, CURLOPT_TIMEOUT, 1);

3) Check your 'logs/' directory. Are there text files in there?

4) Check your 'mp3/' directory. Are there mp3 files in there?

bedo1975
02-23-2012, 09:13 AM
Log file are correctly located in logs folder, mp3 file in mp3 folder, permissions on folder 777

curl_setopt($ch, CURLOPT_TIMEOUT, 1); tested

same things

no error on error_log from apache

don't undertand

chump2877
02-23-2012, 09:16 AM
Paste the contents of the log file that is generated.

bedo1975
02-23-2012, 09:17 AM
this is the log file chum



ffmpeg version N-38046-g278d6ab-syslint Copyright (c) 2000-2012 the FFmpeg developers
built on Feb 20 2012 18:29:26 with gcc 4.1.2 20080704 (Red Hat 4.1.2-51)
configuration: --prefix=/usr/local/cpffmpeg --enable-shared --enable-nonfree --enable-gpl --enable-pthreads --enable-libopencore-amrnb --enable-decoder=liba52 --enable-libopencore-amrwb --enable-libfaac --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --extra-cflags=-I/usr/local/cpffmpeg/include/ --extra-ldflags=-L/usr/local/cpffmpeg/lib --enable-version3 --extra-version=syslint
libavutil 51. 39.100 / 51. 39.100
libavcodec 54. 3.101 / 54. 3.101
libavformat 54. 1.100 / 54. 1.100
libavdevice 53. 4.100 / 53. 4.100
libavfilter 2. 62.101 / 2. 62.101
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 6.100 / 0. 6.100
libpostproc 52. 0.100 / 52. 0.100
Input #0, matroska,webm, from 'videos/1329984973_4f45f5cd7d95c6.82276514.flv':
Duration: 00:07:45.23, start: 0.000000, bitrate: 194 kb/s
Stream #0:0: Video: vp8, yuv420p, 480x360, SAR 1:1 DAR 4:3, 30 fps, 59.94 tbr, 1k tbn, 1k tbc (default)
Stream #0:1: Audio: vorbis, 44100 Hz, stereo, s16 (default)
Output #0, mp3, to 'mp3/Autechre_-_Puch.mp3':
Metadata:
TSSE : Lavf54.1.100
Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16, 128 kb/s (default)
Stream mapping:
Stream #0:1 -> #0:0 (vorbis -> libmp3lame)
Press [q] to stop, [?] for help
size= 325kB time=00:00:20.74 bitrate= 128.2kbits/s
size= 683kB time=00:00:43.70 bitrate= 128.1kbits/s
size= 1038kB time=00:01:06.42 bitrate= 128.1kbits/s
size= 1391kB time=00:01:28.97 bitrate= 128.0kbits/s
size= 1736kB time=00:01:51.09 bitrate= 128.0kbits/s
size= 2089kB time=00:02:13.69 bitrate= 128.0kbits/s
size= 2433kB time=00:02:35.68 bitrate= 128.0kbits/s
size= 2782kB time=00:02:58.05 bitrate= 128.0kbits/s
size= 3126kB time=00:03:20.04 bitrate= 128.0kbits/s
size= 3471kB time=00:03:42.14 bitrate= 128.0kbits/s
size= 3819kB time=00:04:04.37 bitrate= 128.0kbits/s
size= 4167kB time=00:04:26.63 bitrate= 128.0kbits/s
size= 4517kB time=00:04:49.07 bitrate= 128.0kbits/s
size= 4868kB time=00:05:11.51 bitrate= 128.0kbits/s
size= 5215kB time=00:05:33.71 bitrate= 128.0kbits/s
size= 5562kB time=00:05:55.97 bitrate= 128.0kbits/s
size= 5913kB time=00:06:18.38 bitrate= 128.0kbits/s
size= 6262kB time=00:06:40.71 bitrate= 128.0kbits/s
size= 6611kB time=00:07:03.05 bitrate= 128.0kbits/s
size= 6960kB time=00:07:25.38 bitrate= 128.0kbits/s
size= 7266kB time=00:07:45.00 bitrate= 128.0kbits/s

video:0kB audio:7266kB global headers:0kB muxing overhead 0.006062%

chump2877
02-23-2012, 09:35 AM
I don't see any problems in the log file.

Try to debug different PHP variables inside of ffmpeg_progress.php (that are causing $error == 1).

For example, to debug $logFile in ffmpeg_progress.php, change the last line of that file to read:


echo $newLogLength . "|" . $progress . "|" . $conversionSuccess . "|" . $error . "|" . $logFile;

(Additional variables must appear at the end of the echo statement separated by pipe characters.)

Then check the AJAX response text in FireBug (in Firefox) to see what those variables are. Post the values of those variables here.

bedo1975
02-23-2012, 09:49 AM
chump, I've modified the file, and add your command line to see variables error, but nothing appears on the web page, in firebug I've this :

Paramètresapplication/x-www-form-urlencoded
logLength 5002851
mp3File Autechre_-_Puch.mp3
uniqueId 1329986805_4f45fcf5d35210.45294660
Source
uniqueId=1329986805_4f45fcf5d35210.45294660&logLength=5002851&mp3File=Autechre_-_Puch.mp3

I think it's correct no ?

bedo1975
02-23-2012, 09:50 AM
Paramètresapplication/x-www-form-urlencoded
logLength 5002851
mp3File Autechre_-_Puch.mp3
uniqueId 1329986805_4f45fcf5d35210.45294660
Source
uniqueId=1329986805_4f45fcf5d35210.45294660&logLength=5002851&mp3File=Autechre_-_Puch.mp3


is uniqueId = xxxxx must be :



Paramètresapplication/x-www-form-urlencoded
logLength 5002851
mp3File Autechre_-_Puch.mp3
uniqueId 1329986805_4f45fcf5d35210.45294660
Source
uniqueId=1329986805_4f45fcf5d35210.45294660.txt&logLength=5002851&mp3File=mp3/Autechre_-_Puch.mp3


?

bedo1975
02-23-2012, 09:53 AM
I've this in post ffmeg_progress in firebug :

2851|0|2|2|465.23|02851|0|2|2|/home/online/public_html/Dev3/phptube2/logs/1329987125_4f45fe351c6e65.65354386.txt

bedo1975
02-23-2012, 09:59 AM
It is a free script just using Curl and PHP. It gives three options MP4, 3gp and flv. I want to try and get it to work with mp3, and was wondering if someone can take a look. I think just a little change similar to what you have done before with 3gp conversion could achieve this. I tried myself but I am just learning.http://www.businessvideoproduction.info/huang3.jpg
http://www.businessvideoproduction.info/huang2.jpg
http://www.businessvideoproduction.info/huang4.jpg

you can change the ffmpeg command line in :


$exec_string = 'ffmpeg -i '.$this->GetTempVidFileName().' -y -acodec libmp3lame -ab '.$quality.'k '.$this->GetSongFileName() . ' 2> logs/' . $this->_uniqueID . '.txt';

chump2877
02-23-2012, 09:59 AM
2851|0|2|2|465.23|02851|0|2|2|/home/online/public_html/Dev3/phptube2/logs/1329987125_4f45fe351c6e65.65354386.txt

I don't know exactly which variables you are outputting there...time for bed for me....I'll take another look tomorrow

bedo1975
02-23-2012, 11:07 AM
okay, I've reuploaded a fresh script without any modification, and I think that I have throught the error :



200 OK
148ms
jquery.min.js (ligne 4)
POST http://onlinemyclip.com/Dev3/phptube2/ffmpeg_progress.php

200 OK
71ms
jquery.min.js (ligne 4)
En-têtesPostRéponseHTML
Paramètresapplication/x-www-form-urlencoded
logLength 0
mp3File Autechre_-_Puch.mp3
uniqueId 1329990808_4f460c98d5f726.97547783
Source
uniqueId=1329990808_4f460c98d5f726.97547783&logLength=0&mp3File=Autechre_-_Puch.mp3


you can see with the fresh script, the variable logLength in the post ffmpeg_progress is empty egals to " 0 " so I think it's the error

Wait for you see !

bedo1975
02-23-2012, 11:55 AM
Again me



2792|0|2|2



I looked at this, the first number is le length of log file => ok

but the second number is normaly the % progresse

so in firebug he was always at 0 and jquery process are loop infinity

chump2877
02-23-2012, 02:27 PM
Ok, $progress is determined in ffmpeg_progress.php as follows:


$progress = round(($currentTime / $totalTime) * 100);

So adjust your echo line in the same file as follows:


echo $newLogLength . "|" . $progress . "|" . $conversionSuccess . "|" . $error . "|" . $currentTime . "|" . $totalTime;

Run the script and check the various AJAX responses in FireBug to see what those variables are evaluating as. That could give you a hint as to what the problem is.

bedo1975
02-23-2012, 04:06 PM
okay it's do :

result :


$newLogLength . "|" . $progress . "|" . $conversionSuccess . "|" . $error . "|" .
2428 | 0 | 2 | 2 |

$currentTime . "|" . $totalTime;
0 | 465.23

I see the $currentTime variable are always eguals to ' 0 ' it's the coz i think

bedo1975
02-23-2012, 04:32 PM
$currentTime = (float)end($times[1]);

this is my problem with the float instruction

chump2877
02-23-2012, 04:47 PM
that line should read: $currentTime = (float)end($times[2]);

bedo1975
02-23-2012, 04:49 PM
sur but my result with this line is "0" i was try this :

$currentTime = $numTimes;

I know it's the incorrect value, but with this I see the progress conversion bar works .

I don't know why $currentTime = (float)end($times[2]); always return '0'

chump2877
02-23-2012, 04:56 PM
I don't know why $currentTime = (float)end($times[2]); always return '0'

I don't know why either because that is the correct code ;)

cana888
02-23-2012, 10:56 PM
my apache error logs, how to fix that?


PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/apache2/conf.d/mcrypt.ini on line 1 in Unknown on line 0
[Thu Feb 23 13:54:23 2012] [notice] Apache/2.2.14 (Ubuntu) PHP/5.3.2-1ubuntu4.14 with Suhosin-Patch configured -- resuming normal operations
[Thu Feb 23 13:54:32 2012] [error] [client 192.168.217.1] PHP Warning: Division by zero in /home/www/YouTubeToMp3Converter.class.php on line 103, referer: http://192.$
[Thu Feb 23 13:54:32 2012] [error] [client 192.168.217.1] PHP Notice: ob_flush(): failed to flush buffer. No buffer to flush. in /home/www/YouTubeToMp3Converter.class$
[Thu Feb 23 13:54:32 2012] [error] [client 192.168.217.1] PHP Notice: ob_end_flush(): failed to delete and flush buffer. No buffer to delete or flush. in /home/www/Yo$
[Thu Feb 23 13:54:32 2012] [error] [client 192.168.217.1] PHP Notice: ob_flush(): failed to flush buffer. No buffer to flush. in /home/www/YouTubeToMp3Converter.class$
[Thu Feb 23 13:54:32 2012] [error] [client 192.168.217.1] PHP Notice: ob_end_flush(): failed to delete and flush buffer. No buffer to delete or flush. in /home/www/Yo$
[Thu Feb 23 13:54:32 2012] [error] [client 192.168.217.1] PHP Notice: ob_flush(): failed to flush buffer. No buffer to flush. in /home/www/YouTubeToMp3Converter.class$
[Thu Feb 23 13:54:32 2012] [error] [client 192.168.217.1] PHP Notice: ob_end_flush(): failed to delete and flush buffer. No buffer to delete or flush. in /home/www/Yo$
[Thu Feb 23 13:54:32 2012] [error] [client 192.168.217.1] PHP Notice: ob_flush(): failed to flush buffer. No buffer to flush. in /home/www/YouTubeToMp3Converter.class$
[Thu Feb 23 13:54:32 2012] [error] [client 192.168.217.1] PHP Notice: ob_end_flush(): failed to delete and flush buffer. No buffer to delete or flush. in /home/www/Yo$
[Thu Feb 23 13:54:32 2012] [error] [client 192.168.217.1] PHP Notice: ob_flush(): failed to flush buffer. No buffer to flush. in /home/www/YouTubeToMp3Converter.class$
[Thu Feb 23 13:54:32 2012] [error] [client 192.168.217.1] PHP Notice: ob_end_flush(): failed to delete and flush buffer. No buffer to delete or flush. in /home/www/Yo$
[Thu Feb 23 13:54:32 2012] [error] [client 192.168.217.1] PHP Notice: ob_flush(): failed to flush buffer. No buffer to flush. in /home/www/YouTubeToMp3Converter.class$
[Thu Feb 23 13:54:32 2012] [error] [client 192.168.217.1] PHP Notice: ob_end_flush(): failed to delete and flush buffer. No buffer to delete or flush. in /home/www/Yo$
[Thu Feb 23 13:54:32 2012] [error] [client 192.168.217.1] PHP Notice: ob_flush(): failed to flush buffer. No buffer to flush. in /home/www/YouTubeToMp3Converter.class$
[Thu Feb 23 13:54:32 2012] [error] [client 192.168.217.1] PHP Notice: ob_end_flush(): failed to delete and flush buffer. No buffer to delete or flush. in /home/www/Yo$
[Thu Feb 23 13:54:32 2012] [error] [client 192.168.217.1] PHP Notice: ob_flush(): failed to flush buffer. No buffer to flush. in /home/www/YouTubeToMp3Converter.class$
[Thu Feb 23 13:54:33 2012] [error] [client 192.168.217.1] PHP Notice: ob_end_flush(): failed to delete and flush buffer. No buffer to delete or flush. in /home/www/Yo$
[Thu Feb 23 13:54:33 2012] [error] [client 192.168.217.1] PHP Notice: ob_flush(): failed to flush buffer. No buffer to flush. in /home/www/YouTubeToMp3Converter.class$
[Thu Feb 23 13:54:33 2012] [error] [client 192.168.217.1] PHP Notice: ob_end_flush(): failed to delete and flush buffer. No buffer to delete or flush. in /home/www/Yo$
[Thu Feb 23 13:54:33 2012] [error] [client 192.168.217.1] PHP Notice: ob_flush(): failed to flush buffer. No buffer to flush. in /home/www/YouTubeToMp3Converter.class$
[Thu Feb 23 13:54:33 2012] [error] [client 192.168.217.1] PHP Notice: ob_end_flush(): failed to delete and flush buffer. No buffer to delete or flush. in /home/www/Yo$
[Thu Feb 23 13:54:33 2012] [error] [client 192.168.217.1] PHP Notice: ob_flush(): failed to flush buffer. No buffer to flush. in /home/www/YouTubeToMp3Converter.class$

chump2877
02-23-2012, 11:26 PM
Turn off error reporting...none of those things are worth troubleshooting or will cause the code to fail....

Error reporting is already turned off by default in index.php:


ini_set('display_errors',0);

umang.goyal
02-24-2012, 02:12 PM
Hi,
i have been trying to run this script on my laptop with xampp for windows.
i have done everything(latest ffmpeg.exe, latest php script of your app) and have setup it as said in instructions but still i am not getting it work for me..when ever i try to convert a youtube video it stuck on the page where is shows downloading video, it never progress. i have even checked in the video folder video size is always zero kb and process freezes there only. No error is shown neither any log. Please can you help me sort out the problem.

Thanks & Regards,
Umang Goyal

bedo1975
02-24-2012, 02:18 PM
what is your youtube url umang.goyal ?

umang.goyal
02-24-2012, 02:40 PM
here is the URL of the video i am trying to download.


http://www.youtube.com/watch?v=ipNB-ijxHiI&feature=g-vrec&context=G29d7a2aRVAAAAAAAACA

bedo1975
02-24-2012, 02:42 PM
I have test with this url :

http://www.youtube.com/watch?v=ipNB-ijxHiI&

it's works !

umang.goyal
02-24-2012, 02:51 PM
let me try again. thanks for the reply :)

can you tell me if i need to set some permissions for the directories? or you could send me the source files you are using...i would really appreciate that.
Thansk & regards,
Umang Goyal

bedo1975
02-24-2012, 03:00 PM
I've set permission on mp3,videos,logs folder to 0777

in this time I can't send you my file coz I debug it, I've a few problem with the conversion progress bar !

umang.goyal
02-24-2012, 03:04 PM
i did the same. used filezilla and set the permissions to 0777 for all those directories. Still no progress :(
btw, i just had a thought if there would be a problem with permissions then it would have never created flv files within that video folder with size 0kb.

anyways thanks for the help. :)

Thanks & Regards,
Umang Goyal

bedo1975
02-24-2012, 03:06 PM
are you sure that ffmpeg are correctly installed ? ffmpeg-php too ?

Have you look at the config file, if the path of folder, and ffmpeg are correct ?

umang.goyal
02-24-2012, 03:09 PM
ffmpeg-php? i guess no for that.
i have downloaded the ffmpeg-64.exe from the suggested URL and have copied it into the folder where all the script files for the youtubetomp3 converter are saved. let me see about the ffmpeg-php.

bedo1975
02-24-2012, 03:11 PM
perhaps is your config.class :

// Constants
const _TEMPVIDDIR = 'videos/';
const _SONGFILEDIR = 'mp3/';
const _FFMPEG = 'ffmpeg-64.exe';
const _LOGSDIR = 'logs/';

be sure you have the correctly path value

umang.goyal
02-24-2012, 03:13 PM
its all correct in the config.class file, what i meant with ffmpeg-64.exe is that i am using 64bit version :P

can you shed some light on ffmpeg-php please...

chump2877
02-24-2012, 04:50 PM
Hi,
i have been trying to run this script on my laptop with xampp for windows.
i have done everything(latest ffmpeg.exe, latest php script of your app) and have setup it as said in instructions but still i am not getting it work for me..when ever i try to convert a youtube video it stuck on the page where is shows downloading video, it never progress. i have even checked in the video folder video size is always zero kb and process freezes there only. No error is shown neither any log. Please can you help me sort out the problem.

Thanks & Regards,
Umang Goyal

Sounds like a cURL problem...make sure cURL is enabled in php.ini...check to make sure cURL is listed in your phpinfo()

chump2877
02-24-2012, 04:51 PM
its all correct in the config.class file, what i meant with ffmpeg-64.exe is that i am using 64bit version :P

can you shed some light on ffmpeg-php please...

You don't need ffmpeg-php if you are running XAMPP for Windows. Only ffmpeg.exe is required.

I'm still using the 32-bit version of ffmpeg.exe on my Windows 7 Pro 64-bit OS and it works fine.

umang.goyal
02-24-2012, 08:23 PM
Sounds like a cURL problem...make sure cURL is enabled in php.ini...check to make sure cURL is listed in your phpinfo()

hi, thanks for pointing that out. i just enabled the cURL and it worked like charm. the only thing is that the progress bar doesn't show progress while converting the video into mp3.
and thanks for the script i loved it :D

chump2877
02-24-2012, 08:57 PM
the only thing is that the progress bar doesn't show progress while converting the video into mp3.

I've posted all kinds of ways to troubleshoot this issue in this thread, so please try some of those things...if you still can't get it to work, come back here, update me with what you were able to find out, and I'll see if I can help you further...

bedo1975
02-24-2012, 09:59 PM
hi, thanks for pointing that out. i just enabled the cURL and it worked like charm. the only thing is that the progress bar doesn't show progress while converting the video into mp3.
and thanks for the script i loved it :D

I've the same problem, no progress bar on conversion problem ... I search why !

cana888
02-25-2012, 12:18 AM
Can anybaddy check this url if you can download that: http://www.youtube.com/watch?v=XeqcEhrOM7s

I become "Error downloading video!"

umang.goyal
02-25-2012, 09:04 AM
Well i am thinking of putting it up on a linux server. can we do that? i will need to do the needful changes in php.ini like extensions and maybe some other changes...can someone help me with this??

Thanks & Regards,
Umang Goyal

chump2877
02-25-2012, 10:04 AM
Can anybaddy check this url if you can download that: http://www.youtube.com/watch?v=XeqcEhrOM7s

I become "Error downloading video!"

I can confirm that I had the same problem for that video. Other videos download/convert fine though, so this appears to be an isolated incident -- an anomaly. However, if you find that the code is "choking" on other videos as well, please let know. In that case, I may have to modify the code accordingly. Keep me posted.

chump2877
02-25-2012, 10:11 AM
Well i am thinking of putting it up on a linux server. can we do that? i will need to do the needful changes in php.ini like extensions and maybe some other changes...can someone help me with this??

Thanks & Regards,
Umang Goyal

The code will work on Linux. See this post: http://www.codingforums.com/showpost.php?p=1192147&postcount=153. If you need help with this, let me know and I'll do my best.