edit-icon download-icon

Media details

Last Updated: Feb 11, 2018

Back to Overview

  • Overview

    For details about how to install and use the SDK, see Media library SDK-PHP.

    A media set contains an input file and several output files. Besides basic information, an input file contains detailed Media set information. You can query details about the Videos and Screenshots in the output files.

  • Input

    • Media set information

      1. include_once 'aliyun-php-sdk-core/Config.php';
      2. use Mts\Request\V20140618 as Mts;
      3. $accessKeyID = 'test'; // Replace the value with your AccessKeyID
      4. $accessKeySecret = 'test'; // Replace the value with your AccessKeySecret
      5. $profile = DefaultProfile::getProfile('cn-hangzhou',
      6. $accessKeyID,
      7. $accessKeySecret);
      8. $client = new DefaultAcsClient($profile);
      1. function queryMedia($client, $mediaID)
      2. {
      3. $request = new Mts\QueryMediaListRequest();
      4. $request->setAcceptFormat('JSON');
      5. $request->setMediaIds($mediaID);
      6. $request->setIncludeMediaInfo("true");
      7. $response = $client->getAcsResponse($request);
      8. return $response;
      9. }
      10. function printMediaInfo($mediaInfo)
      11. {
      12. print_r('Number of Streams: '.$mediaInfo->{'Format'}->{'NumStreams'}."\n");
      13. if (array_key_exists('Streams', $mediaInfo) &&
      14. array_key_exists('AudioStreamList', $mediaInfo->{'Streams'}) &&
      15. array_key_exists('AudioStream', $mediaInfo->{'Streams'}->{'AudioStreamList'})) {
      16. $audioStreams = $mediaInfo->{'Streams'}->{'AudioStreamList'}->{'AudioStream'};
      17. print_r('Audio Streams:'."\n");
      18. for ($i = 0; $i < count($audioStreams); $i++) {
      19. print_r("\t[".$i."]"."\n");
      20. print_r("\t\tCodecName: ".$audioStreams[$i]->{'CodecName'}."\n");
      21. print_r("\t\tChannels: ".$audioStreams[$i]->{'Channels'}."\n");
      22. print_r("\t\tSamplerate: ".$audioStreams[$i]->{'Samplerate'}."\n");
      23. print_r("\t\tDuration: ".$audioStreams[$i]->{'Duration'}."\n");
      24. print_r("\t\tBitrate: ".$audioStreams[$i]->{'Bitrate'}."\n");
      25. }
      26. }
      27. if (array_key_exists('Streams', $mediaInfo) &&
      28. array_key_exists('VideoStreamList', $mediaInfo->{'Streams'}) &&
      29. array_key_exists('VideoStream', $mediaInfo->{'Streams'}->{'VideoStreamList'})) {
      30. $videoStreams = $mediaInfo->{'Streams'}->{'VideoStreamList'}->{'VideoStream'};
      31. print_r('Video Streams:'."\n");
      32. for ($i = 0; $i < count($videoStreams); $i++) {
      33. print_r("\t[".$i."]"."\n");
      34. print_r("\t\tCodecName: ".$videoStreams[$i]->{'CodecName'}."\n");
      35. print_r("\t\tProfile: ".$videoStreams[$i]->{'Profile'}."\n");
      36. print_r("\t\tDuration: ".$videoStreams[$i]->{'Duration'}."\n");
      37. print_r("\t\tPixFmt: ".$videoStreams[$i]->{'PixFmt'}."\n");
      38. print_r("\t\tFps: ".$videoStreams[$i]->{'Fps'}."\n");
      39. print_r("\t\tBitrate: ".$videoStreams[$i]->{'Bitrate'}."\n");
      40. print_r("\t\tResolution: ".$videoStreams[$i]->{'Width'}.'x'.$videoStreams[$i]->{'Height'}."\n");
      41. }
      42. }
      43. }
      44. $mediaID = 'test'; // Replace the value with your desired media ID
      45. $medias = queryMedia($client, $mediaID)->{'MediaList'}->{'Media'};
      46. for ($i = 0; $i < count($medias); $i++) {
      47. printMediaInfo($medias[$i]->{'MediaInfo'});
      48. }
  • Output

    • Videos

      1. function queryMedia($client, $mediaID)
      2. {
      3. $request = new Mts\QueryMediaListRequest();
      4. $request->setAcceptFormat('JSON');
      5. $request->setMediaIds($mediaID);
      6. $request->setIncludePlayList("true");
      7. $response = $client->getAcsResponse($request);
      8. return $response;
      9. }
      10. function printOutputVideos($videos)
      11. {
      12. print_r('Number of Output Video: '.count($videos)."\n");
      13. for ($i = 0; $i < count($videos); $i++) {
      14. print_r("\t[".$i."]"."\n");
      15. print_r("\t\tMediaWorkflowName: ".$videos[$i]->{'MediaWorkflowName'}."\n");
      16. print_r("\t\tActivityName: ".$videos[$i]->{'ActivityName'}."\n");
      17. print_r("\t\tFormat: ".$videos[$i]->{'Format'}."\n");
      18. print_r("\t\tDuration: ".$videos[$i]->{'Duration'}."\n");
      19. print_r("\t\tFps: ".$videos[$i]->{'Fps'}."\n");
      20. print_r("\t\tBitrate: ".$videos[$i]->{'Bitrate'}."\n");
      21. print_r("\t\tSize: ".$videos[$i]->{'Size'}."\n");
      22. print_r("\t\tResolution: ".$videos[$i]->{'Width'}.'x'.$videos[$i]->{'Height'}."\n");
      23. print_r("\t\tURL: ".$videos[$i]->{'File'}->{'URL'}."\n");
      24. }
      25. }
      26. $mediaID = 'test'; // Replace the value with your desired media ID
      27. $medias = queryMedia($client, $mediaID)->{'MediaList'}->{'Media'};
      28. for ($i = 0; $i < count($medias); $i++) {
      29. printOutputVideos($medias[$i]->{'PlayList'}->{'Play'});
      30. }
    • Screenshots

      1. function queryMedia($client, $mediaID)
      2. {
      3. $request = new Mts\QueryMediaListRequest();
      4. $request->setAcceptFormat('JSON');
      5. $request->setMediaIds($mediaID);
      6. $request->setIncludeSnapshotList("true");
      7. $response = $client->getAcsResponse($request);
      8. return $response;
      9. }
      10. function printOutputSnapshots($snapshots)
      11. {
      12. print_r('Number of Output Snapshot: '.count($snapshots)."\n");
      13. for ($i = 0; $i < count($snapshots); $i++) {
      14. print_r("\t[".$i."]"."\n");
      15. print_r("\t\tMediaWorkflowName: ".$snapshots[$i]->{'MediaWorkflowName'}."\n");
      16. print_r("\t\tActivityName: ".$snapshots[$i]->{'ActivityName'}."\n");
      17. print_r("\t\tType: ".$snapshots[$i]->{'Type'}."\n");
      18. print_r("\t\tCount: ".$snapshots[$i]->{'Count'}."\n");
      19. print_r("\t\tURL: ".$snapshots[$i]->{'File'}->{'URL'}."\n");
      20. }
      21. }
      22. $mediaID = 'test'; // Replace the value with your desired media ID
      23. $medias = queryMedia($client, $mediaID)->{'MediaList'}->{'Media'};
      24. for ($i = 0; $i < count($medias); $i++) {
      25. printOutputSnapshots($medias[$i]->{'SnapshotList'}->{'Snapshot'});
      26. }
Thank you! We've received your feedback.