PHP - Adding This Scaling To Existing Ffmpeg Code?
When I asked about adding a watermark to a video, this was suggested: "when scaling it, I'd do h/5:w/5 (of the source video), then position would be w/20 (5% from the left) and h-h/3 (75% of the way down) When I asked about adding a watermark to a video, this was suggested: "when scaling it, I'd do h/5:w/5 (of the source video), then position would be w/20 (5% from the left) and h-h/3 (75% of the way down)" I'd like to try that, but I don't know how to integrate that into my existing working code: $ffmpegCommand =''.$ffmpeg_b.' -y -i '.$video_file_full_path.' -i '.$watermark_image_full_path.' -filter_complex "scale=426:-2, overlay=10:10, " -vcodec libx264 -preset '.$pt->config->convert_speed.' -crf 26 '.$video_output_full_path_240.' 2>&1'; I've looked at the ffmpeg documentation, but need additional assistance. any help is appreciated
Similar Tutorials
Hello! I found this code from github. https://github.com/gburtini/Learning-Library-for-PHP and I want to know if its possible to add variables to it and what changes needed to be done to the whole script. $xs and $ys I want replace them and add two more. The whole code is he <?php require_once 'function.php'; function ll_nn_predict($xs, $ys, $row, $k) { $distances = ll_nearestNeighbors($xs, $row); $distances = array_slice($distances, 0, $k); $predictions = array(); foreach($distances as $neighbor=>$distance) { $predictions[$ys[$neighbor]]++; } asort($predictions); return $predictions; } function ll_nearestNeighbors($xs, $row) { $testPoint = $xs[$row]; $distances = _ll_distances_to_point($xs, $testPoint); return $distances; } function _ll_distances_to_point($xs, $x) { $distances = array(); foreach($xs as $index=>$xi) { $distances[$index] = ll_euclidean_distance($xi, $x); } asort($distances); array_shift($distances); return $distances; } and the function.php that is required is this: <?php function ll_transpose($rows) { $columns = array(); for($i=0;$i<count($rows);$i++) { for($k = 0; $k<count($rows[$i]); $k++) { $columns[$k][$i] = $rows[$i][$k]; } } return $columns; } function ll_mean($array) { return array_sum($array)/($array); } function ll_variance($array) { $mean = ll_mean($array); $sum_difference = 0; $n = count($array); for($i=0; $i<$n; $i++) { $sum_difference += pow(($array[$i] - $mean),2); } $variance = $sum_difference / $n; return $variance; } function ll_euclidean_distance($a, $b) { if(count($a) != count($b)) return false; $distance = 0; for($i=0;$i<count($a);$i++) { $distance += pow($a[$i] - $b[$i], 2); } return sqrt($distance); } I just want to know where is the variables in those 2 scripts and add more as I'm not well versed in using PHP. Thank you! I need some guidance in regards to adding Login with Facebook.
Is this something which is easily done? Currently, I'm using UserCake:
http://usercake.com/
How much testing and QA is necessary for this type of work?
Im trying to add some info to an existing cell in a mysql database. The cell currently reads: This is a piece of information. I would like to update the cell to read: This is a piece of information. a great piece of info. I have a variable with the following; $info = a great piece of info. Is it possible to add $info to the existing cell via php eg. <?php mysql_query("UPDATE mytable SET info = '$info' WHERE row = '$row'"); ?> all fine except I dont want to SET the info to $info I simply want to add $info onto the end of the existing data in the info record. Is this possible and how do i change the above query and go about it? Many thanks Hi there, I've been trying to implement pagination to an existing script that displays products, but at present only displays next and back buttons. The number of products is now increasing and we would like to show the number of pages of results but the tutorials I've been going through seem to use a very different way of displaying the results to the script we currently have. Does anyone have any suggestions how I could add pagination to this form..... // Build Pagination $ByPage = ($prod_rows * $prod_cols); $qnav = "SELECT devbg_products.*, devbg_categories.*, devbg_subcategories.* FROM devbg_products LEFT JOIN devbg_categories ON devbg_products.ItemCategory = devbg_categories.CategoryID LEFT JOIN devbg_subcategories ON devbg_products.ItemSubcategory = devbg_subcategories.SubcategoryID WHERE devbg_products.ItemCategory = " . sql($cgid); $rnav = mysql_query($qnav) or die(mysql_error()); $rows = mysql_num_rows($rnav); if($rows > $ByPage) { $pages = ceil ($rows / $ByPage); echo "<br>\n"; echo "<table align='center'>\n"; echo "<tr>\n"; echo "<td align=center><font face=verdana size=2>"; echo "<form method='POST' action='ShowCategory.php'>\n"; echo "<input type='hidden' name='Start' value='" . ($Start - $ByPage) . "'>\n"; echo "<input type='hidden' name='CategoryID' value='" . $_REQUEST["CategoryID"] . "'>\n"; echo "<input type='hidden' name='SubcategoryID' value='" . $_REQUEST["SubcategoryID"] . "'>\n"; if (($Start - $ByPage) <> -$ByPage) { echo "<input class='sub' type='submit' value='<<< Back' name='btnBack'>\n"; echo "</form>\n"; echo "</td>\n"; } echo "<td>\n"; echo "<form method='POST' action='ShowCategory.php'>\n"; echo "<input type='hidden' name='Start' value='" . ($Start + $ByPage) . "'>\n"; echo "<input type='hidden' name='CategoryID' value='" . $_REQUEST["CategoryID"] . "'>\n"; echo "<input type='hidden' name='SubcategoryID' value='" . $_REQUEST["SubcategoryID"] . "'>\n"; if ($Start + $ByPage < $pages * $ByPage) { echo "<input class='sub' type='submit' value='Next >>>' name='btnNext'>"; } echo "</form>\n"; echo "</td>\n"; echo "</tr>\n"; echo "</table><br><br>\n"; } This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=358003.0 Hi, I have a basic form that lets people enter details Code: [Select] <form action="welcome.php" method="post"> Name: <input type="text" name="fname" /> Second name: <input type="text" name="sname" /> <input type="submit" /> </form> And the standard insert in sql command. Im now looking to add a image uplad field the the same form. I have tried several methods off the internet but i cant get any to work. I would like the form to upload the image into the directory '../images' and then save the path to the file in the database, e.g. 'images/picture.jpg'. Can anyone point me in the right direction please. Im guessing i will have to use the file input type but i cant get any of it to work. Thanks Im not much of a coder, and I obviously did this wrong since it is not working. Im trying to bring a new field value in to an existing php file. I created a new table, and an admin page to control that field. I cant, however, figure out how to use that value in a different php file. Actually, there are 2 files. Each using a different field from that new table. I will post what my current code is below with the additions I tried to add. I bolded the lines that contain the tags Im trying to use. Any and help you can give in fixing this to make it work is greatly appreciated. Code: [Select] <?php # INCLUDE ALL NECESSARY FILES. include_once("Constants.php"); include_once("Database.php"); include_once("SiteSetting.php"); [b]$query = "SELECT arcade_multiplier FROM tbl_point_rewards"; mysql_query($query) or die("Invalid query". mysql_error() ); $result = mysql_fetch_array($result); $arcade_multiplier = $result["arcade_multiplier"];[/b] $dbObj = new database(); # SAVE ARCADE GAME POINTS INTO THE DATABASE function saveGamePoints( $game_id, $user_id, $game_score, $calculate_score_flag, $play_date ){ global $dbObj; $user_max_plays = getUserMaxPlaysLimit( $user_id, $game_id ); //$_SESSION["arcade_game"]["save_score"] = ($user_max_plays < $_SESSION["arcade_game"]["max_plays"]) ? "yes" : "no" ; if($user_max_plays < $_SESSION["arcade_game"][$_SESSION["url_gameid"]]["max_plays"]){ $total_points = calculatePointRatio($game_id, $game_score); //$total_points = $game_score; $x_gameid = md5($game_id); if($_SESSION["arcade_game"][$x_gameid]["play_time"] > 0){ $playTime['start'] = $_SESSION["arcade_game"][$x_gameid]["play_time"]; $playTime['end'] = time(); $playTime = ($playTime['end'] - $playTime['start']); } else { $playTime = 0; } # update total points into main score [b] $update_sql = "update tbl_users set points_gained = (points_gained+(".ceil($total_points)." * $arcade_multiplier)) where usrid={$user_id}";[/b] $rs = mysql_query($update_sql) or die("Invalid query: {$update_sql} - ". mysql_error()); $table = "tbl_arcade_game_score"; $fields = array("game_id", "user_id", "game_score", "calculate_score_flag", "play_date", "game_time"); $values = array($game_id, $user_id, $game_score, $calculate_score_flag, $play_date, $playTime); // return $dbObj->cgi( $table, $fields, $values, 1 ); $insertid = $dbObj->cgi( $table, $fields, $values, "" ); $ceiling_point = getCeiling($game_id); if($game_score >= $ceiling_point) { $chk_authourity = isAlreadyTrophyOwner($user_id, $game_id); //if($chk_authority < 1) if($chk_authourity < 1) { # store award details into the database (tbl_trophy_award) //$trophy_id = getTrophy( $game_id ); $trophy = getTrophyDetails($game_id); $trophy_id = $trophy['ctoon_id']; $tbl_fields = array('userid', 'game_id', 'award_date', 'trophy' ); $tbl_values = array($user_id, $game_id, $play_date, $trophy_id ); $insert_tbl_trophy_award_id = $dbObj->cgi('tbl_trophy_award', $tbl_fields, $tbl_values , "" ); # award trophy to user (tbl_users_ctoons) $table = "tbl_users_ctoons"; $fl = array("usrid", "ctoon_id", "del_status", "ctoons_auction", "auction_id", "location", "batpts"); $vl = array($user_id, $trophy_id, '0', '', 0, 1, 0); $dbObj->cgi($table, $fl, $vl , "" ); # send a pm to the user about the trophy include_once("send_pm_message.php"); $game = getGameDetails($game_id); $msgSub = "Grats! You just got a trophy!"; $message = "Grats! You got the ".$trophy["toon_name"]." trophy for the ".$game["game_name"]." game!<br> <img src=\"{$game['path']}\">"; //echo $message; //echo "<br><hr><br>"; sendMessage($user_id, 0, 0, $msgSub, $message, 1); sendMessage(2034, $user_id, 0, $msgSub, $message, 1); } } return $insertid; } }//end function function getCeiling($game_id) { $sql = "SELECT ceiling FROM tbl_game WHERE game_id = '".$game_id."'"; $rs = mysql_query($sql); $result = mysql_fetch_assoc($rs); return $result['ceiling']; } function isAlreadyTrophyOwner($user_id, $game_id) { $sql = "SELECT * FROM tbl_trophy_award WHERE game_id = {$game_id} and userid = {$user_id}"; $rs = mysql_query($sql); $num_rows = 0; $num_rows = mysql_num_rows($rs); if($num_rows > 0) { return $num_rows; } else { return $num_rows; } } # calculate game ratio function calculatePointRatio($game_id, $game_score){ //return $game_score; $sql = "select gs.* from arcade_game_setting as gs where gs.game_id={$game_id}"; $rs = mysql_query($sql) or die( "Invalid query". mysql_error() ); if($rs){ $row = mysql_fetch_array($rs); switch($row["calculation_type"]){ case "divide": $x_score = round($game_score / $row["r_no"]); break; case "multiply": $x_score = round($game_score * $row["r_no"]); break; default : $x_score = ceil($game_score); break; }//switch $row["r_no"]; if($row["game_cap"] > 0){ if($x_score > $row["game_cap"]){ $x_score = $row["game_cap"]; } } return $x_score; }//if }// end function # get user total plays function getUserMaxPlaysLimit($user_id, $game_id){ global $d_start_time, $d_end_time; $sql = "select * from tbl_arcade_game_score where user_id={$user_id} and game_id={$game_id} and play_date between {$d_start_time} and {$d_end_time}"; $rs = mysql_query($sql) or die("Invalid query :". mysql_error() ); if($rs){ return mysql_num_rows($rs); }//if } # get game details function getGameDetails($game_id){ $sql = "select g.game_id, g.game_name, g.award_ctoonid, c.toon_name, c.toon_cat, c.toon_subcat, c.toon_small_img from tbl_game as g, tbl_ctoon as c where g.game_id = {$game_id} and g.award_ctoonid=c.ctoon_id"; $rs = mysql_query($sql); if($rs){ $row = mysql_fetch_array($rs); if($row['toon_cat']!="" && $row['toon_subcat']!=0) $tpth="imgtoon/".$row['toon_cat']."/".$row['toon_subcat']."/thumb"; elseif($row['toon_cat']!="" && $row['toon_subcat']==0) $tpth="imgtoon/".$row['toon_cat']."/thumb"; $game["game_name"] = $row["game_name"]; $game["award_ctoon_id"] = $row["award_ctoonid"]; $game["toon_name"] = $row["toon_name"]; $game["path"] = SITEROOT ."/" . $tpth ."/" . $row["toon_small_img"]; return $game; } else { return false; } } # send pm message to winner function sendPMToWinner($user_id, $game_id, $game_score){ include_once("send_pm_message.php"); $g = $game_id; //$point_prize = calculatePointRatio($game_id, $game_score); $point_prize = $game_score; $game = getGameDetails($game_id); //# select ctoon //$sql = "select award_ctoonid from tbl_game where game_id=".$g; //$rsctoon = mysql_query($sql) or die("Invalid query: {$sql} - ". mysql_error()); //$row_ctoon = mysql_fetch_array($rsctoon); //$ctoon_id = $row_ctoon["award_ctoonid"]; //# award ctoon //$insert_user_ctoon = "insert into tbl_users_ctoons (usrid, ctoon_id, del_status, ctoons_auction, auction_id, location, batpts) //values('{$user_id}', '{$ctoon_id}', '0', '', '', '1', '0')"; //mysql_query($insert_user_ctoon) or die("Invalid insert query:".mysql_error() ); //# update points $update_points_sql = "update tbl_users set points_gained = (points_gained+1500) where usrid={$user_id}"; mysql_query($update_points_sql) or die("Invalid updates points query". mysql_error() ); $dbObj = new database(); $msgSub = "Grats! You got a Top Score for ".$game["game_name"]." !"; $message = "Grats! You had one of the Top 10 scores in the ".$game["game_name"]." game last month, and got a 1500 point bonus!<br>"; //<img src=\"{$game['path']}\">"; // echo $message; // echo "<br><hr><br>"; sendMessage($user_id, 0, 0, $msgSub, $message, 1); } /** * function getTrophy( $game_id ) * @param $game_id */ function getTrophy( $game_id ){ $sql = "select award_ctoonid from tbl_game where game_id=".$game_id; $rs = mysql_query( $sql ) or die( mysql_error() ); if( $rs ){ $row = mysql_fetch_assoc( $rs ); } return $row["award_ctoonid"]; } // Updated function from above // Will get more information about the trophy function getTrophyDetails($game_id) { $sql = "select b.ctoon_id,b.toon_name,b.toon_small_img from tbl_game as a,tbl_ctoon as b where a.game_id = '$game_id' and b.ctoon_id = a.award_ctoonid LIMIT 1"; $rs = mysql_query( $sql ) or die( mysql_error() ); if( $rs ){ $row = mysql_fetch_assoc( $rs ); } return $row; } ?> Code: [Select] <?php include_once("Constants.php"); include_once("Database.php"); include_once("SiteSetting.php"); /**************************************************/ # SAVE DONETION IN DATABASE # @param $uid # @param $donation_amt /**************************************************/ function saveDonetion($uid, $donation_amt, $transaction_id, $subscr_id='', $type){ if($transaction_id != "") { $flag = checkExist($uid); if($flag > 0){ updateDonetion($uid, $donation_amt, $transaction_id, $subscr_id='', $type); }else{ addDonetion($uid, $donation_amt, $transaction_id, $subscr_id='', $type); } } } /**************************************************/ /**************************************************/ # CHECK IS RECORD EXITS IN DONETION TABLE # @param $uid /**************************************************/ function checkExist($uid){ $dbObj = new database(); $sql = "select user_id from tbl_donation where user_id={$uid}"; $dbObj->myquery($sql); if($dbObj->row_count > 0){ return $dbObj->f_user_id; }else{ return 0; } } /**************************************************/ /**************************************************/ # INSERT DONETION RECORD IN tbl_donation # @param $uid # @param $donation_amt /**************************************************/ [b]$query = "SELECT arcade_multiplier FROM tbl_point_rewards"; mysql_query($query) or die("Invalid query". mysql_error() ); $result = mysql_fetch_array($result); $arcade_multiplier = $result["arcade_multiplier"];[/b] function addDonetion($uid, $donation_amt, $transaction_id, $subscr_id='', $type){ $dbObj = new database(); $months = floor($donation_amt / 5); $exp_time = mktime(date("H"),date("i"),date("s"),date("m") + $months,date("d"),date("Y")); $fields = array("transaction_id", "subscr_id", "user_id", "donation_amt", "donation_date", "exp_date", "donation_type", "transaction_details"); $values = array($transaction_id, $subscr_id, $uid, $donation_amt, time(), $exp_time, $type, serialize($_SESSION["recurring_td"])); # update points [b]$update_points_sql = "update tbl_users set points_gained = (points_gained+(($donation_amt / 5) * $donation_pts)) where usrid={$uid}";/[b] mysql_query($update_points_sql) or die("Invalid updates points query". mysql_error() ); if($donation_amt < 5){ // The user donated less than $5 }else{ upgradeAccount($uid); } return $dbObj->cgi("tbl_donation", $fields, $values, false); } /**************************************************/ /**************************************************/ # UPDATE EXISTING DONETION RECORD # @param $uid # @param $donation_amt /**************************************************/ function updateDonetion($uid, $donation_amt, $transaction_id, $subscr_id='', $type){ if(strlen($subscr_id) > 0){ $cd = " AND subscr_id='".$subscr_id."'"; } $sql_select = "select exp_date, donation_amt from tbl_donation where user_id=".$uid; //$sql_select = "select exp_date, donation_amt from tbl_donation where user_id=".$uid." and donation_type like '%recurring%'"; $rs_select = mysql_query($sql_select) or die("Invalid query".mysql_error()); if($rs_select){ $row = mysql_fetch_array($rs_select); $expdt = $row["exp_date"]; $damt = ($row["donation_amt"] + $donation_amt); $months = floor($donation_amt / 5); $exp_time = mktime(23, 59, 59, date("m",$row["exp_date"]) + $months, date("d", $row["exp_date"]), date("Y", $row["exp_date"])); } $dbObj = new database(); $sql = "update tbl_donation set transaction_id='".$transaction_id."', donation_amt=(donation_amt + {$donation_amt}), donation_date = ".time().", exp_date=".$exp_time.", donation_type='".$type."', transaction_details='".serialize($_SESSION["recurring_td"])."' where user_id={$uid}"; # update points [b]$update_points_sql = "update tbl_users set points_gained = (points_gained+(($donation_amt / 5) * $donation_pts)) where usrid={$uid}";[/b] mysql_query($update_points_sql) or die("Invalid updates points query". mysql_error() ); $dbObj->myquery($sql, 1); if($donation_amt < 5){ // The user donated less than $5 }else{ upgradeAccount($uid); } } /**************************************************/ /**************************************************/ # UPDATE EXISTING RECURRING DONETION RECORD # @param $uid # @param $donation_amt /**************************************************/ function updateRecurringDonetion($subscr_id, $transaction_amt){ $sql_subscr = "select donation_id, transaction_id, user_id from tbl_donation where subscr_id = '".$subscr_id."'"; $rs_subscr = mysql_query($sql_subscr) or die("Invalid query".mysql_error()); if(strlen($rs_subscr) > 0){ $row_subscr = mysql_fetch_assoc($rs_subscr); $uid = $row_subscr["user_id"]; $donation_amt = $transaction_amt; $transaction_id = $row_subscr["transaction_id"]; $subscr_id = $subscr_id; $type = "Recurring"; updateDonetion($uid, $donation_amt, $transaction_id, $subscr_id='', $type); } } /**************************************************/ /**************************************************/ # UPDATE USER STATUS FROM STANDERED TO PREMIUM # @param $uid /**************************************************/ function upgradeAccount($uid){ $dbObj = new database(); $sql = "UPDATE tbl_users SET acc_type = 'P' WHERE usrid={$uid} LIMIT 1 "; # update points $update_points_sql = "update tbl_users set points_gained = (points_gained+0) where usrid={$uid}"; mysql_query($update_points_sql) or die("Invalid updates points query". mysql_error() ); $dbObj->myquery($sql, 1); }//function upgradeDonation($uid) ?> Hello and good day to all of you I have passed my midterms project(Online Shopping) with a score of 94 in PHP ( Click here to see file ) ( Sorry if the design is too ugly, I'm just new in programming XD ) Now our finals project will be a PHP site again but now with a database in it.. So instead of making a new project/design for a site, why not just add a database to my existing midterms? I would like to ask for some help here in helping me on connecting to the database, adding a database/tables and anything that would be of help like suggesting Databases would be like, - Users ( Admin and Members ) - Upper Clothing ( Shirts, Jackets, Long Sleeves, Raglan and etc ) - Lower Clothing ( Pants, Shorts, Boxers and etc ) - Stock on a current item - Single member's Transaction History - All user's Transaction History Is there a way that I could add those database named above to my project? Thank you in advance! So on a cloud computing platform such as AWS, how would one keep the /html folder in Apache identical?
I can FTP into one "instance" and modify code easily enough, but how would I push reversions to multiple servers at once?
It seems like such a simple question, but the answer eludes me.
Edited by arbitrageur, 20 November 2014 - 04:43 PM. I would like to support UTF-8 on my website but am unsure - and quite fearful - whether it will break my existing code or not?! I looked at http://us3.php.net/mbstring(), but worry that I'm going to miss something. Here is some sample code where I think things could easily break... // Trim all Form data. $trimmed = array_map('trim', $_POST); // ************************ // Validate Form Data. * // ************************ // Validate First Name. if (empty($trimmed['firstName'])){ // No First Name. $errors['firstName'] = 'Enter your First Name.'; }else{ // First Name Exists. if (preg_match('#^[A-Z \'.-]{2,30}$#i', $trimmed['firstName'])){ // Valid First Name. $firstName = $trimmed['firstName']; }else{ // Invalid First Name. $errors['firstName'] = 'First Name must be 2-30 characters (A-Z \' . -)'; } }//End of VALIDATE FIRST NAME // Validate Username. if (empty($trimmed['username'])){ // No Username. $errors['username'] = 'Enter your Username.'; }else{ // Username Exists. if (preg_match('~(?x) # Comments Mode ^ # Beginning of String Anchor (?=.{8,30}$) # Ensure Length is 8-30 Characters .* # Match Anything $ # End of String Anchor ~i', $trimmed['username'])){ // Valid Username. // ****************************** // Check Username Availability. * // ****************************** // Build query. $q1 = 'SELECT id FROM member WHERE username=?'; // Prepare statement. $stmt1 = mysqli_prepare($dbc, $q1); // Bind variable to query. mysqli_stmt_bind_param($stmt1, 's', $trimmed['username']); // Execute query. mysqli_stmt_execute($stmt1); // Store results. mysqli_stmt_store_result($stmt1); // Check # of Records Returned. if (mysqli_stmt_num_rows($stmt1)>0){ // Duplicate Username. $errors['username'] = 'This Username is taken. Try again.'; }else{ // Unique Username. $username = $trimmed['username']; } }else{ // Invalid Username. $errors['username'] = 'Username must be 8-30 characters.'; } }//End of VALIDATE USERNAME Three possible areas where I could run into trouble are with... 1.) array_map 2.) preg_match 3.) Prepared Statements For #2, I see there is mb_ereg_match but I am not sure if I just replace my current Regex function with that one, or if there is more involved. I'm not sure if any problems would arise with #1 or #3 or elsewhere, and would really appreciate a second set of eyes on this code!! requinix said switching is a good idea, but I'm pretty freaked out that I'm going to break things and create a big security hole?! Any help would be appreciated!! Thanks, Debbie Hi, I have some code which displays my blog post in a foreach loop, and I want to add some social sharing code(FB like button, share on Twitter etc.), but the problem is the way I have my code now, creates 3 instances of the sharing buttons, but if you like one post, all three are liked and any thing you do affects all of the blog post. How can I fix this? <?php include ("includes/includes.php"); $blogPosts = GetBlogPosts(); foreach ($blogPosts as $post) { echo "<div class='post'>"; echo "<h2>" . $post->title . "</h2>"; echo "<p class='postnote'>" . $post->post . "</p"; echo "<span class='footer'>Posted By: " . $post->author . "</span>"; echo "<span class='footer'>Posted On: " . $post->datePosted . "</span>"; echo "<span class='footer'>Tags: " . $post->tags . "</span>"; echo ' <div class="addthis_toolbox addthis_default_style "> <a class="addthis_button_facebook_like" fb:like:layout="button_count"></a> <a class="addthis_button_tweet"></a> <a class="addthis_counter addthis_pill_style"></a> </div> <script type="text/javascript">var addthis_config = {"data_track_clickback":true};</script> <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=webguync"></script>'; echo "</div>"; } ?> Hiya! I need help! I have this script; <?php session_start(); include 'system/template/template.php'; include 'system/mysql/mysql.php'; include 'system/properties/property.php'; $mysql = new mysql(); $mysql->connect(); $property = new property(); if(!$property->landlord_loggedin()) { header('Location: login.php'); } if(isset($_SESSION['N_P_ID']) && !empty($_SESSION['N_P_ID'])) { if(isset($_POST['videotitle']) && !empty($_POST['videotitle']) && isset($_FILES['videofile']) && !empty($_FILES['videofile'])) { $upload = $bad . '<form id="Upload" action="upload_video.php" enctype="multipart/form-data" method="post"> <h3>Upload a video of your property</h3> <label>Video Title</label> <input type="text" name="videotitle"><br /> <input type="file" name="videofile"> <label>Submit</label> <input type="submit" name="submit" value="Upload"><br /> <a href="landlord_account.php">Skip</a> </form>'; $extensions = array('mpg', 'avi', 'mpeg'); define ("MAX_SIZE","10240"); function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } if(isset($_FILES['imageone'])) { if(!isset($_POST['videotitle'])) { $bad = '<p class="bad">Please enter a video title.</p>'; $form = $upload; } $filename = stripslashes($_FILES['videofile']['name']); $extension = strtolower(getExtension($filename)); if(!in_array($extension, $extensions)) { $bad = '<p class="bad">Video is incorrect format, please make sure your video format is either mpg/mpeg or avi.</p>'; $form = $upload; } else { $size = filesize($_FILES['videofile']['tmp_name']); if($size > MAX_SIZE*1024) { $bad = '<p class="bad">Video too large.</p>'; $form = $upload; } $time = time(); $image_name = $time . '.' . $extension; $newname = "uploads/properties/landlord_files/videos/" . $image_name; if(move_uploaded_file($_FILES['videofile']['tmp_name'], $newname)) { if($property->add_video($time, 'flv', $_POST['videotitle'])) { $srcFile = 'uploads/properties/landlord_files/videos/' . $image_name; $destFile = 'uploads/properties/landlord_files/videos/' . $time . '.flv'; $ffmpegPath = "/path/to/ffmpeg"; $flvtool2Path = "/path/to/flvtool2"; $ffmpegObj = new ffmpeg_movie($srcFile); $srcWidth = makeMultipleTwo($ffmpegObj->getFrameWidth()); $srcHeight = makeMultipleTwo($ffmpegObj->getFrameHeight()); $srcFPS = $ffmpegObj->getFrameRate(); $srcAB = intval($ffmpegObj->getAudioBitRate()/1000); $srcAR = $ffmpegObj->getAudioSampleRate(); $img = $image_name; $ff_frame = $ffmpegObj->getFrame(1); if($ff_frame) { $gd_image = $ff_frame->toGDImage(); if($gd_image) { imagepng($gd_image, $img); imagedestroy($gd_image); $property->add_image($img, 'png', 'frame_shot'); } } exec($ffmpegPath . " -i " . $srcFile . " -ar " . $srcAR . " -ab " . $srcAB . " -f flv -s " . $srcWidth . "x" . $srcHeight . " " . $destFile . " | " . $flvtool2Path . " -U stdin " . $destFile); @unlink($newname); function makeMultipleTwo ($value) { $sType = gettype($value/2); if($sType == "integer") { return $value; } else { return ($value-1); } } $ref = 1; } else { @unlink($newname); $bad = '<p class="bad">Video upload failed.</p>'; $form = $upload; } } else { $bad = '<p class="bad">Video upload failed.</p>'; $form = $upload; } } } if($ref == 1) { header('Location: landlord_account.php?page=3'); } } else { $form = '<form id="Upload" action="upload_video.php" enctype="multipart/form-data" method="post"> <h3>Upload a video of your property</h3> <label>Video Title</label> <input type="text" name="videotitle"><br /> <input type="file" name="videofile"> <label>Submit</label> <input type="submit" name="submit" value="Upload"><br /> <a href="landlord_account.php">Skip</a> </form>'; } $template = new template(); $array = array('TITLE' => 'Upload A Video', 'CONTENT' => $form); $template->newTemplate($array, 'add_property'); } else { header('Location: landlord_account.php'); } ?> When I click upload, nothing happens. I just get a blank template (from my template system). Is there something I'm doing wrong here? Many thanks, James. Hi, I am using a php script for converting avi,mpeg files to flv with ffmpeg.my code is Code: [Select] $srcFile = "uploads/flame.avi"; $destFile = "uploads/flame.flv"; $ffmpegPath = "/usr/bin/ffmpeg"; $flvtool2Path = "/usr/bin/flvtool2"; $ffmpegObj = new ffmpeg_movie($srcFile); $srcWidth = 320; $srcHeight = 240; $command = $ffmpegPath . " -i " . $srcFile . " -f flv -s " . $srcWidth . "x" . $srcHeight . " " . $destFile . " | " . $flvtool2Path . " -U stdin " . $destFile; $convert = exec($command); if(!$convert) { echo "FAILED!!!"; } else { echo "SUCCESS"; }I can create a flv file using this script.But sometimes it creates a flv file with size 0 k.I don't know why this is happening.With the same avi file,sometimes it creates correct flv file and sometimes flv with size 0k.How can I confirm whether the conversion is success. In both the cases it displays SUCCESS. HI, When I trying to covnert 3gp to FLV I got this error: FFmpeg version SVN-r12665, Copyright (c) 2000-2008 Fabrice Bellard, et al. configuration: --enable-gpl --enable-postproc --enable-swscale --enable-avfilt er-lavf --enable-pthreads --enable-liba52 --enable-avisynth --enable-libfaac --e nable-libfaad --enable-libgsm --enable-memalign-hack --enable-libmp3lame --enabl e-libnut --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --cpu=i686 --extra-ldflags=-static libavutil version: 49.6.0 libavcodec version: 51.54.0 libavformat version: 52.13.0 libavdevice version: 52.0.0 built on Apr 2 2008 22:35:11, gcc: 4.2.3 Seems stream 0 codec frame rate differs from container frame rate: 29.97 (30000/ 1001) -> 15.00 (15/1) Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'uploads/v_1.3gp': Duration: 00:01:03.6, start: 0.000000, bitrate: 189 kb/s Stream #0.0(und): Video: h263, yuv420p, 176x144 [PAR 12:11 DAR 4:3], 15.00 t b(r) Stream #0.1(und): Audio: samr / 0x726D6173, 8000 Hz, mono WARNING: The bitrate parameter is set too low. It takes bits/s as argument, not kbits/s Output #0, flv, to 'uploads/a.flv': Stream #0.0(und): Video: flv, yuv420p, 320x240 [PAR 1:1 DAR 4:3], q=2-31, 20 0 kb/s, 15.00 tb(c) Stream #0.1(und): Audio: libmp3lame, 22050 Hz, mono, 0 kb/s Stream mapping: Stream #0.0 -> #0.0 Stream #0.1 -> #0.1 Unsupported codec (id=73728) for input stream #0.1 What should I do? Thanks This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=334005.0 This topic has been moved to Other Web Server Software. http://www.phpfreaks.com/forums/index.php?topic=351144.0 Hi, I have limited experience of using PHP, but having done some searching around it would seem that it is possible to convert audio files that are uploaded through a web page to mp3 using ffmpeg. The audio files would be uploaded using the Uploadify script to subfolders that are named according to the user's login. I would need the PHP script to be able to process all audio files that are either not in MP3 format, or are in MP3 format but greater than 192kbps, deleting the original file after the conversion. Am I right in thinking that this could be achieved using PHP, and if so, can anyone get me started with some code, or a link to a webpage with some code? Also, I am currently using Hostpapa for hosting my website, and I understand that they don't include ffmpeg, and also don't allow ssh. I read on one website that I could still install a compiled version of ffmpeg on a shared server, but I am not sure if this means that it would work on Hostpapa, or whether I would need to change my host to get ffmpeg working. Any advice on any of this would be welcome! Thanks, Nick This topic has been moved to Other Web Server Software. http://www.phpfreaks.com/forums/index.php?topic=351153.0 i dont get whats wrong i does not add to the db Code: [Select] <?php if($_POST['submitbtn']){ require "scripts/connect.php"; $title = mysql_real_escape_string($_POST['title']); $by = mysql_real_escape_string($_POST['by']); $body = mysql_real_escape_string($_POST['body']); if ($title && $by && $body){ $query = mysql_query("INSERT INTO news (title, by, body)VALUES('$title', '$by', '$body')"); echo "ADD SUCCESFULLY!"; }else $msg = "<font color=red>YOU DID NOT FILL ALL OF THEM IN!</font>"; } ?> |