TestController.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: PHP
  5. * Date: 2016/12/15
  6. * Time: 13:13
  7. */
  8. Yii::import('application.vendor.qiniu.src.Qiniu.*',1);
  9. class TestController extends AdminController {
  10. public function actionIndex()
  11. {
  12. $accessKey = 'Kn8GNMFOLKTNMUaKZ6r1wnjsgTk4ideQifK3umUr';
  13. $secretKey = 'mLtD4GhBjQt_llcgx4rKlhAts9j8iJ0Qa5VmNyi2';
  14. $auth = new Qiniu\Auth($accessKey, $secretKey);
  15. var_dump($secretKey);exit;
  16. $bucket = 'video';
  17. $key = 'af_055bd00624e2981480363953002.mp4';
  18. $pfop = new PersistentFop($auth, $bucket);
  19. $fops = "?vframe/jpg/offset/1";
  20. list($id, $error) = $pfop->execute($key, $fops);
  21. echo "2";
  22. var_dump($id);
  23. $this->assertNull($error);
  24. list($status, $error) = PersistentFop::status($id);
  25. $this->assertNotNull($status);
  26. $this->assertNull($error);
  27. }
  28. public function actionIndex1(){
  29. $accessKey = 'H1mZo5YAluX1n3Ic_gWFzQFAty0DedVK24gYWbvq';
  30. $secretKey = 'Kod0wn_TWOAzFe4WJedhvVHu2CzRC_R3GtpRTPiV';
  31. $auth = new Qiniu\Auth($accessKey, $secretKey);
  32. //要转码的文件所在的空间和文件名
  33. $bucket = 'video';
  34. $key = 'af_055bd00624e2981480363953002.mp4';
  35. //转码是使用的队列名称
  36. $pipeline = '';
  37. $pfop = new PersistentFop($auth, $bucket, $pipeline);
  38. //要进行转码的转码操作
  39. $fops = "vframe/jpg/offset/1";
  40. list($id, $err) = $pfop->execute($key, $fops);
  41. echo "\n====> pfop avthumb result: \n";
  42. if ($err != null) {
  43. var_dump($err);
  44. } else {
  45. echo "PersistentFop Id: $id\n";
  46. }
  47. //查询转码的进度和状态
  48. list($ret, $err) = $pfop->status($id);
  49. echo "\n====> pfop avthumb status: \n";
  50. if ($err != null) {
  51. var_dump($err);
  52. } else {
  53. var_dump($ret);
  54. }
  55. }
  56. }