[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

06/26/2008 at 09:43AM PDT, ID: 23518911
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.7

PHP: ffmpeg to work with audio file

Asked by alicca in PHP Scripting Language

Tags: PHP

hi this is some part of clipshare script

upload.php

i found a site that teach you to convert mp3 format to flv.

Command for ffmpeg to convert:

ffmpeg -y -i myfile.mp3 -f flv -acodec libmp3 -ab 64 -ac 1 myfile.flv

source from : http://heardspace.sulehosting.co.za/?p=5

my problem is how to modify the code to recognize mp3 file being upload and convert it to flv.

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
if(isset($_GET['rnd_id']))
{
    STemplate::assign('upload_page', 'upload');
        
    $temp_dir = $_REQUEST['temp_dir'];
    $_POST_DATA = getPostData($temp_dir, $_REQUEST['tmp_sid']);
    
    $upload_dir = $_POST_DATA['upload_dir'];
    $upload_file = $_POST_DATA['upfile_0'];
    $upload_file_path = $upload_dir . $upload_file;
    if(!is_file($upload_file_path) || filesize($upload_file_path) < 0)
    {
	$err = 'Failed to upload selected file!';
    }
    
    $upload_file_size = filesize($uploaded_file_path);
    if($err == "")
    {
	$pos = strrpos($upload_file,".");
	$ph = strtolower(substr($upload_file,$pos+1,strlen($upload_file)-$pos));
	$space = round($upload_file_size/(1024*1024));
	if($config['enable_package']=="yes")
	{
	    check_subscriber($space);
	}
	
	//this should never happen
	if(($ph!="3gp" && ph!="mp3" && $ph!="mp4" && $ph!="mov" && $ph!="asf" && $ph!="flv" && $ph!="mpg" && $ph!="avi" && $ph!="mpeg" && $ph!="wmv" && $ph!="rm" && $ph!="dat") || $space>$config[max_video_size])
	    $err = 'Invalid video format or invalid video size!';	
    }
    
    if($err == "")
    {
 
			// ----- Approve Video -----
			if($config['approve'] == 1) {
				$active="active='0'";
				} else {
				$active="active='1'";
				}
			// -------------------------
 
  $v_title = htmlentities(strip_tags($_POST_DATA[field_myvideo_title])); 
  $v_descr = htmlentities(strip_tags($_POST_DATA[field_myvideo_descr])); 
 
  $sql="insert into video set 
    UID=$_SESSION[UID], 
    title='$v_title', 
    description='$v_descr', 
    keyword='$_POST_DATA[field_myvideo_keywords]', 
    channel='0|$_POST_DATA[listch]|0', 
    space = '$space', 
    addtime='".time()."', 
    adddate='".date("Y-m-d")."', 
    vkey='".mt_rand()."', 
    type='$_POST_DATA[field_privacy]',
	$active, 
    filehome='$_POST_DATA[p]'";
 
	$conn->execute($sql);
    	$vid=mysql_insert_id();
        $vdoname=$vid.".".$ph;
	$ff = $config['vdodir'].'/'.$vdoname;
	
	//rename uploaded file
	if(rename($upload_file_path,$ff))
	{
	    //create background conversion process
 
if($config[vresize] == 1) {$encodecommand="$config[mencoder] $config[vdodir]/$vdoname -o $config[flvdodir]/".$vid.".flv -of lavf -oac mp3lame -lameopts abr:br=56 -ovc lavc -lavcopts vcodec=flv:vbitrate=$config[vbitrate]:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -vop scale=$config[vresize_x]:$config[vresize_y] -srate $config[sbitrate]";}
else {$encodecommand="$config[mencoder] $config[vdodir]/$vdoname -o $config[flvdodir]/".$vid.".flv -of lavf -oac mp3lame -lameopts abr:br=56 -ovc lavc -lavcopts vcodec=flv:vbitrate=$config[vbitrate]:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames -srate $config[sbitrate]";}
 
		exec("$config[phppath] $config[BASE_DIR]/convert.php $vdoname $vid $ff> /dev/null &"); 
	    
		//create temporary (video is converting) thumbs	
		video_to_frame2($ff, $vid);
			
		//get duration
		exec("$config[mplayer] -vo null -ao null -frames 0 -identify $config[vdodir]/$vdoname", $p);
    		while(list($k,$v)=each($p))
    		{
        	    if($length=strstr($v,'ID_LENGTH='))
        	    break;
    		}
    		$lx = explode("=",$length);
    		$duration = $lx[1];
 
	} else {
	    $err = 'Failed to rename uploaded file!';
	}
    }
    
    if($err == "")
    {
	$space=get_size($ff);
	$space=round($space/(1024*1024));
	$conn->execute("update video set space='$space' where VID='$vid'");
	$key=substr(md5($vid),11,20);
	send_subscribed_mail($_SESSION[UID],'$key',$_SESSION[EMAIL]);
 
        $sql="update video set
    		vdoname='$vdoname',
                flvdoname='".$vid.".flv',
                duration='$duration',
                vkey='$key' WHERE VID=$vid";
        $conn->execute($sql);
       
 
        if($config['enable_package']=="yes")
        {
    	    $sql = "update subscriber set used_space=used_space+$space, used_bw=used_bw+$space, total_video=total_video+1 where UID=$_SESSION[UID]";
            $conn->execute($sql);
        }
        
        header("Location:$config[baseurl]/upload_success.php?viewkey=$key&upload=yes"); exit;
    }
}
Attachments:
 
this is all part of upload.php
 
[+][-]06/26/08 11:29 AM, ID: 21877628

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06/29/08 11:09 AM, ID: 21894933

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: PHP Scripting Language
Tags: PHP
Sign Up Now!
Solution Provided By: Ray_Paseur
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20091111-EE-VQP-91 / EE_QW_2_20070628