Go Back   CodingForums.com > :: Server side development > PHP > Post a PHP snippet

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rating: Thread Rating: 7 votes, 5.00 average.
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-21-2012, 10:13 PM   PM User | #361
spanero
New to the CF scene

 
Join Date: Jun 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
spanero is an unknown quantity at this point
Hi globusut89, you use a host or vps, and its in pacifichost.com or other?
Thank
spanero is offline   Reply With Quote
Old 06-21-2012, 10:40 PM   PM User | #362
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,549
Thanks: 15
Thanked 131 Times in 124 Posts
chump2877 is on a distinguished road
Quote:
Originally Posted by globusut89 View Post
My converter converts only video to mp3,
other formats will not work here its>>www.pepzol.com
Please check and write what is wrong, thanks
I briefly checked your installation, and appears that only YouTube videos are not converting to video formats? I was able to convert Dailymotion to a video format.

1) The first thing you should do is paste your FFmpeg log file here for the failed conversion. Comment out this line:

PHP Code:
unlink($logFile); 
...so that the app does not automatically delete the log file.

2) Open up your site on Firefox and launch Firebug. Switch to the Console tab in Firebug and try to convert a file on your site. After the conversion screen appears, check the Console tab for the AJAX requests being made to ffmpeg_progress.php (the file that makes the conversion progress bar “go”). Each AJAX request is delineated by a plus sign that, when expanded, reveals the AJAX response text for that request.

Your site, when converting a YouTube video to a video format, is asynchronously accessing ffmpeg_progress.php over and over again, to infinity, and returning the same AJAX response text each time: 0 | 0 | 2 | 1. Those numbers correspond to variables defined in ffmpeg_progress.php (log length, percent progress, conversion success, and error, respectively), and they indicate that something is wrong with the conversion.

Open up ffmpeg_progress.php in your favorite script editor. The 1 in the sequence of numbers indicates there is an error. This error corresponds with 1 of 3 failed conditions in ffmpeg_progress.php:

PHP Code:
if (is_file($logFile))   // Does the new/current log file exist? 
if (preg_match('/(Duration: )(\d\d):(\d\d):(\d\d\.\d\d)/i'$log$matches) == 1)   // Was the code able to parse the log file and find the total duration of the video to be converted? 
if ($numTimes 0)   // Was the code able to parse the log file and find the amount of video (time) converted thus far? 
Troubleshoot these conditions by placing additional variables at the end of this line (they must go at the end of the line):

PHP Code:
echo $newLogLength "|" $progress "|" $conversionSuccess "|" $error
For example, to troubleshoot the $logFile variable, you could do the following:

PHP Code:
echo $newLogLength "|" $progress "|" $conversionSuccess "|" $error "|" $logFile
After editing your ffmpeg_progress.php file, return to Firefox and try to convert a file again. Check the Firebug Console tab for the various AJAX responses to see what the $logFile variable (for example) evaluates to. So, you see, in this way, you can debug ffmpeg_progress.php as it is executed by consecutive AJAX requests.

In this way (described above), figure out and isolate what code is failing. Once we know what code is failing, then we can troubleshoot why it is failing.
__________________
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]

Last edited by chump2877; 06-21-2012 at 10:45 PM..
chump2877 is offline   Reply With Quote
Old 06-22-2012, 08:58 AM   PM User | #363
globusut89
New to the CF scene

 
Join Date: Jun 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
globusut89 is an unknown quantity at this point
Yes its right, dailymotion video convert properly.
here it's
http://pastebin.com/b53bnp1K

Last edited by globusut89; 06-22-2012 at 09:05 AM..
globusut89 is offline   Reply With Quote
Old 06-22-2012, 04:48 PM   PM User | #364
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,549
Thanks: 15
Thanked 131 Times in 124 Posts
chump2877 is on a distinguished road
Quote:
Originally Posted by globusut89 View Post
Yes its right, dailymotion video convert properly.
here it's
http://pastebin.com/b53bnp1K
Here's what you can try, in the order that I would try them:

1) I don't think you have the latest stable release of FFmpeg. The top of your log file says:

Code:
FFmpeg version 0.6.5, Copyright (c) 2000-2010 the FFmpeg developers
I'm pretty sure the latest stable release of FFmpeg is at least into version 0.7.x, and the copyright reads 2000-2011? Try updating your FFmpeg to the latest stable release, and see if that fixes your problems.

2) This line in the log file:

Code:
swScaler: Unknown format is not supported as input pixel format
...implies that the video track/stream of the video is encoded using a codec that FFmpeg doesn't recognize. And, in fact, the input video track/stream:

Code:
Stream #0.0(eng): Video: 0x0000, 1920x1080, PAR 1:1 DAR 16:9, 1k fps, 29.97 tbr, 1k tbn, 1k tbc
...doesn't even list a codec (that I can see). Kind of strange, since I assume YouTube generally re-encodes all videos that are uploaded to the site using some FFmpeg-compatible codec?

Does this happen for all YouTube videos, or do some YouTube videos convert OK (to video formats)?

3) The problem _might_ have something to do with this line in the log as well:

Code:
Seems stream 0 codec frame rate differs from container frame rate: 1000.00 (1000/1) -> 29.97 (30000/1001)
Perhaps FFmpeg is looking at the video container instead of the video track/stream (with regard to a video codec), and that's why FFmpeg can't find a video codec?


Sorry I can't give you a more cut-and-dry solution to your problem here. The truth is, I'm not really sure what the problem is just by looking at the log file. Try updating FFmpeg first, and then we can analyze subsequent log files if the problem persists.
__________________
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]
chump2877 is offline   Reply With Quote
Old 06-22-2012, 06:56 PM   PM User | #365
bbrog
New Coder

 
Join Date: Jun 2012
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
bbrog is an unknown quantity at this point
Hi, can you let me know which link I should download for ffmpeg

http://ffmpeg.org/download.html

the yum update stuff does not work with my server so I will have to manually get the link.

Thanks!
bbrog is offline   Reply With Quote
Old 06-22-2012, 07:53 PM   PM User | #366
globusut89
New to the CF scene

 
Join Date: Jun 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
globusut89 is an unknown quantity at this point
I can not do update ffmpeg, because I have shared hosting.
I contacted the help of pacifichost, they wrote that i should ordered a vps, since the shared hosting may have problem in with convert.
May u have script, which convert but to only mp3 format ?
anyway thanks for your help.
globusut89 is offline   Reply With Quote
Old 06-22-2012, 09:25 PM   PM User | #367
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,549
Thanks: 15
Thanked 131 Times in 124 Posts
chump2877 is on a distinguished road
Quote:
Originally Posted by globusut89 View Post
May u have script, which convert but to only mp3 format ?
You could strip away functionality from the code so that it only converts to mp3...
__________________
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]
chump2877 is offline   Reply With Quote
Old 06-22-2012, 10:03 PM   PM User | #368
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,549
Thanks: 15
Thanked 131 Times in 124 Posts
chump2877 is on a distinguished road
Quote:
Originally Posted by bbrog View Post
Hi, can you let me know which link I should download for ffmpeg

http://ffmpeg.org/download.html

the yum update stuff does not work with my server so I will have to manually get the link.

Thanks!
I see that in one of my virtual machines, I have installed:

Code:
ffmpeg version 0.7.3-4:0.7.3-0ubuntu0.11.10.1, Copyright (c) 2000-2011 the Libav developers
I found a reference to that here: http://git.libav.org/?p=libav.git;a=...767f8fd5369859

Link to files distribution appears to be this: http://git.libav.org/?p=libav.git;a=...5369859;sf=tgz
__________________
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]
chump2877 is offline   Reply With Quote
Old 06-23-2012, 08:05 AM   PM User | #369
bbrog
New Coder

 
Join Date: Jun 2012
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
bbrog is an unknown quantity at this point
Hi, I'm running into the following problem now do you know what this can be about

php: symbol lookup error:
/usr/local/lib/php/extensions/no-debug-non-zts-20060613/ffmpeg.so: undefined
symbol: avcodec_init
bbrog is offline   Reply With Quote
Old 06-23-2012, 06:29 PM   PM User | #370
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,549
Thanks: 15
Thanked 131 Times in 124 Posts
chump2877 is on a distinguished road
Quote:
Originally Posted by bbrog View Post
Hi, I'm running into the following problem now do you know what this can be about

php: symbol lookup error:
/usr/local/lib/php/extensions/no-debug-non-zts-20060613/ffmpeg.so: undefined
symbol: avcodec_init
Looks like some kind of installation/compilation error.

1) Did you completely remove the existing version of ffmpeg before installing a new version? Did you install multiple versions of some other software on the server?

2) Have you added the following line to your php.ini:

Code:
extension=ffmpeg.so
3) Does the file /usr/local/lib/php/extensions/no-debug-non-zts-20060613/ffmpeg.so exist? If so, paste the contents of the file.

