|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* (c) Kitodo. Key to digital objects e.V. <[email protected]> |
|
5
|
|
|
* |
|
6
|
|
|
* This file is part of the Kitodo and TYPO3 projects. |
|
7
|
|
|
* |
|
8
|
|
|
* @license GNU General Public License version 3 or later. |
|
9
|
|
|
* For the full copyright and license information, please read the |
|
10
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace Kitodo\Dlf\Format; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Process AudioMD and VideoMD metadata. |
|
17
|
|
|
* |
|
18
|
|
|
* The technical reason for handling both formats here is that this makes it slightly more |
|
19
|
|
|
* straightforward to extract `duration` as either video duration or audio duration. |
|
20
|
|
|
* |
|
21
|
|
|
* @author Kajetan Dvoracek <[email protected]> |
|
22
|
|
|
* @package TYPO3 |
|
23
|
|
|
* @subpackage dlf |
|
24
|
|
|
* @access public |
|
25
|
|
|
*/ |
|
26
|
|
|
class AudioVideoMD implements \Kitodo\Dlf\Common\MetadataInterface |
|
27
|
|
|
{ |
|
28
|
|
|
/** |
|
29
|
|
|
* Extract some essential AudioMD/VideoMD metadata. |
|
30
|
|
|
* |
|
31
|
|
|
* @access public |
|
32
|
|
|
* |
|
33
|
|
|
* @param \SimpleXMLElement $xml: The XML to extract the metadata from |
|
34
|
|
|
* @param array &$metadata: The metadata array to fill |
|
35
|
|
|
* |
|
36
|
|
|
* @return void |
|
37
|
|
|
*/ |
|
38
|
|
|
public function extractMetadata(\SimpleXMLElement $xml, array &$metadata) |
|
39
|
|
|
{ |
|
40
|
|
|
$xml->registerXPathNamespace('audiomd', 'http://www.loc.gov/audioMD/'); |
|
41
|
|
|
$xml->registerXPathNamespace('videomd', 'http://www.loc.gov/videoMD/'); |
|
42
|
|
|
|
|
43
|
|
|
if (!empty($audioDuration = (string) $xml->xpath('./audiomd:audioInfo/audiomd:duration')[0])) { |
|
44
|
|
|
$metadata['audio_duration'] = [$audioDuration]; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
if (!empty($videoDuration = (string) $xml->xpath('./videomd:videoInfo/videomd:duration')[0])) { |
|
48
|
|
|
$metadata['video_duration'] = [$videoDuration]; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
$metadata['duration'] = $metadata['video_duration'] ?: $metadata['audio_duration'] ?: []; |
|
52
|
|
|
|
|
53
|
|
|
if (!empty($videoFrameRate = (string) $xml->xpath('./videomd:fileData/videomd:frameRate[@mode="Fixed"]')[0])) { |
|
54
|
|
|
$metadata['video_frame_rate'] = [$videoFrameRate]; |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|