avoid provoking alpha+odd bug

This commit is contained in:
ccd0 2013-11-30 23:50:06 -08:00
parent 3a85fb8133
commit 7595d6b660

View File

@ -135,24 +135,23 @@ function videoData($filename) {
// Get track information // Get track information
$videoAttr = $videoTrack->get('Video'); $videoAttr = $videoTrack->get('Video');
if (isset($videoAttr)) { if (!isset($videoAttr)) throw new Exception('missing video parameters');
$pixelWidth = $videoAttr->get('PixelWidth'); $pixelWidth = $videoAttr->get('PixelWidth');
$pixelHeight = $videoAttr->get('PixelHeight'); $pixelHeight = $videoAttr->get('PixelHeight');
if ($pixelWidth == 0 || $pixelHeight == 0) { if (!isset($pixelWidth) || !isset($pixelHeight)) throw new Exception('no width or height');
error_log('bad PixelWidth/PixelHeight'); if ($pixelWidth == 0 || $pixelHeight == 0) throw new Exception('bad PixelWidth/PixelHeight');
$pixelWidth = NULL; $displayWidth = $videoAttr->get('DisplayWidth', $pixelWidth);
$pixelHeight = NULL; $displayHeight = $videoAttr->get('DisplayHeight', $pixelHeight);
} if ($displayWidth == 0 || $displayHeight == 0) throw new Exception('bad DisplayWidth/DisplayHeight');
$data['width'] = $videoAttr->get('DisplayWidth', $pixelWidth); $data['width'] = $displayWidth;
$data['height'] = $videoAttr->get('DisplayHeight', $pixelHeight); $data['height'] = $displayHeight;
if ($data['width'] == 0 || $data['height'] == 0) {
error_log('bad DisplayWidth/DisplayHeight');
$data['width'] = $pixelWidth;
$data['height'] = $pixelHeight;
}
}
// Extract frame to use as thumbnail // Extract frame to use as thumbnail
if ($videoAttr->get('AlphaMode') != NULL) {
if (!($pixelWidth % 2 == 0 && $pixelHeight % 2 == 0 && $displayWidth % 2 == 0 && $displayHeight % 2 == 0)) {
throw new Exception('preview frame blocked due to Chromium bug');
}
}
$trackNumber = $videoTrack->get('TrackNumber'); $trackNumber = $videoTrack->get('TrackNumber');
if (!isset($trackNumber)) throw new Exception('missing track number'); if (!isset($trackNumber)) throw new Exception('missing track number');
if (isset($data['duration']) && $data['duration'] >= 5) { if (isset($data['duration']) && $data['duration'] >= 5) {
@ -163,7 +162,6 @@ function videoData($filename) {
$frame = firstWebMFrame($segment, $trackNumber, $skip); $frame = firstWebMFrame($segment, $trackNumber, $skip);
if (!isset($frame)) throw new Exception('no keyframes'); if (!isset($frame)) throw new Exception('no keyframes');
$data['frame'] = muxWebMFrame($videoTrack, $frame); $data['frame'] = muxWebMFrame($videoTrack, $frame);
} catch (Exception $e) { } catch (Exception $e) {
error_log($e->getMessage()); error_log($e->getMessage());
} }