Added understanding of video codecs, primarily to allow us to determine whether a file is a webm or not, but also to support my forthcoming video transcoding extension
This commit is contained in:
parent
988bc831b2
commit
65aca09203
4 changed files with 22 additions and 1 deletions
|
@ -439,7 +439,7 @@ class Image
|
|||
$database->execute(
|
||||
"UPDATE images SET ".
|
||||
"lossless = :lossless, ".
|
||||
"video = :video, audio = :audio,image = :image, ".
|
||||
"video = :video, video_codec = :video_codec, audio = :audio,image = :image, ".
|
||||
"height = :height, width = :width, ".
|
||||
"length = :length WHERE id = :id",
|
||||
[
|
||||
|
@ -448,6 +448,7 @@ class Image
|
|||
"height" => $this->height ?? 0,
|
||||
"lossless" => $database->scoresql_value_prepare($this->lossless),
|
||||
"video" => $database->scoresql_value_prepare($this->video),
|
||||
"video_codec" => $database->scoresql_value_prepare($this->video_codec),
|
||||
"image" => $database->scoresql_value_prepare($this->image),
|
||||
"audio" => $database->scoresql_value_prepare($this->audio),
|
||||
"length" => $this->length
|
||||
|
|
|
@ -67,6 +67,7 @@ class VideoFileHandler extends DataHandlerExtension
|
|||
if (array_key_exists("streams", $data)) {
|
||||
$video = false;
|
||||
$audio = true;
|
||||
$video_codec = null;
|
||||
$streams = $data["streams"];
|
||||
if (is_array($streams)) {
|
||||
foreach ($streams as $stream) {
|
||||
|
@ -79,6 +80,7 @@ class VideoFileHandler extends DataHandlerExtension
|
|||
break;
|
||||
case "video":
|
||||
$video = true;
|
||||
$video_codec = $stream["codec_name"];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -93,7 +95,15 @@ class VideoFileHandler extends DataHandlerExtension
|
|||
}
|
||||
}
|
||||
$event->image->video = $video;
|
||||
$event->image->video_codec = $video_codec;
|
||||
$event->image->audio = $audio;
|
||||
if($event->image->get_mime()==MimeType::MKV &&
|
||||
($event->image->video_codec == "vp9" ||
|
||||
$event->image->video_codec == "vp8")) {
|
||||
// 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"])) {
|
||||
|
|
|
@ -931,6 +931,13 @@ class Media extends Extension
|
|||
|
||||
$database->begin_transaction();
|
||||
}
|
||||
|
||||
if ($this->get_version(MediaConfig::VERSION) < 3) {
|
||||
$database->execute($database->scoreql_to_sql(
|
||||
"ALTER TABLE images ADD COLUMN video_codec varchar(512) NULL"
|
||||
));
|
||||
$this->set_version(MediaConfig::VERSION, 3);
|
||||
}
|
||||
}
|
||||
|
||||
public static function hex_color_allocate($im, $hex)
|
||||
|
|
|
@ -34,6 +34,9 @@ class CustomViewImageTheme extends ViewImageTheme
|
|||
<br>Filesize: $h_filesize
|
||||
<br>Type: ".$h_type."
|
||||
";
|
||||
if($image->video_codec!=null) {
|
||||
$html .= "<br/>Video Codec: $image->video_codec";
|
||||
}
|
||||
if ($image->length!=null) {
|
||||
$h_length = format_milliseconds($image->length);
|
||||
$html .= "<br/>Length: $h_length";
|
||||
|
|
Reference in a new issue