1
+ <?php
2
+ require_once __DIR__ . '/../autoload.php ' ;
3
+
4
+ use Qencode \Exceptions \QencodeApiException ;
5
+ use Qencode \Exceptions \QencodeClientException ;
6
+ use Qencode \Exceptions \QencodeException ;
7
+ use Qencode \QencodeApiClient ;
8
+ use Qencode \Classes \Metadata ;
9
+
10
+ // Replace this with your API key
11
+ $ apiKey = '5a2a846a26ace ' ;
12
+ $ video_url = 'https://sinpartyapi.com/storage/bd6c4463-8c01-42fc-b86f-c19369565ae9-64663ea162a716.638146551684422305.mov ' ;
13
+
14
+ $ url = 'https://prod-europe-west1-d-1-api-gcp.qencode.com/ ' ;
15
+ //$url = 'https://prod-us-central1-a-1-api-gcp.qencode.com/';
16
+
17
+ $ q = new QencodeApiClient ($ apiKey , $ url );
18
+
19
+ try {
20
+ //log_message('Getting metadata for: '.$video_url.' ...');
21
+ $ video_info = $ q ->getMetadata ($ video_url );
22
+ echo "\nVideo info " ;
23
+ list ($ width , $ height ) = Metadata::get_video_dimensions ($ video_info );
24
+ log_message ('width, px: ' .$ width );
25
+ log_message ('height, px: ' .$ height );
26
+
27
+ $ bitrate = Metadata::get_bitrate ($ video_info );
28
+ log_message ('bitrate, b/s: ' .$ bitrate );
29
+
30
+ $ framerate = Metadata::get_framerate ($ video_info );
31
+ log_message ('framerate, fps: ' .$ framerate );
32
+
33
+ $ duration = Metadata::get_duration ($ video_info );
34
+ log_message ('duration, sec: ' .$ duration );
35
+ //echo "DONE!";
36
+
37
+ } catch (QencodeClientException $ e ) {
38
+ // We got some inconsistent state in client application (e.g. task_token not found when requesting status)
39
+ log_message ('Qencode Client Exception: ' . $ e ->getCode () . ' ' . $ e ->getMessage ());
40
+ } catch (QencodeApiException $ e ) {
41
+ // API response status code was not successful
42
+ log_message ('Qencode API Exception: ' . $ e ->getCode () . ' ' . $ e ->getMessage ());
43
+ } catch (QencodeException $ e ) {
44
+ // API call failed
45
+ log_message ('Qencode Exception: ' . $ e ->getMessage ());
46
+ var_export ($ q ->getLastResponseRaw ());
47
+ }
48
+
49
+ function log_message ($ msg ) {
50
+ echo $ msg ."\n" ;
51
+ }
0 commit comments