-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,3 +39,4 @@ | |
*.ogv binary | ||
*.wmv binary | ||
*.flv binary | ||
*.mxf binary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace Selective\VideoType\Detector; | ||
|
||
use Selective\VideoType\VideoFormat; | ||
use Selective\VideoType\VideoType; | ||
use Selective\VideoType\VideoMimeType; | ||
use SplFileObject; | ||
|
||
/** | ||
* Detector. | ||
*/ | ||
final class MxfDetector implements VideoDetectorInterface | ||
{ | ||
/** | ||
* MXF - Material Exchange Format. | ||
* | ||
* http://fileformats.archiveteam.org/wiki/MXF#Identifiers | ||
* | ||
* @param SplFileObject $file The video file | ||
* | ||
* @return VideoType|null The video type | ||
*/ | ||
public function detect(SplFileObject $file): ?VideoType | ||
{ | ||
// Search at the end of the file | ||
$offset = $file->getSize() - 1024; | ||
$file->fseek($offset); | ||
|
||
$magicBytes = (string)hex2bin('060e2b34020501010d0102'); | ||
$hasMagicBytes = strpos((string)$file->fread(1024), $magicBytes) !== false; | ||
|
||
return $hasMagicBytes ? new VideoType( | ||
VideoFormat::MXF, | ||
VideoMimeType::VIDEO_MXF | ||
) : null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.