사이트 내 전체검색
그누보드
sir.뮤죤님 팁: 스트리밍서버에 ftp 접송 개념 / ffmpeg 동영상 이미지 캡쳐 및 스트리밍서버로 데이타 전송하기
로빈아빠
https://cmd.kr/gnu/86 URL이 복사되었습니다.

본문

http://sir.co.kr/bbs/board.php?bo_table=g4_tiptech&wr_id=11517

요즘 동영상 관련되서  ㅡ,,ㅡ .
 
**   그누보드 게시판을 이용,  동영상미디어 파일을 스트리밍서버에 업로드하고 자동 리턴값을 반환하는원리
 
1. write.skin.php  에서 ..
 
//수정이 아닌경우만 랜덤 아이디값 생성
if($w !== "u"){
  if($randumid == ""){
   $randumid = time();
   $randumid = substr("$randumid$randumid", 1, 16);
  }
}
else{
  $RanID = $write[wr_5];  // 수정 변경인 경우 기존의 랜덤값을 유지 한다.
  }
?>
<form enctype="multipart/form-data"  action="result.php" method="post">
<!---------ucc--------->
<input type=hidden name="randumid"     value="<?=$randumid?>">
<!--------업로드고유값--->
<input type=hidden name="connect_id"        value="20070606">
<input type=file name="userfile" >
<input type="submit" value="업로드">
</form>
 
-----------------------------------------------------
 
2. 스트리밍서버값에서 처리할 내용 (기본적사항들)
 
<?
//파일의 기본값정보
 $upfile_name  =  $_FILES['userfile']['name'];    //업로드 실재이름
 $upfile_tmp   =  $_FILES['userfile']['tmp_name']; //임시저장값경로
 $upfile_size  =  $_FILES['userfile'][size];   //파일용량
 $randumid     =  $_POST['randumid'];    //무작의 생성 랜덤값

//접속 고유번호,  1차 검증
 $connect_id   =  $_POST['connect_id']; 
 //고유값을 여러군데 확장할경우 아래부분을 수정하시면 됩니다.
 if($connect_id !== '20070606'){
      die("허용되지 않은 번호입니다. 관리자에게 문의하세요");  //접속실패시
 }
//생성된 랜덤값을 되돌려줄경로,  여러군데서 사용시에는 아래를 db data 처리하시면 됩니다
 if($connect_id == '20070606'){
      $return_url = "http://www.fla013.cafe79.net/ucc_pass.php"; 
 }

$file     = $_FILES['userfile']['tmp_name'];  //업로드시킬 임시경로
$fp       = fopen($file, 'r');    
  
 ####################기본적 수정할 내용########################
//자신의 계정에 맞는 ftp 경로
 $ftp_server       = "";  //접속ip 주소
 $ftp_user_name    = "";    //접속 id
 $ftp_user_pass    = "";    //접속 pw
 $server_port      = 21;              //접속 prot
//스트리밍 서버의 저장경로 지정
$server_dir        = "/exschool/file_upload";  // 자신의 환경에 맞게 수정하세요.
#################################################################

//원결연결시도
$connet_ftp  = ftp_connect($ftp_server, $server_port);
if(!$connet_ftp)
    die("$ftp_server 접속에 실패하였습니다");  //접속실패시

//ftp 로그인 시도
$connet_login  =   ftp_login($connet_ftp, $ftp_user_name, $ftp_user_pass);
if(!$connet_login)
    die(" $ftp_user_name 접속정보가 일치하지 않습니다.");
 
ftp_chdir($connet_ftp, $server_dir);
 
//파일을 업로드 한다.  파일명을 랜덤값으로 처리 저장하므로 중복값이 발생되지 않음
$ftp_result = ftp_put($connet_ftp, $randumid, $_FILES['userfile']['tmp_name'], FTP_BINARY);

//업로드가 성공적이라면 리턴값을 보냄
if($ftp_result){?>
<form enctype="multipart/form-data"  action="<?=$return_url?>" method="post">
<!---------결과값이 성공한경우--------->
<input type=hidden name="pass_ok"     value="123456789">
<!--------업로드고유값--->
<input type=hidden name="home_url"        value="<?=$return_url?>">

<input type="submit" value="업로드">
</form>
  <?}
else{
  echo '실패';
  }
//FTP를 닫는다
ftp_quit($connet_ftp);
?>

-----------------------------------------------------

 

ffmpeg를 이용해서 동영상이미지 캡쳐및 스트리밍서버로 데이타 전송하기입니다.

