[FFmpeg]ffmpeg基于phpcms程序的在线转换视频exec函数版
程序为phpcms,你可以修改下做到你的项目中.此为在线转换,非上一版本的bat批处理版
[FFmpeg]ffmpeg基于phpcms程序的在线转换视频exec函数版
程序为phpcms,你可以修改下做到你的项目中.此为在线转换,非上一版本的bat批处理版
- <?php
- require dirname(__FILE__).'/include/common.inc.php';
- if($PHPSESSID)
- {
- session_id($PHPSESSID);
- session_start();
- }
- if($auth) set_cookie('auth', $auth);
- if(!get_cookie('cookietime') && $cookietime) set_cookie('cookietime', $cookietime);
- require_once 'admin/model_field.class.php';
- $field = new model_field($modelid);
- $info = $field->get($fieldid);
- if(!$info) showmessage('指定的字段不存在!');
- $upload_allowext = $info['upload_allowext'];
- $upload_maxsize = $info['upload_maxsize']*1024;
- require_once 'attachment.class.php';
- $attachment = new attachment();
- if($dosubmit)
- {
- $aid = $attachment->upload('Filedata', $upload_allowext, $upload_maxsize);
- if($aid)
- {
- $filename = $attachment->uploadedfiles[0]['filename'];
- $fileurl = UPLOAD_URL.$attachment->uploadedfiles[0]['filepath'];
- $houzhui = $attachment->uploadedfiles[0]['fileext'];
- /* if($houzhui == 'rmvb' || $houzhui == 'rm'){
- exit($filename.'|'.$fileurl);
- }*/
- if($houzhui != 'flv')
- {
- $mpeg = PHPCMS_ROOT."FFmpeg/ffmpeg.exe";
- $fromFile = PHPCMS_ROOT.$fileurl;
- //$time = date("Y",TIME).'/'.date("md",TIME).'/';
- $file = $attachment->uploadedfiles[0]['filepath'];
- $name = explode('.',$file);
- $filename1 = $name[0];
- $flvName = PHPCMS_ROOT.UPLOAD_URL.$filename1.".flv";
- $flvWith = 320;
- $flvHeight = 240;
- set_time_limit(0);
- exec("$mpeg -i $fromFile -y -ab 28 -ar 22050 -b 200000 -r 24 -s $flvWith*$flvHeight $flvName",$mStatus,$status);
- $image = PHPCMS_ROOT.UPLOAD_URL.$filename1.".jpg";
- exec("$mpeg -i $fromFile -y -ss 00:00:01 -t 00:00:02 -f image2 -vframes 10 $image");
- if($status == 0){
- unlink(PHPCMS_ROOT.$fileurl);
- exit($filename.'|'.UPLOAD_URL.$filename1.".flv$".UPLOAD_URL.$filename1.".jpg");
- }
- else{
- exit("sorry!Conversion failed!!");
- }
- }
- else{
- exit($filename.'|'.$fileurl);
- }
- }
- else
- {
- if (isset($_FILES["Filedata"])) {
- echo $_FILES["Filedata"]["error"];
- exit;
- }
- }
- }
- else
- {
- include template('phpcms','flash_upload');
- }
- ?>
主要看思路哈.说实话,php的exec相当难用,涉及到系统权限等一大堆乱七八糟的东西.有时候真是让人崩溃,最近严重崩溃中,把以前一个项目的代码拷贝来,防止电脑挂了或者电脑没在身边的时候看看.也给大家参考下,有不对的地方还望斧正.
热门文章推荐
- [FFmpeg]ffmpeg各类参数说明与使用示例
- [FFmpeg]ffmpeg命令参数详解(帮助说明)强大所有参数
- [ffmpeg]FFmpeg参数命令及用法整理(很全面详细)
- [FFmpeg]图文介绍windows下实现编译ffmpeg工程的详细步骤
- [ffmpeg]ffmpeg使用参数的中文说明
- [ffmpeg]如何使用ffmpeg下载分段并加密的m3u8视频流
- [FFmpeg]php下用ffmpeg扩展实现视频转换截图
- [FFmpeg]ffmpeg支持的格式全解析
请稍候...