Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning on PrintHexBytes function when $string is not a string. #442

Closed
MorganOlufsen opened this issue Apr 19, 2024 · 3 comments
Closed

Comments

@MorganOlufsen
Copy link

Somewhere in code this function is called passing a INT on $string. That raises a warning:
Trying to access array offset on value of type int on /vagrant/vendor/james-heinrich/getid3/getid3/getid3.lib.php line 36

My workaround was to just return an empty string if is_string($string) == false.

@JamesHeinrich
Copy link
Owner

I could just hide the warning as you describe, but I'd prefer to fix the problem at the source if possible. Do you have a sample file that triggers this warning? (post here or email [email protected])

@MorganOlufsen
Copy link
Author

Sorry for the delay.
The code is relatively simple:

$getID3 = new getID3; $fileinfo = $getID3->analyze('video.mp4');

Unfortunately the problem occurs with a specific MP4 file that I cannot pass because it has copyright. I haven't been able to replicate it with another video.

I have made a backtrace in case it is helpful to see which function calls this.

Stack trace:
#0 /vagrant/vendor/james-heinrich/getid3/getid3/module.audio-video.quicktime.php(2177): getid3_lib::PrintHexBytes()
#1 /vagrant/vendor/james-heinrich/getid3/getid3/module.audio-video.quicktime.php(2263): getid3_quicktime->QuicktimeParseAtom()
#2 /vagrant/vendor/james-heinrich/getid3/getid3/module.audio-video.quicktime.php(894): getid3_quicktime->QuicktimeParseContainerAtom()
#3 /vagrant/vendor/james-heinrich/getid3/getid3/module.audio-video.quicktime.php(2263): getid3_quicktime->QuicktimeParseAtom()
#4 /vagrant/vendor/james-heinrich/getid3/getid3/module.audio-video.quicktime.php(312): getid3_quicktime->QuicktimeParseContainerAtom()
#5 /vagrant/vendor/james-heinrich/getid3/getid3/module.audio-video.quicktime.php(2263): getid3_quicktime->QuicktimeParseAtom()
#6 /vagrant/vendor/james-heinrich/getid3/getid3/module.audio-video.quicktime.php(283): getid3_quicktime->QuicktimeParseContainerAtom()
#7 /vagrant/vendor/james-heinrich/getid3/getid3/module.audio-video.quicktime.php(2263): getid3_quicktime->QuicktimeParseAtom()
#8 /vagrant/vendor/james-heinrich/getid3/getid3/module.audio-video.quicktime.php(283): getid3_quicktime->QuicktimeParseContainerAtom()
#9 /vagrant/vendor/james-heinrich/getid3/getid3/module.audio-video.quicktime.php(2263): getid3_quicktime->QuickDesafortunadamente el problema se da con un fichero MP4 concreto que no puedo pasar por tener derechos de autor. No he conseguido replicarlo con otro video.timeParseAtom()
#10 /vagrant/vendor/james-heinrich/getid3/getid3/module.audio-video.quicktime.php(283): getid3_quicktime->QuicktimeParseContainerAtom()
#11 /vagrant/vendor/james-heinrich/getid3/getid3/module.audio-video.quicktime.php(2263): getid3_quicktime->QuicktimeParseAtom()
#12 /vagrant/vendor/james-heinrich/getid3/getid3/module.audio-video.quicktime.php(283): getid3_quicktime->QuicktimeParseContainerAtom()
#13 /vagrant/vendor/james-heinrich/getid3/getid3/module.audio-video.quicktime.php(93): getid3_quicktime->QuicktimeParseAtom()
#14 /vagrant/vendor/james-heinrich/getid3/getid3/getid3.php(781): getid3_quicktime->Analyze()
#15 /vagrant/app/models/FileAttachment.php(92): getID3->analyze()

It seems that it receives an int when the function is called from:
module.audio-video.quicktime.php(Line 2177)

Here:

if ($atom_structure['ES_DecSpecificInfoTag'] != 0x05) {
	$this->warning('expecting esds.ES_DecSpecificInfoTag = 0x05, found 0x'.getid3_lib::PrintHexBytes($atom_structure['ES_DecSpecificInfoTag']).'), at offset '.$atom_structure['offset']);
	break;
}

Video format detected by file command:
ISO Media, MP4 Base Media v1 [ISO 14496-12:2003]

I'm not sure if it's relevant, but the only audio track is in the Catalan language.

@JamesHeinrich
Copy link
Owner

Thanks, PrintHexBytes shouldn't have been used there at all.
Fixed in 1192b61
(there was also 3 other similar places where the same error could have occurred).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants