123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 |
- Presentation
- ============
- MediaVorus is a small PHP library wich provide a set of tools to extract every
- technical information from multimedia files.
- Example
- -------
- .. code-block:: php
- <?php
- use MediaVorus\MediaVorus;
- use MediaVorus\MediaVorus;
- use MediaVorus\Media\Image;
- $mediavorus = MediaVorus::create();
- $Media = $mediavorus->guess('tests/files/CanonRaw.CR2');
- if($Media instanceof Image)
- {
- echo sprintf("Image was taken with a %f shutter speed", $Media->getShutterSpeed());
- }
- Goals
- -----
- MediaVorus is a small PHP library wich provide a set of tools to deal with
- multimedia files.
- The aim is to provide an abstract layer between the program and the multimedia
- file.
- First, the need is to analyze multimedia files and get their properties.
- In a very next future, we would add metadata mapper to handle various
- configurations.
- API
- ===
- Guesser
- -------
- .. code-block:: php
- <?php
- use MediaVorus\MediaVorus;
- $Media = MediaVorus::guess('tests/files/ExifTool.jpg');
- //Returns a \Doctrine\Common\Collections\ArrayCollection of Medias
- $MediaCollection = MediaVorus::inspectDirectory($dir, $recursive);
- Medias
- ------
- Media\\DefaultMedia
- *******************
- Default Media is the Default container.
- This object provides GPS informations :
- .. code-block:: php
- <?php
- use MediaVorus\MediaVorus;
- use MediaVorus\Media;
- $Media = MediaVorus::guess('somefile.smf');
- if($Media instanceof Media\DefaultMedia)
- {
- /**
- * Returns the longitude as a described above
- */
- $Media->getLongitude();
- /**
- * Returns the longitude as a described above
- */
- $Media->getLatitude();
- /**
- * Returns Longitude reference (West or East) and equals to one of the
- * Media\DefaultMedia::GPSREF_LONGITUDE_* constants
- */
- $Media->getLongitudeRef();
- /**
- * Returns Latitude reference (North or South) and equals to one of the
- * Media\DefaultMedia::GPSREF_LATITUDE_* constants
- */
- $Media->getLatitudeRef();
- }
- Media\\Image
- ************
- Media Image extends the default media.
- It has much more methods and provides the following informations :
- .. code-block:: php
- <?php
- use MediaVorus\MediaVorus;
- use MediaVorus\Media;
- $Media = MediaVorus::guess('tests/files/ExifTool.jpg');
- if($Media instanceof Media\Image)
- {
- /**
- * It extends the DefaultMedia
- */
- assert($Media instanceof Media\DefaultMedia);
- /**
- * Returns the width (int)
- */
- $Media->getWidth();
- /**
- * Returns the height (int)
- */
- $Media->getHeight();
- /**
- * Returns the number of channels (int)
- */
- $Media->getChannels();
- /**
- * Returns the focal length (string), not parsed
- */
- $Media->getFocalLength();
- /**
- * Returns the color depth in bits (int)
- */
- $Media->getColorDepth();
- /**
- * Returns the camera model name (string)
- */
- $Media->getCameraModel();
- /**
- * Returns true if the flash has been fired (bool)
- */
- $Media->getFlashFired();
- /**
- * Returns the aperture (string), not parsed
- */
- $Media->getAperture();
- /**
- * Returns the shutter speed (string), not parsed
- */
- $Media->getShutterSpeed();
- /**
- * Returns the orientation (string), one of the Media\Image::ORIENTATION_*
- */
- $Media->getOrientation();
- /**
- * Returns the date when the photos has been taken (string), not parsed
- */
- $Media->getCreationDate();
- /**
- * Returns the hyperfocal distance (string), not parsed
- */
- $Media->getHyperfocalDistance();
- /**
- * Returns the ISO value (int)
- */
- $Media->getISO();
- /**
- * Returns the light value (string), not parsed
- */
- $Media->getLightValue();
- }
- Media serialization
- -------------------
- All medias are serializable with `JMS Serializer <http://jmsyst.com/libs/serializer>`_.
- For example :
- .. code-block:: php
- <?php
- use Doctrine\Common\Annotations\AnnotationRegistry;
- use JMS\Serializer\SerializerBuilder;
- use MediaVorus\MediaVorus;
- AnnotationRegistry::registerAutoloadNamespace(
- 'JMS\Serializer\Annotation', __DIR__.'/vendor/jms/serializer/src'
- );
- $serializer = SerializerBuilder::create()
- ->setCacheDir(__DIR__ . '/cache')
- ->build();
- $mediavorus = MediaVorus::create();
- print($serializer->serialize($mediavorus->guess('image.jpg'), 'json'));
- would result in the following output :
- .. code-block:: json
- {
- "type": "Image",
- "raw_image": false,
- "multiple_layers": false,
- "width": 3264,
- "height": 2448,
- "channels": 3,
- "focal_length": 4.28,
- "color_depth": 8,
- "camera_model": "iPhone 4S",
- "flash_fired": false,
- "aperture": 2.4,
- "shutter_speed": 0.05,
- "orientation": 90,
- "creation_date": "2012:03:16 16:29:09",
- "hyperfocal_distance": 2.0773522348635,
- "ISO": 400,
- "light_value": 4.847996906555,
- "color_space": "RGB"
- }
- Silex Service Provider
- ----------------------
- MediaVorus comes bundled with its `Silex Service Provider <silex.sensiolabs.org>`_.
- As MediaVorus relies on `PHP-Exiftool <https://github.com/romainneutron/PHPExiftool>`_
- and `FFProbe <http://ffmpeg-php.readthedocs.org/>`_, you'll have to register
- both bundles to use it :
- .. code-block:: php
- <?php
- use FFMpeg\FFMpegServiceProvider;
- use MediaVorus\MediaVorusServiceProvider;
- use PHPExiftool\PHPExiftoolServiceProvider;
- use Silex\Application;
- $app = new Application();
- $app->register(new MediaVorusServiceProvider());
- $app->register(new PHPExiftoolServiceProvider());
- $app->register(new FFMpegServiceProvider());
- // you will now have access to $app['mediavorus']
- $video = $app['mediavorus']->guess('/path/to/video/file');
- .. toctree::
- :maxdepth: 1
- API
- UseCases
|