Find out whether video is in landscape or portrait format

The place for "I can't figure out how to..." questions.
Post Reply
user632819
User
Posts: 4
Joined: Wed Aug 15, 2018 9:14 am
Are you a spambot?: no

Find out whether video is in landscape or portrait format

Post by user632819 » Wed Aug 15, 2018 9:33 am

I'm using getID3 to find out width and height of a video. I downloaded the newest version from here: https://github.com/JamesHeinrich/getID3

I have this PHP code:

Code: Select all

<?php
include_once('getid3/getid3.php');
$getID3 = new getID3;
$file = $getID3->analyze('clip.MOV');

$width = $file['video']['resolution_x'];
$height = $file['video']['resolution_y'];

echo "Width: ".$width;
echo "Height: ".$height;
?>
I'm uploading videos from iPhone.

When using a video in landscape/horizontal format everything is fine.

But when using a video in portrait/upright format I'm getting height as width and vice versa.

When editing a portrait/upright video in a video app and re-saving it, it's working fine when uploading.

I think there's something with the metadata.

I already read this topic: https://www.getid3.org/phpBB3/viewtopic.php?t=1908

I tried the following:

Code: Select all

<?php
include_once('getid3/getid3.php');
$getID3 = new getID3;
var_dump($getID3->analyze('my_clip.mov'));
?>
I'm getting very much text as output, about 35,655 characters.

Searching for "rotate" only gives me the following twice: ["rotate"]=> int(0)

Any idea how I can find out the orientation?

Thanks,
Dave.

James Heinrich
getID3() v1 developer
Posts: 1475
Joined: Fri May 04, 2001 4:00 pm
Are you a spambot?: no
Location: Northern Ontario, Canada
Contact:

Re: Find out whether video is in landscape or portrait format

Post by James Heinrich » Wed Aug 15, 2018 4:36 pm

Perhaps you could supply a couple (or ideally 4) short (even 1-second is fine) sample videos from your iPhone so I can make sure things are being parsed correctly. If you could take very brief videos, one in each orientation (landscape, portrait, upside-down-landscape, reverse-portrait) of something where the correct orientation is clear (view of outside, for example) that would be useful. I'll take a look at them and make sure the orientation details are being parsed correctly.

user632819
User
Posts: 4
Joined: Wed Aug 15, 2018 9:14 am
Are you a spambot?: no

Re: Find out whether video is in landscape or portrait format

Post by user632819 » Thu Aug 16, 2018 7:12 am

James Heinrich wrote:
Wed Aug 15, 2018 4:36 pm
Perhaps you could supply a couple (or ideally 4) short (even 1-second is fine) sample videos from your iPhone so I can make sure things are being parsed correctly. If you could take very brief videos, one in each orientation (landscape, portrait, upside-down-landscape, reverse-portrait) of something where the correct orientation is clear (view of outside, for example) that would be useful. I'll take a look at them and make sure the orientation details are being parsed correctly.
Hey James,
thank you very much for trying to help me.

I would prefer not to post my video files with private exif informations here in public.

How can I send you a privat message? Do you have an e-mail address.

Thanks and greetings,
Dave.

James Heinrich
getID3() v1 developer
Posts: 1475
Joined: Fri May 04, 2001 4:00 pm
Are you a spambot?: no
Location: Northern Ontario, Canada
Contact:

Re: Find out whether video is in landscape or portrait format

Post by James Heinrich » Thu Aug 16, 2018 1:07 pm

Please send any sample files to info@getid3.org

James Heinrich
getID3() v1 developer
Posts: 1475
Joined: Fri May 04, 2001 4:00 pm
Are you a spambot?: no
Location: Northern Ontario, Canada
Contact:

Re: Find out whether video is in landscape or portrait format

Post by James Heinrich » Thu Aug 16, 2018 6:25 pm

Hi Dave,

Sorry, I realize why you couldn't post back and fixed it. But I also didn't get any sample files from you yet...?

user632819
User
Posts: 4
Joined: Wed Aug 15, 2018 9:14 am
Are you a spambot?: no

Re: Find out whether video is in landscape or portrait format

Post by user632819 » Thu Aug 16, 2018 6:42 pm

Hey James,
thanks, I just sent you the files again.

Did you receive my email now?

Till then,
Dave.
Last edited by user632819 on Thu Aug 16, 2018 6:47 pm, edited 1 time in total.

James Heinrich
getID3() v1 developer
Posts: 1475
Joined: Fri May 04, 2001 4:00 pm
Are you a spambot?: no
Location: Northern Ontario, Canada
Contact:

Re: Find out whether video is in landscape or portrait format

Post by James Heinrich » Thu Aug 16, 2018 6:45 pm

Sorry, I eventually did find the files from your original email (in my spam folder, not sure why I couldn't find them before). I'm looking at them now.

James Heinrich
getID3() v1 developer
Posts: 1475
Joined: Fri May 04, 2001 4:00 pm
Are you a spambot?: no
Location: Northern Ontario, Canada
Contact:

Re: Find out whether video is in landscape or portrait format

Post by James Heinrich » Thu Aug 16, 2018 7:54 pm


user632819
User
Posts: 4
Joined: Wed Aug 15, 2018 9:14 am
Are you a spambot?: no

Re: Find out whether video is in landscape or portrait format

Post by user632819 » Fri Aug 17, 2018 7:13 am

Hi James,
thank you for the patched version.

I'm able to get the right rotate now.

This code is working now:

Code: Select all

<?php
include_once('getid3/getid3.php');

$filename = "clip.mov";

$getID3 = new getID3;
$file = $getID3->analyze($filename);

$width = $file['video']['resolution_x'];
$height = $file['video']['resolution_y'];
$rotate = $file['video']['rotate'];

$width = $file['video']['resolution_x'];
$height = $file['video']['resolution_y'];

if($file['video']['rotate'] == 90 || $file['video']['rotate'] == 270) {
	echo "Height: ".$width."<br><br>";
	echo "Width: ".$height."<br><br>";
} else {
	echo "Height: ".$height."<br><br>";
	echo "Width: ".$width."<br><br>";
}
echo "Rotate: ".$rotate;
?>
Thanks and greetings,
Dave.

Post Reply