Opened 3 years ago
Last modified 3 years ago
#53944 new defect (bug)
Video resolution in portrait orientation
Reported by: | mazursv | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 5.8 |
Component: | Media | Keywords: | has-patch |
Focuses: | Cc: |
Description
Hi!
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:
<?php 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)
Note: See
TracTickets for help on using
tickets.
Check if the video has been rotated 90/270 degrees and if so, swap the
width
andheight
values.Trac ticket: https://core.trac.wordpress.org/ticket/53944