2nd iteration returning different data
So, I'm using this library with laravel to parse my home video library. I have a queued task to scan a bunch of files. I've discovered that the 1st job always returns good ID3 data, but the subsequent invocations return less data (and not quicktime.comments - which I'm using to get date and gps info).
It's easy to show - I ran this routine in my debugging:
$this->_o = new \getID3();
$this->_o->analyze($this->file_path());
$this->_o->getHashdata('sha1');
$this->_x = new \getID3();
$this->_x->analyze($this->file_path());
$this->_x->getHashdata('sha1');
dump(['O:md5'=>$xx=md5(serialize(Arr::get($this->_o->info,'quicktime.comments'))),'keys'=>array_keys($this->_o->info)]);
dump(['X:md5'=>$xx=md5(serialize(Arr::get($this->_x->info,'quicktime.comments'))),'keys'=>array_keys($this->_x->info)]);
It essentially parse the same file twice - however the results are different:
array:2 [
"O:md5" => "5d9b87390842becd39a0635c388080e5"
"keys" => array:21 [
0 => "GETID3_VERSION"
1 => "filesize"
2 => "filepath"
3 => "filename"
4 => "filenamepath"
5 => "avdataoffset"
6 => "avdataend"
7 => "fileformat"
8 => "audio"
9 => "video"
10 => "tags"
11 => "warning"
12 => "comments"
13 => "encoding"
14 => "mime_type"
15 => "quicktime"
16 => "playtime_seconds"
17 => "bitrate"
18 => "tags_html"
19 => "playtime_string"
20 => "sha1_data"
]
]
array:2 [
"X:md5" => "dcca48101505dd86b703689a604fe3c4"
"keys" => array:19 [
0 => "GETID3_VERSION"
1 => "filesize"
2 => "filepath"
3 => "filename"
4 => "filenamepath"
5 => "avdataoffset"
6 => "avdataend"
7 => "fileformat"
8 => "audio"
9 => "video"
10 => "warning"
11 => "comments"
12 => "encoding"
13 => "mime_type"
14 => "quicktime"
15 => "playtime_seconds"
16 => "bitrate"
17 => "playtime_string"
18 => "sha1_data"
]
]
Notice the different MD5 results (the X:md5 result is the md5 of "null"), and the different number of keys.
Why would this be?
I'm not sure. If anyone else has insight I'm interested to hear ideas.
So its seems that the key "tags" and "tags_html" is missing on the second invocation - what triggers those to be unset (I think I saw that those keys are created when the object is created).
Are there any "const" values set anywhere? Since its the same run of PHP, its obviously something set from the first run is affecting the decision making in the second run.
Looking for ideas ...
Hello. I have the same problem. In the second and next invoke for mov files there is no tags and tags_html. Tags are only in the first invoke. What is a solution for this issue?
The issue is still occurring in both v1.9.22-202207161647 and v2.0.0-beta5. The following code can be used to reproduce the issue:
$analyze1 = $getID3->analyze('0.mov');
$analyze2 = $getID3->analyze('0.mov');
var_dump(array_diff(array_keys($analyze1), array_keys($analyze2)));
This code works by calling analyze on the same file twice and then comparing the results. The output of the code is:
array(2) {
[10]=>
string(4) "tags"
[18]=>
string(9) "tags_html"
}
This output demonstrates that repeating the exact same call to $getID3->analyze('0.mov') yields different results. The expected behavior is that repeating the call would give the same result.
@JamesHeinrich I emailed a sample .mov file for this with the code needed to verify the bug.
Finally figured out the problem. It's specific to Quicktime files, and caused by a static variable that wasn't being reset between calls to getid3_quicktime;Analyze(). My previous comment was that it was an ugly solution, but I didn't foresee this side effect. I have changed it to a class variable that should work mostly the same except can be reset with each new call.
At least with the provided sample file it solves the problem. Please re-open this issue if there's still a problem.
https://github.com/JamesHeinrich/getID3/commit/a3008444b66fbbc2494f5b1e18784f4c674c48fd