How to get Video metadata :: 2018-05-17 18:41:04

This:

require_once ABSPATH . ‘wp-admin/includes/media.php’;
$up_array = wp_upload_dir();
echo “url = “.$up_array[‘url’].”<br/>”; //(current date)// url = http://js.dom/wp-content/uploads/2018/05
echo “baseurl = “.$up_array[‘baseurl’].”<br/>”; // baseurl = http://js.dom/wp-content/uploads
echo “basedir = “.$up_array[‘basedir’].”<br/>”; // basedir = /var/www/js.dom/public_html/wp-content/uploads
echo “subdir = “.$up_array[‘subdir’].”<br/>”; // subdir = /2018/05
echo “path = “.$up_array[‘path’].”<br/>”; // path = /var/www/js.dom/public_html/wp-content/uploads/2018/05
echo “error = “.$up_array[‘error’].”<br/>”; // error =

$uploads = wp_upload_dir();
$uploads_dir = ( $uploads[‘basedir’] . $uploads[‘subdir’] );
$file = $uploads_dir . ‘/Littoral.mov’;

function printArr($k,$v){
if(!is_array($v)):
echo strtoupper($k).” = {$v}<br/>”;
else:

if (current($k) == $v[0]):
echo “<br/>”;
endif;

foreach($v as $vk => $vv):
echo “&emsp;”.strtoupper($vk);
if(!is_array($vv)):
echo ” = “.$vv.”<br/>”;
else:

if (current($vk) == $vv[0]):
echo “<br/>”;
endif;

foreach($vv as $vvk => $vvv):
$temp = (!is_int($vvk))?strtoupper($vvk):”<br/>”.(string)$vvk;
echo “&emsp;&emsp;{$temp} = {$vvv}<br/>”;
endforeach;
endif;
endforeach;
endif;
}

$metadata = array();
if ( ! class_exists( ‘getID3’ ) ) {
require( ABSPATH . WPINC . ‘/ID3/getid3.php’ );
}
$id3 = new getID3();
$data = $id3->analyze( $file );
foreach($data as $key => $value):
printArr($key,$value);
endforeach;

… gave me this:

GETID3_VERSION = 1.9.14-201706111222
FILESIZE = 563235
FILEPATH = /var/www/js.dom/public_html/wp-content/uploads/2018/05
FILENAME = Littoral.mov
FILENAMEPATH = /var/www/js.dom/public_html/wp-content/uploads/2018/05/Littoral.mov
AVDATAOFFSET = 9458
AVDATAEND = 563235
FILEFORMAT = mp4

DATAFORMAT = mp4
CODEC = ISO/IEC 14496-3 AAC
SAMPLE_RATE = 32000
CHANNELS = 2
BITS_PER_SAMPLE = 16
LOSSLESS =
CHANNELMODE = stereo
STREAMS
0 = Array

DATAFORMAT = mpeg4
RESOLUTION_X = 320
RESOLUTION_Y = 240
CODEC = MPEG-4 Video
BITS_PER_SAMPLE = 24
LOSSLESS =
PIXEL_ASPECT_RATIO = 1
FRAME_RATE = 14.985

LANGUAGE
0 = English
ENCODING = UTF-8
MIME_TYPE = video/mp4

HINTING = 1
CONTROLLER = standard
MOOV
HIERARCHY = moov
NAME = moov
SIZE = 9410
OFFSET = 0
SUBATOMS = Array
TIME_SCALE = 32000
DISPLAY_SCALE = 1
VIDEO
RESOLUTION_X = 320
RESOLUTION_Y = 240
CODEC_FOURCC = mp4v
CODEC_FOURCC_LOOKUP =
CODEC = MPEG-4 Video
COLOR_DEPTH = 24
COLOR_DEPTH_NAME = millions (24-bit color)
FRAME_RATE = 14.985
FRAME_COUNT = 184
AUDIO
CODEC = mp4
SAMPLE_RATE = 32000
CHANNELS = 2
BIT_DEPTH = 16
STTS_FRAMECOUNT
0 = 384

1 = 184

2 = 184

3 = 127
FREE
HIERARCHY = free
NAME = free
SIZE = 32
OFFSET = 9410
WIDE
HIERARCHY = wide
NAME = wide
SIZE = 8
OFFSET = 9442
MDAT
HIERARCHY = mdat
NAME = mdat
SIZE = 553785
OFFSET = 9450
ENCODING = UTF-8
PLAYTIME_SECONDS = 12.28
BITRATE = 360766.7752443
PLAYTIME_STRING = 0:12

« »