徽州网站建设,企业网站备案域名信息,网站免费建站pixiv app,奇艺广州网站建设 熊掌号在线转化.谁有 把其他的视频文件格式的视频,经过上传自动转化FLV格式的一种插件.提供编程接口.给我一份.类似新浪网播客上传视频的一样. (还有上传是的哪个效果,进度条如何作的?)或者给我个参考地址什 ... 环境#xff1a;redhat as41。首先获取ffmpeg很多人找不到怎么下载,其…在线转化.谁有 把其他的视频文件格式的视频,经过上传自动转化FLV格式的一种插件.提供编程接口.给我一份.类似新浪网播客上传视频的一样. (还有上传是的哪个效果,进度条如何作的?)或者给我个参考地址什 ... 环境redhat as41。首先获取ffmpeg很多人找不到怎么下载,其实之前ffmpeg可以通过cvs下载不过最近他已经换成了更加强大的svn如何使用SVN我这里不再介绍网上还有大量的安装和使用的文章可以借鉴这里简单罗列几个SVN辅助的软件SubVersion从
http://subversion.tigris.org/ 下载支持linux我们这里就装这个TortoiseSVN从
http://tortoisesvn.tigris.org/ 下载是很不错的SVN客户端程序为windows外壳程序集成到windows资源管理器和文件管理系统的Subversion客户端用起来很方便commit动作变得就像Winrar右键压缩一样方便。ok那我们先装subversion记住最好之前装过apr和apr-util在apache.org网站能下到wget http://subversion.tigris.org/downloads/subversion-1.3.2.tar.gztar zvxf subversion-1.3.2.tar.gzcd subversion-1.3.2./configure --with-apr/usr/local/apr-httpd --with-apr-util/usr/local/apr-util-httpd/makemake install到此我们就可以通过svn命令获取最新的ffmpeg了svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg你会发现在你所在的目录自动出现一个ffmpeg的目录就是你下载的源代码。我们还不能这么快编译ffmpeg应该如果要让ffmpeg支持更多格式的转换还需做一些前期工作2.支持mp3linux当然是lame下载解压cd lame-3.96.1./configure --enable-shared --prefix/usr这里推荐尽量装在/usr下默认是装在/usr/local下。这样ffmpeg编译都能顺利的找到库文件3.支持Ogg Vorbis:as4自带相应的rpm包你可以安装一下如下rpm包libvorbis, libvorbis-devel,libogg, libogg-devel4.支持xvid x264现在最流行的两种高质量的压缩格式xvid的编译安装wget http://downloads.xvid.org/downloads/xvidcore-1.1.0.tar.gztar zvxf xvidcore-1.1.0.tar.gz./configure --prefix/usrmakemake installx264的获取同样是采用svn方式看来svn取代cvs不远了svn co svn://svn.videolan.org/x264/trunk x264cd x264./configure --prefix/usr --enable-sharedmakemake install5.AC3和dts编码的支持as4系统似乎已经支持ac3编码编译的时候只要加--enable-a52 --enable-gpl参数就行libdts编译参数./configure --prefix/usrmakemake install6.mpg4 aac格式支持由于服务器还针对手机用户服务所以类似aacmpg4铃声格式的支持我们也得做。这里我们安装faad2和faac就行下载请到
http://www.audiocoding.com/modules/mydownloads/FAAD2的编译cd faad2autoreconf -vif./configure --prefix/usr --with-mp4v2 --enable-sharedmakemake installfaac的编译cd faacchmod x bootstrap./bootstrap./configure --prefix/usr --with-mp4v2 --enable-sharedmakemake install7.支持3gp格式这也是现在好多手机支持的格式因为手机用户是我们的主要用户所以也得支持编译编译的时候加上--enable-amr_nb --enable-amr_wb参数就行根据编译系统的提示所以我们得下载一些编译3gp所需得文件。wget http://www.3gpp.org/ftp/Specs/ar ... 6.204/26204-510.zip解压以后把里面的文件都拷贝到libavcodec/amrwb_floatwget http://www.3gpp.org/ftp/Specs/ar ... 6.104/26104-510.zip解压以后把里面的文件都拷贝到libavcodec/amr_float好了基本ffmpeg支持的格式我们基本都做好前期准备了下面是ffmpeg的编译./configure --prefix/usr --enable-gpl --enable-shared --enable-mp3lame --enable-amr_nb --enable-amr_wb --enable-amr_if2 --enable-libogg --enable-vorbis --enable-xvid --enable-a52 --enable-a52bin --enable-faadbin --enable-dts --enable-pp --enable-faad --enable-faac --enable-x264 --enable-pthreads --disable-ffserver --disable-ffplaymakemake install补充1关于3gp的编译如果大家要编译--enable-amr_nb-fixed那就不能跟--enable-amr_nb同时编译我不大清楚这两者到底有什么区别似乎fixed是修正版管他呢编译的方法wget http://www.3gpp.org/ftp/Specs/ar ... 6.073/26073-510.zip解压以后把里面的文件都拷贝到libavcodec/amr目录下修改libavcodec/amr/makefile 找到CFLAGS -Wall -pedantic-errors -I. $(CFLAGS_$(MODE)) -D$(VAD) 换成CFLAGS -Wall -I. $(CFLAGS_$(MODE)) -D$(VAD) -DMMS_IO整体编译参数就是./configure --prefix/usr --enable-gpl --enable-shared --enable-mp3lame --enable-amr_nb-fixed --enable-amr_wb --enable-amr_if2 --enable-libogg --enable-vorbis --enable-xvid --enable-a52 --enable-a52bin --enable-dts --enable-pp --enable-faad --enable-faadbin --enable-faac --enable-x264 --enable-pthreads --disable-ffserver --disable-ffplaymakemake install补充2有朋友说在当在cpu是x86的情况下不能编译过去我这里没发生过这情况如果你真编译不过去可以试着加上cpucpuok,一个强大的ffmpeg编译好了不过目前管方的ffmpeg还不支持wma9和rmvb不过网上有很多解决方法大家去自己找找。关于进度条的问题,我一直都无法解决.按道理新浪也不可能100%获取真实进度的吧?如果模拟的话就一大堆了,我这里提供一UPU的类用的SOCKET协议.[php]?php/*** UGiA PHP UPLOADER V0.2** Copyright 2005 legend
legendskyhotmail.com* * This library is free software; you can redistribute it and/or modify it* under the terms of the GNU Lesser General Public License as published by* the Free Software Foundation; either version 2.1 of the License, or (at* your option) any later version.* This library is distributed in the hope that it will be useful, but* WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU* Lesser General Public License for more details.* You should have received a copy of the GNU Lesser General Public* License along with this library; if not, write to the Free Software* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,* USA.** link
http://www.ugia.cn,
http://sourceforge.net/projects/upu* copyright Copyright: 2004-2005 UGiA.CN.* author legend
legendskyhotmail.com* package UPU* version $Id: upu.class.php,v 1.2 2005/09/22 08:03:22 legend9 Exp $*/define(UPU_CLIENT_CHARSET, utf-8);define(UPU_TEMP_PATH, /upload/upu/temp/);define(UPU_SAVE_PATH, /upload/upu/files/);define(UPU_SOCKET_ENDTAG, /x2d/x2d/x0d/x0a);define(UPU_CRLF, /x0d/x0a);define(UPU_SOCKET_CREATE_ERROR, Socket创建失败);define(UPU_SOCKET_BIND_ERROR, 端口绑定失败);define(UPU_SOCKET_LISTEN_ERROR, 端口监听失败);define(UPU_SOKET_ACCEPT_ERROR, 无法接受客户端请求);define(UPU_CREATE_TEMP_FILE_ERROR, 创建临时文件失败);define(UPU_FILE_TO_LARGE, 文件超过指定大小);define(UPU_GET_TMP_FILE_SIZE_ERROR, 获取临时文件大小失败);define(UPU_READ_TMP_FILE_ERROR, 打开临时文件失败);define(UPU_WRITE_NEW_FILE_ERRPR, 创建新文件失败);class UPU{ var $sPort 1024;var $ePort 65536;var $savePath UPU_SAVE_PATH;var $tmpPath UPU_TEMP_PATH;var $allowExt *;var $maxFileSize 0;var $srvPort;var $ipAddr;var $processID;var $bufferSize 1024;var $Boundary;var $ContentLength 0;var $fileSize 0;var $fileInfo array();var $formData array();var $errorCode 0;function UPU (){$this-srvPort mt_rand($this-sPort, $this-ePort);$this-ipAddr $_SERVER[SERVER_NAME];}function processRequest(){ $uSocket socket_create(AF_INET, SOCK_STREAM, SOL_TCP);if ($uSocket 0) return -101;$uBind socket_bind($uSocket, $this-ipAddr, $this-srvPort);if ($uBind 0) return -102;//socket_set_blocking($uSocket);$uListen socket_listen($uSocket, 5);if ($uListen 0) return -103; $this-writeContents($this-tmpPath . $this-processID . .srv, $this-ipAddr.:.$this-srvPort);$uRequest socket_accept($uSocket);if ($uRequest 0) return -104;$httpResponse HTTP/1.1 200 OK/r/n;$httpResponse . Content-Length: 2/r/n;$httpResponse . Content-Type: text/html/r/n;$httpResponse . Last-Modified: . date(r) . /r/n;$httpResponse . Accept-Ranges: bytes/r/n;$httpResponse . X-Powered-By: UPU/r/n;$httpResponse . Date: . date(r) . /r/n/r/n;socket_write($uRequest, $httpResponse);$neededbuffer true;$BufferPond array();$tmpFileName $this-tmpPath . $this-processID . .dat;if(!$fp fopen ($tmpFileName, wb)) return -105;$dataRead 0;while ($flag socket_recv($uRequest, $buffer, $this-bufferSize, 0)){fwrite($fp, $buffer);// buffer pondarray_push ($BufferPond, $buffer);if (count($BufferPond) 3){$dataRead strlen($BufferPond[0]);array_shift($BufferPond);}$Contents join(, $BufferPond);// boundaryif (!$this-Boundary){if (preg_match(/Content-Type: multipart//form-data; boundary[-]{27}(/S)/i, $Contents, $matchesB))$this-Boundary $matchesB[1];}// content lengthif (!$this-ContentLength){if (preg_match(/Content-Length: (/d)/r/n/i, $Contents, $matchesL)){$this-ContentLength $matchesL[1];$this-writeContents($this-tmpPath . $this-processID . .con, $this-ContentLength);if ($this-maxFileSize $this-ContentLength $$maxFileSize * 1024 * 1024){return -106;break;}}}// parse$boundary str_repeat(-, 29) . $this-Boundary;if (strpos($Contents, $boundary)){ preg_match_all(/$boundary/r/nContent-Disposition: form-data; name/([^/]*)/(; filename/([^/]*)//r/nContent-Type: (/S))?/r/n/i, $Contents, $matchesF, PREG_OFFSET_CAPTURE);//print_r($matchesF);if ($matchesF){for ($i 0; $i count($matchesF[0]); $i ){$formIndex $this-checkFormName($matchesF[1][$i][0], $this-formData);if ( $formIndex -1){$this-formData[] array (name $matchesF[1][$i][0],type $matchesF[3][$i] ? file : form,filename $matchesF[3][$i][0],content-type $matchesF[4][$i][0],offset $dataRead $matchesF[0][$i][1],full $matchesF[0][$i][0]);if ($matchesF[3][$i]){$clientArray new Array(/ . $matchesF[1][$i][0] . /,/ . $this-getBaseName($matchesF[3][$i][0]) . /,/ . $matchesF[4][$i][0] . /);$this-writeContents($this-tmpPath . $this-processID . .inf, $clientArray);}}}}else{break;}}if ($flag 0){echo socket_strerror(socket_last_error($uSocket));break;}elseif ($flag 0){echo client disconnected;break;}// end of request ?$eof substr($buffer, -4);$las substr($buffer, $this-bufferSize - 4, 4);if ($eof UPU_SOCKET_ENDTAG || (strlen($eof) 4 ($las{strlen($eof) -1} /x0a || $las{strlen($eof) -1} /x00))){break;}$loopTime ;}fclose($fp);$msg ok;socket_write($uRequest, $msg, strlen($msg));socket_close($uRequest);socket_close($uSocket);//print_r($this-fileInfo);//print_r($this-formData);// temp file sizeif (!$this-fileSize filesize($tmpFileName)){return -108;}// temp file read handleif (!$readHandle fopen($tmpFileName, rb)){return -109;}foreach ($this-formData as $k $v){fseek($readHandle, $v[offset] strlen($v[full]) 2);$eOffset $k 1 count($this-formData)? $this-fileSize - 35 - strlen($this-Boundary) : $this-formData[$k 1][offset] - 2;$this-formData[$k][filesize] $eOffset - $v[offset] - strlen($v[full]) - 2;if ($v[type] file){$extension $this-getExtension($v[filename]);$savepath $this-savePath . md5($this-processID . - . $k) . . . $extension;$writeHandle fopen($savepath, wb);fwrite($writeHandle, fread($readHandle,$this-formData[$k][filesize]));fclose($writeHandle);$this-formData[$k][ext] $extension;$this-formData[$k][path] $savepath;}else{$this-formData[$k][value] fread($readHandle, $this-formData[$k][filesize]);}}fclose($readHandle);$form array();foreach ($this-formData as $k $v){if ($v[type] file){$form[$v[name]] array(filename $this-getBaseName($v[filename]),extension $v[ext],clientpath $v[filename],savepath realpath($v[path]),filetype $v[content-type], filesize $v[filesize],extension $v[ext]);}else{$form[$v[name]] $v[value];}}$this-writeContents($this-tmpPath . $this-processID . .frm, serialize($form));sleep(60);unlink($this-tmpPath . $this-processID . .inf);unlink($this-tmpPath . $this-processID . .dat);unlink($this-tmpPath . $this-processID . .con);unlink($this-tmpPath . $this-processID . .srv);}// get socket server ip address and portfunction getSrvAddr(){return $this-getContents($this-tmpPath . $this-processID . .srv);}// get Content Lengthfunction getContentLength(){return $this-getContents($this-tmpPath . $this-processID . .con);}// get file infofunction getFileInfo(){return $this-getContents($this-tmpPath . $this-processID . .inf);}// get uploaded file lengthfunction getUploadedLength(){if (file_exists($this-tmpPath . $this-processID . .dat)){return filesize($this-tmpPath . $this-processID . .dat);}return 0;}function getFormData(){if (file_exists($this-tmpPath . $this-processID . .frm)){return $this-getContents($this-tmpPath . $this-processID . .frm);}return 0;}function writeContents($filename, $contents){$fwriteHandle fopen($filename, w);if (!is_resource($fwriteHandle)){return false;}fwrite($fwriteHandle, $contents);fclose($fwriteHandle);return true;}function getContents($filename){if (file_exists($filename)){$freadHandle fopen($filename, r);if (!is_resource($freadHandle)){return false;}$contents fread($freadHandle, filesize($filename));fclose($freadHandle);return $contents;}return false;}function getBaseName($path){$path str_replace(//, /, $path);return substr($path, strrpos($path, /) 1);}function getExtension($filename){return substr(strrchr($filename, .), 1);}function checkFormName($formName, $arr){foreach ($arr as $k $v){if ($formName $v[name]){return $k;}}return -1;}}?