diff --git a/src/Code/Converters/TtmlConverter.php b/src/Code/Converters/TtmlConverter.php index a76ac31..164665e 100644 --- a/src/Code/Converters/TtmlConverter.php +++ b/src/Code/Converters/TtmlConverter.php @@ -12,7 +12,7 @@ public function canParseFileContent($file_content) public function fileContentToInternalFormat($file_content) { $dom = new \DOMDocument(); - $dom->loadXML($file_content); + @$dom->loadXML($file_content); $array = array(); @@ -120,12 +120,14 @@ protected static function ttmlTimeToInternal($ttml_time) } elseif (substr($ttml_time, -1) === 's') { return rtrim($ttml_time, 's'); } else { - $timeParts = explode(':', $ttml_time); - $hours = (int)$timeParts[0]; - $minutes = (int)$timeParts[1]; - $seconds = (int)$timeParts[2]; - $totalSeconds = ($hours * 3600) + ($minutes * 60) + $seconds; - return $totalSeconds; + $time_parts = explode('.', $ttml_time); + $milliseconds = 0; + if (isset($time_parts[1])) { + $milliseconds = (float) ('0.' . $time_parts[1]); + } + + list($hours, $minutes, $seconds) = array_map('intval', explode(':', $time_parts[0])); + return ($hours * 3600) + ($minutes * 60) + $seconds + $milliseconds; } } } \ No newline at end of file diff --git a/tests/files/ttml_with_duplicated_element_ids.ttml b/tests/files/ttml_with_duplicated_element_ids.ttml new file mode 100644 index 0000000..8d68c00 --- /dev/null +++ b/tests/files/ttml_with_duplicated_element_ids.ttml @@ -0,0 +1,21 @@ + + + + TTML Example With Duplicated Element Ids + Thierry Michel 2015 + + + +