/step_one.php

https://bitbucket.org/santafear/converted · PHP · 102 lines · 63 code · 17 blank · 22 comment · 7 complexity · 6cb010ec4c9656367667dde5fef4ed79 MD5 · raw file

  1. <?php
  2. //exemple php /var/www/webroot/converter/step_one.php /home/chroot/user1/home/user1/2 1 2
  3. //exemple php /usr/local/converter/step_one.php /home/katanyou/2 1 2
  4. //exemple php /var/converted/step_one.php /home/katanyou/2 1 2 (in 61.47.40.194)
  5. //https://studio.ving.tv/api/wowza/getftppath
  6. //https://studio.ving.tv/api/wowza/getftppathads/
  7. //https://studio.ving.tv/api/wowza/getpathads/
  8. $folderpath = $argv[1];
  9. $partner_id = $argv[2];
  10. $channel_id = $argv[3];
  11. $ftp_name = "";
  12. $file_src = "";
  13. $file_desc = "";
  14. if ($handle = opendir($folderpath)) {
  15. while (false !== ($file = readdir($handle))) {
  16. //echo $file."\n";
  17. if ($file[0] == ".") {
  18. continue;
  19. }
  20. $ch = curl_init('https://studiov1.ving.tv/api/wowza/createvideo/partner_id/' . $partner_id . '/tv_channel_id/' . $channel_id . '/name/' . basename($file));
  21. // $ch = curl_init('https://studio.ving.tv/api/wowza/createvideo/partner_id/' . $partner_id . '/tv_channel_id/' . $channel_id . '/name/' . basename($file));
  22. // echo 'https://v1.studio.ving.tv/api/wowza/createvideo/partner_id/'. $partner_id .'/tv_channel_id/'. $channel_id .'/name/'. basename($file).'/ftp_name/'.$ftp_name;
  23. echo 'https://studiov1.ving.tv/api/wowza/createvideo/partner_id/'. $partner_id .'/tv_channel_id/'. $channel_id .'/name/'. basename($file);
  24. // $ch = curl_init('https://studio.ving.tv/api/wowza/createvideo/partner_id/'. $partner_id .'/tv_channel_id/'. $channel_id .'/name/'. basename($file).'/ftp_name/'.$ftp_name);
  25. curl_setopt($ch, CURLOPT_HEADER, 0);
  26. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  27. curl_setopt($ch, CURLOPT_VERBOSE, 0);
  28. $json = curl_exec($ch);
  29. print curl_error($ch);
  30. print curl_errno($ch);
  31. curl_close($ch);
  32. $json = trimJson($json);
  33. $data = json_decode($json);
  34. $file_src = null;
  35. for($i = 0; $i<count($data); $i++) {
  36. $status = $data[$i]->status;
  37. $convert_status = $data[$i]->convert_status;
  38. $is_trailer = $data[$i]->is_trailer;
  39. $partner_vdo_id = $data[$i]->partner_vdo_id;
  40. $file_name = $data[$i]->file_name;
  41. $path_name = $data[$i]->path_name;
  42. $file_type = $data[$i]->file_type;
  43. $width = $data[$i]->width;
  44. $height = $data[$i]->height;
  45. $bitrate = $data[$i]->bitrate;
  46. $id = $data[$i]->id;
  47. $length = $data[$i]->length;
  48. $order_no = $data[$i]->order_no;
  49. $path_form = $data[$i]->path_form;
  50. $path_to = $data[$i]->path_to;
  51. //echo "#######====###### status:".$status.", convert_status:" .$convert_status.",is_trailer:".$is_trailer.",partner_vdo_id:".$partner_vdo_id.",file_name:".$file_name.",path_name:".$path_name.",file_type".$file_type.",id:".$id;
  52. $file_src = $path_form;
  53. $file_desc = $path_to . "." . $file_type . "." . $partner_id . "." . $channel_id.".".$id.".".$partner_vdo_id;
  54. if (file_exists($file_src)) {
  55. if (copy($file_src, $file_desc)) {
  56. echo "unlink($file_src);\n";
  57. //unlink($file_src);
  58. /*$ffmpegInstance = new ffmpeg_movie($file_desc);
  59. $length = date('H:i:s', mktime(0, 0, (int) $ffmpegInstance->getDuration(), 0, 0, 0));
  60. $ffmpegInstance->getDuration();
  61. $ffmpegInstance->getFrameCount();
  62. $ffmpegInstance->getFrameRate();
  63. $ffmpegInstance->getFilename();
  64. $height = $ffmpegInstance->getFrameHeight();
  65. $width = $ffmpegInstance->getFrameWidth();
  66. $bitrate = $ffmpegInstance->getBitRate() / 1000;
  67. $filetype = $ffmpegInstance->getVideoCodec();*/
  68. echo 'https://studiov1.ving.tv/api/wowza/updatevideo/id/' . $id . '/status/q';
  69. $ch = curl_init('https://studiov1.ving.tv/api/wowza/updatevideo/id/' . $id . '/status/q');
  70. echo $rec_data = curl_exec($ch);
  71. curl_close($ch);
  72. }
  73. }//end if (file_exists($file_src))
  74. }
  75. echo "unlink($file_src);\n";
  76. unlink($file_src);
  77. }
  78. closedir($handle);
  79. }
  80. exit();
  81. function trimJson($str) {
  82. $pos = strpos($str, "[");
  83. return substr($str, $pos);
  84. }
  85. ?>