** 기본적 플로우 **

동영상파일 -->> 임시디렉토리에 업로드 -->> 동영상 변환 및 영상캡쳐

-->> 스트리밍서버접속 및 동영상 이전 -->> 임시디렉토리파일 삭제

-->> 전송할 디렉토리파일정보를 웹서버에 저장.

----------------------전송플로우입니다.----------------------

<?php
    // Handle the file and return the file identifier to the SWF
 if (isset($_FILES["resume_file"]) && isset($_FILES["resume_file"]["name"])) {
  //echo $_FILES["resume_file"]["name"];
  
/*************************************************************************/
 /**********************디렉토리에 업로드할경우*******************************/

 //$upload_path = str_replace("\\", "/", realpath(dirname($_SERVER['scRIPT_FILENAME']))) . "/uploads/";
 $upload_path = "uploads/";

  $ext = strtolower(substr(strrchr($_FILES["resume_file"]["name"],"."), 1)); //확장자

//세팅할 파일명
 $seting_name  = "";
 $seting_name .= time();
 $seting_name .= time();
 $seting_name .= ".".$ext;
 


 //세팅할 주소
 $seting_path  = $upload_path;
 $seting_path .= $seting_name;
 
/****************************
 // Handle the upload
 if (!move_uploaded_file($_FILES["resume_file"]["tmp_name"], $seting_path)) {
  header("HTTP/1.0 500 Internal Server Error");
 }
 ************************8/


 
 // Delete the file.  We don't want it.
 //@unlink($upload_path . $_FILES["Filedata"]["name"]);
 
 /***************************디렉토리 업로드 끝**********************************/


/***********************************동영상변환************************/

  //$in_file  = "2.wmv";
  $in_file  = $_FILES["resume_file"]["tmp_name"];
  $out_name  = time();
  $out_name .= time();

  $rr_path     = "/home/seumi/www/upload2/uploads/";
  $o_i_path    =  $rr_path;
  $o_i_path   .=  $out_name;

 

  exec("/home/seumi/www/ffmpeg/ffmpeg/ffmpeg -i $in_file -an -ss 00:00:14 -an -r 2 -vframes 1 -y $o_i_path%d.jpg ", $output, $error);

//에러가 없다면
   if(!$error){
    $creat_img   = $out_name;
    $creat_img  .= 1;
    $creat_img  .= ".jpg";

  }
  else{
  header("HTTP/1.0 500 Internal Server Error");
  }

/***********************************동영상변환************************/

 

//접속할 서버

 $ftp_server = "접속할아이피주소";
 $ftp_user_name = "계정이름";
 $ftp_user_pass = "계정패스워드";
 $server_port = 21; //포트

 $r_path  = $in_file;

  $ext = strtolower(substr(strrchr($_FILES["resume_file"]["name"],"."), 1)); //확장자

//세팅할 파일명
 $seting_name  = "";
 $seting_name .= time();
 $seting_name .= time();
 $seting_name .= ".".$ext;

$fp              = fopen($r_path, 'r');
     if (!$fp)
    {
  header("HTTP/1.0 500 Internal Server Error");
    }
   
   
//원격서버에 연결한다.
if(!($fc = ftp_connect($ftp_server, $server_port)))
    die("$server_host : $server_post - connect failed");

//원격서버에 로그인한다.
if(!ftp_login($fc, $ftp_user_name, $ftp_user_pass))
    die("$server_id - login failed");

//디렉토리로 이동
$server_dir  = "/동영상업로드할경로/";
$f_chdir     = ftp_chdir($fc, $server_dir);

   /*
   if (!$f_chdir)
    {
       alert("접속서버 디렉토리변경 실패");
    }
 */

//파일을 업로드 한다.
$ftp_result = ftp_put($fc, $seting_name , $r_path, FTP_BINARY);

 // Delete the file.  We don't want it.
 @unlink($upload_path . $seting_name);
 @unlink($upload_path . $ch_file);
/*************************************************************************/
  
  echo $seting_name;
  echo "|";
  echo $creat_img;
  echo "|";
  echo $file_size;
  echo "|";
  echo $file_type;

  
 } else {
  echo ' ';
 }
?>

-------------------------------------

해당결과물정보를 그누보드 게시판 여분필드에 저장하세요.

댓글목록

등록된 댓글이 없습니다.

그누보드
190 (3/4P)

Search

Copyright © Cmd 명령어 3.145.72.5