Make WordPress Core

Opened 3 years ago

Last modified 3 years ago

#53944 new defect (bug)

Video resolution in portrait orientation

Reported by: mazursv's profile mazursv Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.8
Component: Media Keywords: has-patch
Focuses: Cc:



I uploaded mp4 video file having portrait orientation and found that attachment metadata contains swapped width and height parameters. I see that WP is using getID3 library to read video metadata and found that it can detect when video is rotated.

I used following filter to fix that:


add_filter('wp_read_video_metadata', [$this, 'wp_read_video_metadata'], 20, 4);
public function wp_read_video_metadata( $metadata, $file, $file_format, $id3_data ) {
                if( !empty( $id3_data['video']['rotate'] ) ) {
                        if( $id3_data['video']['rotate'] === 90 || $id3_data['video']['rotate'] === 270 ) {
                                $metadata['width'] = $id3_data['video']['resolution_y'];
                                $metadata['height'] = $id3_data['video']['resolution_x'];

                return $metadata;

Change History (2)

#1 @mazursv
3 years ago

  • Component changed from General to Media

This ticket was mentioned in PR #1597 on WordPress/wordpress-develop by costdev.

3 years ago

  • Keywords has-patch added

Check if the video has been rotated 90/270 degrees and if so, swap the width and height values.

Trac ticket:

Note: See TracTickets for help on using tickets.