Make WordPress Core


Ignore:
Timestamp:
10/04/2017 07:31:51 PM (6 years ago)
Author:
mikeschroder
Message:

Media: Store video creation date in meta.

When able to be parsed, store the created date for a video file from meta,
since this is useful separately from the dates on the file itself.

Introduces wp_get_media_creation_timestamp() to read the timestamp from
getID3 and a wp_read_video_metadata filter analogous to
wp_read_image_metadata.

Fixes #35218.
Props stevegrunwell, joemcgill, desrosj, blobfolio, mikeschroder.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/media.php

    r41724 r41746  
    21392139        $this->assertSame( 0, $attachment_id );
    21402140    }
     2141
     2142    /**
     2143     * @ticket 35218
     2144     */
     2145    function test_wp_get_media_creation_timestamp_video_asf() {
     2146        $metadata = array(
     2147            'fileformat' => 'asf',
     2148            'asf'        => array(
     2149                'file_properties_object' => array(
     2150                    'creation_date_unix' => 123,
     2151                ),
     2152            ),
     2153        );
     2154
     2155        $this->assertEquals( 123, wp_get_media_creation_timestamp( $metadata ) );
     2156    }
     2157
     2158    /**
     2159     * @ticket 35218
     2160     */
     2161    function test_wp_get_media_creation_timestamp_video_matroska() {
     2162        $metadata = array(
     2163            'fileformat' => 'matroska',
     2164            'matroska'   => array(
     2165                'comments' => array(
     2166                    'creation_time' => array(
     2167                        '2015-12-24T17:40:09Z'
     2168                    ),
     2169                ),
     2170            ),
     2171        );
     2172
     2173        $this->assertEquals( 1450978809, wp_get_media_creation_timestamp( $metadata ) );
     2174    }
     2175
     2176    /**
     2177     * @ticket 35218
     2178     */
     2179    function test_wp_get_media_creation_timestamp_video_quicktime() {
     2180        $metadata = array(
     2181            'fileformat' => 'quicktime',
     2182            'quicktime'  => array(
     2183                'moov' => array(
     2184                    'subatoms' => array(
     2185                        array(
     2186                            'creation_time_unix' => 1450978805,
     2187                        ),
     2188                    ),
     2189                ),
     2190            ),
     2191        );
     2192
     2193        $this->assertEquals( 1450978805, wp_get_media_creation_timestamp( $metadata ) );
     2194    }
     2195
     2196    /**
     2197     * @ticket 35218
     2198     */
     2199    function test_wp_get_media_creation_timestamp_video_webm() {
     2200        $metadata = array(
     2201            'fileformat' => 'webm',
     2202            'matroska'   => array(
     2203                'info' => array(
     2204                    array(
     2205                        'DateUTC_unix' => 1265680539,
     2206                    ),
     2207                ),
     2208            ),
     2209        );
     2210
     2211        $this->assertEquals( 1265680539, wp_get_media_creation_timestamp( $metadata ) );
     2212    }
     2213
     2214    /**
     2215     * @ticket 35218
     2216     */
     2217    function test_wp_read_video_metadata_adds_creation_date_with_quicktime() {
     2218        $video    = DIR_TESTDATA . '/uploads/small-video.mov';
     2219        $metadata = wp_read_video_metadata( $video );
     2220
     2221        $this->assertEquals( 1269120551, $metadata['created_timestamp'] );
     2222    }
     2223
     2224    /**
     2225     * @ticket 35218
     2226     */
     2227    function test_wp_read_video_metadata_adds_creation_date_with_mp4() {
     2228        $video    = DIR_TESTDATA . '/uploads/small-video.mp4';
     2229        $metadata = wp_read_video_metadata( $video );
     2230
     2231        $this->assertEquals( 1269120551, $metadata['created_timestamp'] );
     2232    }
     2233
     2234    /**
     2235     * @ticket 35218
     2236     */
     2237    function test_wp_read_video_metadata_adds_creation_date_with_mkv() {
     2238        $video    = DIR_TESTDATA . '/uploads/small-video.mkv';
     2239        $metadata = wp_read_video_metadata( $video );
     2240
     2241        $this->assertEquals( 1269120551, $metadata['created_timestamp'] );
     2242    }
     2243
     2244    /**
     2245     * @ticket 35218
     2246     */
     2247    function test_wp_read_video_metadata_adds_creation_date_with_webm() {
     2248        $video    = DIR_TESTDATA . '/uploads/small-video.webm';
     2249        $metadata = wp_read_video_metadata( $video );
     2250
     2251        $this->assertEquals( 1269120551, $metadata['created_timestamp'] );
     2252    }
    21412253}
    21422254
Note: See TracChangeset for help on using the changeset viewer.