Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 14 of 79 FirstFirst ... 412131415162464 ... LastLast
Results 196 to 210 of 1174
Like Tree5Likes

Thread: YouTube-to-MP3 conversion - PHP class and script

  1. #196
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,778
    Thanks
    19
    Thanked 155 Times in 146 Posts
    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....
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  2. #197
    New Coder
    Join Date
    Feb 2012
    Posts
    26
    Thanks
    9
    Thanked 0 Times in 0 Posts
    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.

  3. #198
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,778
    Thanks
    19
    Thanked 155 Times in 146 Posts
    Quote Originally Posted by zemaitis View Post
    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?
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  4. #199
    New Coder
    Join Date
    Feb 2012
    Posts
    15
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Code:
    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...!!!

  5. #200
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,778
    Thanks
    19
    Thanked 155 Times in 146 Posts
    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()):

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

    PHP Code:
    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:

    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).

    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?
    Last edited by chump2877; 02-18-2012 at 11:01 AM.
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  6. #201
    New Coder
    Join Date
    Feb 2012
    Posts
    15
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by chump2877 View Post
    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()):

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

    PHP Code:
    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:

    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).

    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?
    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...postcount=1289 without any error or missing package.

    config.class.php
    Code:
    <?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

    Code:
    <?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

    Code:
    <?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

    Code:
    <?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>

  7. #202
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,778
    Thanks
    19
    Thanked 155 Times in 146 Posts
    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/-j4E4kFLqXI...40/Capture.JPG.

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

    PHP Code:
    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...w=1916&bih=915

    -- http://stackoverflow.com/questions/5...g-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.
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  8. #203
    New Coder
    Join Date
    Feb 2012
    Posts
    29
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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

  9. #204
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,778
    Thanks
    19
    Thanked 155 Times in 146 Posts
    That warning message appears to be generated by this line in YouTubeToMp3Converter.class.php:

    PHP Code:
    $percent round($downloaded/$downloadSize2) * 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:

    PHP Code:
    $percent = @round($downloaded/$downloadSize2) * 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.
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  10. #205
    New Coder
    Join Date
    Feb 2012
    Posts
    29
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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

  11. #206
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,778
    Thanks
    19
    Thanked 155 Times in 146 Posts
    If constant _FFMPEG equals '/usr/local/bin/ffmpeg', then your FFMPEG command should read:

    PHP Code:
    $exec_string '/usr/local/bin/ffmpeg -i '.$this->GetTempVidFileName().' -y -acodec libmp3lame -ab '.$quality.'k '.$this->GetSongFileName() . ' 2> logs/' $this->_uniqueID '.txt'
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  12. #207
    New Coder
    Join Date
    Feb 2012
    Posts
    29
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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 ?

  13. #208
    New Coder
    Join Date
    Feb 2012
    Posts
    29
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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

  14. #209
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,778
    Thanks
    19
    Thanked 155 Times in 146 Posts
    Quote Originally Posted by bedo1975 View Post
    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?
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  15. #210
    New Coder
    Join Date
    Feb 2012
    Posts
    29
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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


 
Page 14 of 79 FirstFirst ... 412131415162464 ... LastLast

LinkBacks (?)

  1. 07-21-2014, 05:32 PM
  2. 07-12-2014, 05:59 PM
  3. 06-26-2014, 03:39 PM
  4. 05-31-2014, 09:13 PM
  5. 04-24-2014, 07:53 PM
  6. 04-19-2014, 10:22 AM
  7. 04-04-2014, 08:33 PM
  8. 04-04-2014, 01:58 AM
  9. 03-28-2014, 06:03 AM
  10. 03-20-2014, 06:11 PM
  11. 03-16-2014, 01:22 AM
  12. 03-08-2014, 04:56 PM
  13. 03-07-2014, 06:21 PM
  14. 03-01-2014, 12:48 PM
  15. 02-22-2014, 08:40 PM
  16. 02-22-2014, 12:02 AM
  17. 02-21-2014, 08:15 PM
  18. 02-21-2014, 12:00 AM
  19. 02-20-2014, 08:37 PM
  20. 02-20-2014, 06:53 PM
  21. 02-20-2014, 03:21 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •