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 02-15-2012, 03:51 PM   PM User | #181
zemaitis
New Coder

 
Join Date: Feb 2012
Posts: 26
Thanks: 9
Thanked 0 Times in 0 Posts
zemaitis is an unknown quantity at this point
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
zemaitis is offline   Reply With Quote
Old 02-15-2012, 05:31 PM   PM User | #182
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,530
Thanks: 15
Thanked 128 Times in 121 Posts
chump2877 is on a distinguished road
Quote:
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?
__________________
Regards, R.J.

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

Help spread the word! Like my YouTube-to-Mp3 Web Conversion Software on Facebook !! :)
chump2877 is offline   Reply With Quote
Old 02-16-2012, 07:41 AM   PM User | #183
zemaitis
New Coder

 
Join Date: Feb 2012
Posts: 26
Thanks: 9
Thanked 0 Times in 0 Posts
zemaitis is an unknown quantity at this point
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

Last edited by zemaitis; 02-16-2012 at 09:02 AM..
zemaitis is offline   Reply With Quote
Old 02-16-2012, 09:06 AM   PM User | #184
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,530
Thanks: 15
Thanked 128 Times in 121 Posts
chump2877 is on a distinguished road
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....
__________________
Regards, R.J.

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

Help spread the word! Like my YouTube-to-Mp3 Web Conversion Software on Facebook !! :)
chump2877 is offline   Reply With Quote
Old 02-16-2012, 09:19 AM   PM User | #185
zemaitis
New Coder

 
Join Date: Feb 2012
Posts: 26
Thanks: 9
Thanked 0 Times in 0 Posts
zemaitis is an unknown quantity at this point
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.

Last edited by zemaitis; 02-16-2012 at 10:54 AM..
zemaitis is offline   Reply With Quote
Old 02-16-2012, 11:21 AM   PM User | #186
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,530
Thanks: 15
Thanked 128 Times in 121 Posts
chump2877 is on a distinguished road
Quote:
Originally Posted by zemaitis View Post
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.
__________________
Regards, R.J.

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

Help spread the word! Like my YouTube-to-Mp3 Web Conversion Software on Facebook !! :)
chump2877 is offline   Reply With Quote
Old 02-16-2012, 11:30 AM   PM User | #187
zemaitis
New Coder

 
Join Date: Feb 2012
Posts: 26
Thanks: 9
Thanked 0 Times in 0 Posts
zemaitis is an unknown quantity at this point
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..

Last edited by zemaitis; 02-16-2012 at 12:25 PM..
zemaitis is offline   Reply With Quote
Old 02-16-2012, 06:45 PM   PM User | #188
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,530
Thanks: 15
Thanked 128 Times in 121 Posts
chump2877 is on a distinguished road
Quote:
Originally Posted by zemaitis View Post
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:

Code:
$("#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)...

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

Code:
window.onload = function()
{
	if (!document.getElementById('preview'))
	{
		$("#conversionForm").css("display", "block");
	}
};
...to something like (again, code is not tested)...

Code:
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 } ?>
};
__________________
Regards, R.J.

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

Help spread the word! Like my YouTube-to-Mp3 Web Conversion Software on Facebook !! :)
chump2877 is offline   Reply With Quote
Users who have thanked chump2877 for this post:
zemaitis (02-16-2012)
Old 02-16-2012, 08:27 PM   PM User | #189
zemaitis
New Coder

 
Join Date: Feb 2012
Posts: 26
Thanks: 9
Thanked 0 Times in 0 Posts
zemaitis is an unknown quantity at this point
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

Last edited by zemaitis; 02-16-2012 at 08:47 PM..
zemaitis is offline   Reply With Quote
Old 02-17-2012, 12:44 PM   PM User | #190
skyice
New to the CF scene

 
Join Date: Feb 2012
Posts: 3
Thanks: 2
Thanked 0 Times in 0 Posts
skyice is an unknown quantity at this point
On ubuntu 11.04 i receive this error: http://xencraft.net/logs/1329405250_...8.65734555.txt

Can you help me?

Last edited by skyice; 02-17-2012 at 12:47 PM..
skyice is offline   Reply With Quote
Old 02-17-2012, 01:03 PM   PM User | #191
zemaitis
New Coder

 
Join Date: Feb 2012
Posts: 26
Thanks: 9
Thanked 0 Times in 0 Posts
zemaitis is an unknown quantity at this point
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?

Last edited by zemaitis; 02-17-2012 at 01:05 PM..
zemaitis is offline   Reply With Quote
Old 02-17-2012, 01:13 PM   PM User | #192
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,530
Thanks: 15
Thanked 128 Times in 121 Posts
chump2877 is on a distinguished road
Quote:
Originally Posted by skyice View Post
On ubuntu 11.04 i receive this error: http://xencraft.net/logs/1329405250_...8.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():

PHP Code:
$exec_string parent::_FFMPEG.' -i '.$this->GetTempVidFileName().' -y -acodec libmp3lame -ab '.$quality.'k '.$this->GetSongFileName() . ' 2> logs/' $this->_uniqueID '.txt'
See this post for more info regarding packages required.
__________________
Regards, R.J.

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

Help spread the word! Like my YouTube-to-Mp3 Web Conversion Software on Facebook !! :)
chump2877 is offline   Reply With Quote
Users who have thanked chump2877 for this post:
skyice (02-17-2012)
Old 02-17-2012, 01:30 PM   PM User | #193
skyice
New to the CF scene

 
Join Date: Feb 2012
Posts: 3
Thanks: 2
Thanked 0 Times in 0 Posts
skyice is an unknown quantity at this point
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
skyice is offline   Reply With Quote
Old 02-17-2012, 01:45 PM   PM User | #194
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,530
Thanks: 15
Thanked 128 Times in 121 Posts
chump2877 is on a distinguished road
Quote:
Originally Posted by skyice View Post
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? You have a lower version of Ubuntu, so maybe libavcodec-extra-53 is incompatible with your system? That is my best guess.
__________________
Regards, R.J.

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

Help spread the word! Like my YouTube-to-Mp3 Web Conversion Software on Facebook !! :)
chump2877 is offline   Reply With Quote
Users who have thanked chump2877 for this post:
skyice (02-17-2012)
Old 02-17-2012, 01:52 PM   PM User | #195
skyice
New to the CF scene

 
Join Date: Feb 2012
Posts: 3
Thanks: 2
Thanked 0 Times in 0 Posts
skyice is an unknown quantity at this point
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
skyice is offline   Reply With Quote
Reply

Bookmarks

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

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 09:59 PM.


Advertisement
Log in to turn off these ads.