Also, I failed to ask why this is the case:

Quote:
the yum update stuff does not work with my server
...so why do you have to build ffmpeg from source?
__________________
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]
chump2877 is offline   Reply With Quote
Old 06-24-2012, 06:47 PM   PM User | #371
globusut89
New to the CF scene

 
Join Date: Jun 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
globusut89 is an unknown quantity at this point
When trying to convert YouTube to MP3 I do not see first step
when video is download 1..50..100%%.
I just see second step when video is convert 1...40...100%
Why can not I see the first step ?

and i got error log:
Code:
PHP Warning:  Division by zero in /home/pepzolco/public_html/VideoConverter.class.php on line 114
here its line 114
Code:
$percent = round($downloaded/$downloadSize, 2) * 100;
>>>
http://videotomp3.pl


;

Last edited by globusut89; 06-24-2012 at 06:52 PM..
globusut89 is offline   Reply With Quote
Old 06-24-2012, 08:39 PM   PM User | #372
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,549
Thanks: 15
Thanked 131 Times in 124 Posts
chump2877 is on a distinguished road
Quote:
Originally Posted by globusut89 View Post
When trying to convert YouTube to MP3 I do not see first step
when video is download 1..50..100%%.
I just see second step when video is convert 1...40...100%
Why can not I see the first step ?
You have modified the code, so I don't know why the code is no longer working for you. How could I know? The original code does not do that.

That said, the download of the video is still occurring, because you can see it in the browser source code. Perhaps you deleted a flush() somewhere, which is required to flush the output buffer during the download process so that the download progress bar is visible.

It's also possible that you have an extremely fast download speed, downloading the video from YouTube to your server. In which case, the video is downloaded before the download progress bar has a chance to display.

Quote:
Originally Posted by globusut89 View Post
and i got error log:
Code:
PHP Warning:  Division by zero in /home/pepzolco/public_html/VideoConverter.class.php on line 114
That warning is irrelevant, and not the source of your problem. It is a harmless side effect of calculating the percentages for the progress bar. If you have disabled PHP error reporting, which you should (and it is disabled, by default), then PHP warnings like that will not be displayed in the browser.
__________________
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]
chump2877 is offline   Reply With Quote
Old 07-02-2012, 06:50 AM   PM User | #373
zhanly
New to the CF scene

 
Join Date: Jul 2012
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
zhanly is an unknown quantity at this point
Does your script support using proxy to connect to youtube?
zhanly is offline   Reply With Quote
Old 07-02-2012, 08:06 AM   PM User | #374
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,549
Thanks: 15
Thanked 131 Times in 124 Posts
chump2877 is on a distinguished road
Quote:
Originally Posted by zhanly View Post
Does your script support using proxy to connect to youtube?
Neither of the versions of my app (free or paid-for version) currently includes proxy functionality, but I have programmed this before using the Tor project. Tor, in general, leverages a large proxy network that enables you to anonymize your IP address and location while surfing the internet. You can install it on Linux and take advantage of the command line interface provided to programmatically (and anonymously) connect to YouTube via the Tor proxy network. (You need to create a socket connection to the Tor proxy first -- to establish a new identity -- before connecting to YouTube via cURL to download a video, if I recall correctly.)

The problem with proxies (any proxy network) is that they are notoriously slow. So the download times of your videos will suffer, and that inconvenience will be passed on to the consumer of your website/application.

If the demand for proxy connections to YouTube becomes great, I might add this feature to my app here. Can I ask exactly why you need to use a proxy to connect to YouTube?
__________________
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]
chump2877 is offline   Reply With Quote
Old 07-03-2012, 02:00 AM   PM User | #375
bbrog
New Coder

 
Join Date: Jun 2012
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
bbrog is an unknown quantity at this point
Hi, just wondering how much cpu and memory this script uses? Does it use a good amount?

Lets say we are getting hit by 20 downloads every minute or 1000 a day or something.

My server specs:

2.0ghz quad core
8GB Ram

has many other sites on it also.

Do let me know.

Thanks!
bbrog is offline   Reply With Quote
Reply

Bookmarks

Tags
audio, class, conversion, dailymotion, ffmpeg, free youtube mp3 script, free youtube script, mp3, php, script, video, youtube, youtube to mp3, youtube to mp3 php script, youtube to mp3 script

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:46 AM.


Advertisement
Log in to turn off these ads.