Selasa, 19 April 2016

Video Converter

script, 1=>file_name, 2=>temp_file $file_name = $argv[1]; $temp_file = $argv[2]; $uploads = '/opt/lampp/htdocs/user_uploads/'; // Set up file location strings $save_to = $uploads.'video/'.$file_name.'.mp4'; $save_thumb_to = $uploads.'image/200/'.$file_name.'.jpg'; $save_large_thumb_to = $uploads.'image/800/'.$file_name.'.jpg'; // first we need to extract at least one thumbnail. $command = "ffmpeg -i ".$temp_file." -an -ss 00:00:03 -an -r 1 -vframes 1 -y -vf scale='-1:min(200\, iw*3/2)' ".$save_thumb_to.' 2>&1 >> /opt/lampp/logs/ffmpeg_log.log'; exec($command); // Let's make a larger thumbnail too $command = "ffmpeg -i ".$temp_file." -an -ss 00:00:03 -an -r 1 -vframes 1 -y -vf scale='-1:min(800\, iw*3/2)' ".$save_large_thumb_to.' 2>&1 >> /opt/lampp/logs/ffmpeg_log.log'; exec($command); // ffmpeg command to convert video // MP4 $command = "ffmpeg -i ".$temp_file." -y -vf scale='min(900\, iw*3/2)':-1 -vcodec libx264 -coder 1 -bf 16 -refs 1 -flags2 +dct8x8 -acodec libfaac -ac 2 -ar 48000 ".$save_to." 2>&1 >> /opt/lampp/logs/ffmpeg_log.log"; exec($command); // 2>&1 redirect STDERR to STDOUT and send to log. // Now we need to run the mp4 we just made through qt-faststart to move the moov metadata to the start of the file to allow browsers to start playing the content before the whole file is downloaded. $command = "/opt/lampp/background_scripts/qtfaststart.py $save_to"; exec($command); // Set the correct permissions for the new file $command = "chmod 744 $save_to"; exec($command); // Grab the dimensions using mediainfo $command = "/usr/bin/mediainfo $save_to --Output=XML"; exec($command, $output); // Load the output from mediainfo $xml = new SimpleXMLElement(implode("\n",$output)); // Select the width and height of the video $video = $xml->File->track[1]; $width = (int) str_replace(array('pixels',' '),'',$video->Width); $height = (int) str_replace(array('pixels',' '),'',$video->Height); // Save the dimensions to the media table // connect to the database try { $dbh = new PDO("mysql:host=localhost;dbname=database_name", 'user_name', 'password'); $dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); } catch(PDOException $e) { $e->getMessage(); } // We can detect if any error occurred during processing by checking for the videos dimensions if( ! isset($xml->File->track[1]) ){ $sql = " UPDATE `database`.`table` SET `error` = :error WHERE `file_name` = :file_name; "; $sth = $dbh->prepare($sql); $sth->bindParam(':error', '1'); $sth->bindParam(':file_name', $file_name); $sth->execute(); die(); } // Select the width and height of the video $video = $xml->File->track[1]; $width = (int) str_replace(array('pixels',' '),'',$video->Width); $height = (int) str_replace(array('pixels',' '),'',$video->Height); $sql = " UPDATE `database`.`table` SET `width` = :width, `height` = :height WHERE `file_name` = :file_name; "; $sth = $dbh->prepare($sql); $sth->bindParam(':width', $width); $sth->bindParam(':height', $height); $sth->bindParam(':file_name', $file_name); $sth->execute(); ?>
http://www.resepkuekeringku.com/2014/11/resep-donat-empuk-ala-dunkin-donut.html http://www.resepkuekeringku.com/2015/03/resep-kue-cubit-coklat-enak-dan-sederhana.html http://www.resepkuekeringku.com/2014/10/resep-donat-kentang-empuk-lembut-dan-enak.html http://www.resepkuekeringku.com/2014/07/resep-es-krim-goreng-coklat-kriuk-mudah-dan-sederhana-dengan-saus-strawberry.html http://www.resepkuekeringku.com/2014/06/resep-kue-es-krim-goreng-enak-dan-mudah.html http://www.resepkuekeringku.com/2014/09/resep-bolu-karamel-panggang-sarang-semut-lembut.html

Copyright © Lantole Video Convert | Powered by Blogger

Design by Anders Noren | Blogger Theme by NewBloggerThemes.com | BTheme.net      Up ↑