Skip to content

Commit

Permalink
feat: Get MP4 properties with asset.video (#1761)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudLigny committed Aug 16, 2023
1 parent 9091dda commit 7de030d
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 1 deletion.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"ext-gd": "*",
"ext-mbstring": "*",
"benjaminhoegh/parsedown-toc": "1.4.3",
"clwu/php-read-mp4info": "^2.0",
"cocur/slugify": "^4.4",
"dflydev/dot-access-data": "^3.0",
"erusev/parsedown-extra": "^0.8",
Expand Down
52 changes: 51 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions src/Assets/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,20 @@ public function getAudio(): Mp3Info
return new Mp3Info($this->data['file']);
}

/**
* Returns MP4 file infos.
*
* @see https://github.com/clwu88/php-read-mp4info
*/
public function getVideo(): array
{
if ($this->data['type'] !== 'video') {
throw new RuntimeException(sprintf('Not able to get video infos of "%s"', $this->data['path']));
}

return \Clwu\Mp4::getInfo($this->data['file']);
}

/**
* Returns the data URL (encoded in Base64).
*
Expand Down

0 comments on commit 7de030d

Please sign in to comment.