an array is an array
This commit is contained in:
parent
00d4f9f75c
commit
aae902e44d
1 changed files with 40 additions and 42 deletions
|
@ -66,53 +66,51 @@ class VideoFileHandler extends DataHandlerExtension
|
|||
try {
|
||||
$data = Media::get_ffprobe_data($event->image->get_image_filename());
|
||||
|
||||
if (is_array($data)) {
|
||||
if (array_key_exists("streams", $data)) {
|
||||
$video = false;
|
||||
$audio = false;
|
||||
$video_codec = null;
|
||||
$streams = $data["streams"];
|
||||
if (is_array($streams)) {
|
||||
foreach ($streams as $stream) {
|
||||
if (is_array($stream)) {
|
||||
if (array_key_exists("codec_type", $stream)) {
|
||||
$type = $stream["codec_type"];
|
||||
switch ($type) {
|
||||
case "audio":
|
||||
$audio = true;
|
||||
break;
|
||||
case "video":
|
||||
$video = true;
|
||||
$video_codec = $stream["codec_name"];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (array_key_exists("width", $stream) && !empty($stream["width"])
|
||||
&& is_numeric($stream["width"]) && intval($stream["width"]) > ($event->image->width) ?? 0) {
|
||||
$event->image->width = intval($stream["width"]);
|
||||
}
|
||||
if (array_key_exists("height", $stream) && !empty($stream["height"])
|
||||
&& is_numeric($stream["height"]) && intval($stream["height"]) > ($event->image->height) ?? 0) {
|
||||
$event->image->height = intval($stream["height"]);
|
||||
if (array_key_exists("streams", $data)) {
|
||||
$video = false;
|
||||
$audio = false;
|
||||
$video_codec = null;
|
||||
$streams = $data["streams"];
|
||||
if (is_array($streams)) {
|
||||
foreach ($streams as $stream) {
|
||||
if (is_array($stream)) {
|
||||
if (array_key_exists("codec_type", $stream)) {
|
||||
$type = $stream["codec_type"];
|
||||
switch ($type) {
|
||||
case "audio":
|
||||
$audio = true;
|
||||
break;
|
||||
case "video":
|
||||
$video = true;
|
||||
$video_codec = $stream["codec_name"];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (array_key_exists("width", $stream) && !empty($stream["width"])
|
||||
&& is_numeric($stream["width"]) && intval($stream["width"]) > ($event->image->width) ?? 0) {
|
||||
$event->image->width = intval($stream["width"]);
|
||||
}
|
||||
if (array_key_exists("height", $stream) && !empty($stream["height"])
|
||||
&& is_numeric($stream["height"]) && intval($stream["height"]) > ($event->image->height) ?? 0) {
|
||||
$event->image->height = intval($stream["height"]);
|
||||
}
|
||||
}
|
||||
$event->image->video = $video;
|
||||
$event->image->video_codec = $video_codec;
|
||||
$event->image->audio = $audio;
|
||||
if ($event->image->get_mime()==MimeType::MKV &&
|
||||
VideoContainers::is_video_codec_supported(VideoContainers::WEBM, $event->image->video_codec)) {
|
||||
// WEBMs are MKVs with the VP9 or VP8 codec
|
||||
// For browser-friendliness, we'll just change the mime type
|
||||
$event->image->set_mime(MimeType::WEBM);
|
||||
}
|
||||
}
|
||||
$event->image->video = $video;
|
||||
$event->image->video_codec = $video_codec;
|
||||
$event->image->audio = $audio;
|
||||
if ($event->image->get_mime()==MimeType::MKV &&
|
||||
VideoContainers::is_video_codec_supported(VideoContainers::WEBM, $event->image->video_codec)) {
|
||||
// WEBMs are MKVs with the VP9 or VP8 codec
|
||||
// For browser-friendliness, we'll just change the mime type
|
||||
$event->image->set_mime(MimeType::WEBM);
|
||||
}
|
||||
}
|
||||
if (array_key_exists("format", $data)&& is_array($data["format"])) {
|
||||
$format = $data["format"];
|
||||
if (array_key_exists("duration", $format) && is_numeric($format["duration"])) {
|
||||
$event->image->length = (int)floor(floatval($format["duration"]) * 1000);
|
||||
}
|
||||
}
|
||||
if (array_key_exists("format", $data)&& is_array($data["format"])) {
|
||||
$format = $data["format"];
|
||||
if (array_key_exists("duration", $format) && is_numeric($format["duration"])) {
|
||||
$event->image->length = (int)floor(floatval($format["duration"]) * 1000);
|
||||
}
|
||||
}
|
||||
} catch (MediaException $e) {
|
||||
|
|
Reference in a new issue