mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
metadata extraction ffmpeg -> mediainfo
This commit is contained in:
@@ -3586,6 +3586,17 @@ $collections = [
|
||||
'array' => false,
|
||||
'filters' => [],
|
||||
],
|
||||
[
|
||||
'$id' => 'format',
|
||||
'type' => Database::VAR_STRING,
|
||||
'format' => '',
|
||||
'size' => Database::LENGTH_KEY,
|
||||
'signed' => true,
|
||||
'required' => false,
|
||||
'default' => null,
|
||||
'array' => false,
|
||||
'filters' => [],
|
||||
],
|
||||
[
|
||||
'$id' => 'duration',
|
||||
'type' => Database::VAR_STRING,
|
||||
@@ -3620,7 +3631,29 @@ $collections = [
|
||||
'filters' => [],
|
||||
],
|
||||
[
|
||||
'$id' => 'videoCodec',
|
||||
'$id' => 'aspectRatio',
|
||||
'type' => Database::VAR_STRING,
|
||||
'format' => '',
|
||||
'size' => Database::LENGTH_KEY,
|
||||
'signed' => true,
|
||||
'required' => false,
|
||||
'default' => null,
|
||||
'array' => false,
|
||||
'filters' => [],
|
||||
],
|
||||
[
|
||||
'$id' => 'videoFormat',
|
||||
'type' => Database::VAR_STRING,
|
||||
'format' => '',
|
||||
'size' => Database::LENGTH_KEY,
|
||||
'signed' => true,
|
||||
'required' => false,
|
||||
'default' => null,
|
||||
'array' => false,
|
||||
'filters' => [],
|
||||
],
|
||||
[
|
||||
'$id' => 'videoFormatProfile',
|
||||
'type' => Database::VAR_STRING,
|
||||
'format' => '',
|
||||
'size' => Database::LENGTH_KEY,
|
||||
@@ -3642,7 +3675,7 @@ $collections = [
|
||||
'filters' => [],
|
||||
],
|
||||
[
|
||||
'$id' => 'videoFramerate',
|
||||
'$id' => 'videoFrameRateMode',
|
||||
'type' => Database::VAR_STRING,
|
||||
'format' => '',
|
||||
'size' => Database::LENGTH_KEY,
|
||||
@@ -3653,7 +3686,18 @@ $collections = [
|
||||
'filters' => [],
|
||||
],
|
||||
[
|
||||
'$id' => 'audioCodec',
|
||||
'$id' => 'videoFrameRate',
|
||||
'type' => Database::VAR_STRING,
|
||||
'format' => '',
|
||||
'size' => Database::LENGTH_KEY,
|
||||
'signed' => true,
|
||||
'required' => false,
|
||||
'default' => null,
|
||||
'array' => false,
|
||||
'filters' => [],
|
||||
],
|
||||
[
|
||||
'$id' => 'audioFormat',
|
||||
'type' => Database::VAR_STRING,
|
||||
'format' => '',
|
||||
'size' => Database::LENGTH_KEY,
|
||||
@@ -3675,7 +3719,7 @@ $collections = [
|
||||
'filters' => [],
|
||||
],
|
||||
[
|
||||
'$id' => 'audioSamplerate',
|
||||
'$id' => 'audioSampleRate',
|
||||
'type' => Database::VAR_STRING,
|
||||
'format' => '',
|
||||
'size' => Database::LENGTH_KEY,
|
||||
|
||||
+19
-25
@@ -120,43 +120,37 @@ class TranscodingV1 extends Worker
|
||||
$mediaInfo = new MediaInfo();
|
||||
$mediaInfoContainer = $mediaInfo->getInfo($inPath);
|
||||
$general = $mediaInfoContainer->getGeneral();
|
||||
$this->video->
|
||||
setAttribute('duration', strval($general->get('duration')->getMilliseconds()));
|
||||
$this->video
|
||||
->setAttribute('duration', strval($general->get('duration')->getMilliseconds()))
|
||||
->setAttribute('format', $general->get('format')->getShortName());
|
||||
|
||||
var_dump($general->get('duration')->getMilliseconds());
|
||||
var_dump($general->get('overall_bit_rate')->getShortName());
|
||||
|
||||
$videos = $mediaInfoContainer->getVideos();
|
||||
foreach ($videos as $video) {
|
||||
foreach ($mediaInfoContainer->getVideos() ?? [] as $video) {
|
||||
$this->video
|
||||
->setAttribute('height', $video->get('height')->getAbsoluteValue())
|
||||
->setAttribute('width', $video->get('width')->getAbsoluteValue())
|
||||
->setAttribute('videoCodec', strval($video->get('format')->getShortName()))
|
||||
->setAttribute('videoFramerate', strval($video->get('frame_rate')->getAbsoluteValue()))
|
||||
->setAttribute('aspectRatio', $video->get('display_aspect_ratio')->getTextValue())
|
||||
->setAttribute('videoFormat', $video->get('format')->getShortName())
|
||||
->setAttribute('videoFormatProfile', $video->get('video_format_profile'))
|
||||
->setAttribute('videoFrameRate', strval($video->get('frame_rate')->getAbsoluteValue()))
|
||||
->setAttribute('videoFrameRateMode', $video->get('frame_rate_mode')->getFullName())
|
||||
->setAttribute('videoBitrate', strval($video->get('bit_rate')->getAbsoluteValue()));
|
||||
|
||||
var_dump($video->get('format_profile'));
|
||||
var_dump($video->get('frame_rate_mode')->getFullName());
|
||||
var_dump($video->get('display_aspect_ratio')->getTextValue());
|
||||
}
|
||||
|
||||
$audios = $mediaInfoContainer->getAudios();
|
||||
|
||||
foreach ($audios as $audio) {
|
||||
foreach ($mediaInfoContainer->getAudios() ?? [] as $audio) {
|
||||
$this->video
|
||||
->setAttribute('audioCodec', strval($audio->get('format')->getShortName()))
|
||||
->setAttribute('audioSamplerate', strval($audio->get('frame_rate')->getAbsoluteValue()))
|
||||
->setAttribute('audioFormat', strval($audio->get('format')->getShortName()))
|
||||
->setAttribute('audioSampleRate', strval($audio->get('sampling_rate')->getAbsoluteValue()))
|
||||
->setAttribute('audioBitrate', strval($audio->get('bit_rate')->getAbsoluteValue()));
|
||||
}
|
||||
|
||||
console::info('Input video id:' . $this->video->getId() . PHP_EOL .
|
||||
console::info('Input video id: ' . $this->video->getId() . PHP_EOL .
|
||||
'Input name: ' . $this->file->getAttribute('name') . PHP_EOL .
|
||||
'Input width: ' . $this->video->getAttribute('width') . PHP_EOL .
|
||||
'Input height: ' . $this->video->getAttribute('height') . PHP_EOL .
|
||||
'Input duration: ' . $this->video->getAttribute('duration') . PHP_EOL .
|
||||
'Input size: ' . $this->video['size'] . PHP_EOL .
|
||||
'Input videoBitrate: ' . $this->video->getAttribute('videoBitrate') . PHP_EOL .
|
||||
'Input audioBitrate: ' . $this->video->getAttribute('audioBitrate') . PHP_EOL);
|
||||
'Input width: ' . $this->video->getAttribute('width') . ' px' . PHP_EOL .
|
||||
'Input height: ' . $this->video->getAttribute('height') . ' px' . PHP_EOL .
|
||||
'Input duration: ' . ($this->video->getAttribute('duration') / 1000) . ' sec' . PHP_EOL .
|
||||
'Input size: ' . ($this->video->getAttribute('size') / 1024 / 1024) . ' MiB' . PHP_EOL .
|
||||
'Input videoBitrate: ' . ($this->video->getAttribute('videoBitrate') / 1000) . ' b/s' . PHP_EOL .
|
||||
'Input audioBitrate: ' . ($this->video->getAttribute('audioBitrate') / 1000) . ' b/s');
|
||||
|
||||
$this->database->updateDocument('videos', $this->video->getId(), $this->video);
|
||||
$media = $this->ffmpeg->open($inPath);
|
||||
|
||||
@@ -31,9 +31,21 @@ class Video extends Model
|
||||
->addRule('size', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'File size.',
|
||||
'default' => '',
|
||||
'default' => 0,
|
||||
'example' => 23647142,
|
||||
])
|
||||
->addRule('format', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Format.',
|
||||
'default' => '',
|
||||
'example' => 'MPEG-4',
|
||||
])
|
||||
->addRule('aspectRatio', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Aspect ratio .',
|
||||
'default' => '',
|
||||
'example' => '16:9',
|
||||
])
|
||||
->addRule('duration', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'require' => false,
|
||||
@@ -55,16 +67,23 @@ class Video extends Model
|
||||
'default' => 0,
|
||||
'example' => 544,
|
||||
])
|
||||
->addRule('videoCodec', [
|
||||
->addRule('videoFormat', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'require' => false,
|
||||
'description' => 'Video codec.',
|
||||
'default' => null,
|
||||
'example' => 'h264,avc1',
|
||||
'description' => 'Video format.',
|
||||
'default' => '',
|
||||
'example' => 'AVC',
|
||||
])
|
||||
->addRule('videoFormatProfile', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'require' => false,
|
||||
'description' => 'Video format profile.',
|
||||
'default' => '',
|
||||
'example' => 'Baseline@L3.1',
|
||||
])
|
||||
->addRule('videoBitrate', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'require' => false,
|
||||
'require' => false,
|
||||
'description' => 'Video bitrate.',
|
||||
'default' => 0,
|
||||
'example' => 564790,
|
||||
@@ -76,12 +95,12 @@ class Video extends Model
|
||||
'default' => 0,
|
||||
'example' => '231947377/4638947',
|
||||
])
|
||||
->addRule('audioCodec', [
|
||||
->addRule('audioFormat', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'require' => false,
|
||||
'description' => 'Audio codec.',
|
||||
'default' => null,
|
||||
'example' => 'aac,mp4a',
|
||||
'description' => 'Audio format.',
|
||||
'default' => '',
|
||||
'example' => 'AAC',
|
||||
])
|
||||
->addRule('audioBitrate', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
@@ -90,7 +109,7 @@ class Video extends Model
|
||||
'default' => 0,
|
||||
'example' => 127999,
|
||||
])
|
||||
->addRule('audioSamplerate', [
|
||||
->addRule('audioSampleRate', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'require' => false,
|
||||
'description' => 'Audio sample rate.',
|
||||
|
||||
Reference in New Issue
Block a user