Lightroom SDK: photo:getDevelopSettings() throws an error sometimes when photo is a video

  • 2
  • Problem
  • Updated 6 years ago
Error message: tried to index 'trimEnd' but it was nil, or something like that.
Photo of Rob Cole

Rob Cole

  • 4831 Posts
  • 382 Reply Likes

Posted 6 years ago

  • 2
Photo of Rob Cole

Rob Cole

  • 4831 Posts
  • 382 Reply Likes
This error is driving me crazy:



Only happens with some videos, but what it means is that it is not safe for *any* plugin to call getDevelopSettings unless wrapped by an LrTasks.pcall.

I hope this bug is fixed. If not, a note in the api document is in order:
"this function will throw an error sometimes...".

I bet most plugins do not so protect, and thus have a ticking time bomb in them, waiting to go off.

Thanks,
Rob
Photo of John R. Ellis

John R. Ellis, Champion

  • 3739 Posts
  • 978 Reply Likes
Is this a property of the particular video or the catalog? I.e. if you find a video that consistently throws an error, what happens if you import it into a fresh catalog? Just a wild guess: Perhaps the problem videos were imported into an LR 3 catalog?
Photo of Rob Cole

Rob Cole

  • 4831 Posts
  • 382 Reply Likes
Gimme a minute to check - it's the same problem that cropped up during initial testing of AnyFilter (which you subsequently corrected).
Photo of John R. Ellis

John R. Ellis, Champion

  • 3739 Posts
  • 978 Reply Likes
Oh, I forgot about that. But it would be good to know if this is a problem with the videos themselves or a corrupted catalog entry.
Photo of John R. Ellis

John R. Ellis, Champion

  • 3739 Posts
  • 978 Reply Likes
Here's the code I forgot about in Any Filter:


--[[----------------------------------------------------------
table
safeGetDevelopSettings (photo)

Returns photo:getDevelopSettings(). If an error occurs,
logs the error in the debug log and returns {}. (In LR 4.1,
a video in Rob Cole's catalog caused
photo:getDevelopSettings() to raise an error.)
-----------------------------------------------------------]]

function safeGetDevelopSettings (photo)
local success, value =
LrTasks.pcall (photo.getDevelopSettings, photo)
if success then return value end
Debug.logn ("safeGetDevelopSettings",
photo:getRawMetadata ("path"), value)
return {}
end
Photo of Rob Cole

Rob Cole

  • 4831 Posts
  • 382 Reply Likes
Yep. - that's the work-around I've employed as well.
Photo of Rob Cole

Rob Cole

  • 4831 Posts
  • 382 Reply Likes
Video was imported in Lr3, but can not be imported in Lr4(.4RC1).

So, there is something about the video that Lr4 does not like, but that did not bother Lr3.

Note: video was edited in Premiere Elements and saved in MPG format, after coming from Canon S5-IS.

PS - the video has no problems outside Lr.

PPS - It's a video of a naked woman dancing, so please don't ask me to post it ;-)
Photo of John R. Ellis

John R. Ellis, Champion

  • 3739 Posts
  • 978 Reply Likes
Isn't it the case that it's only LR 4 in which you can apply develop adjustments to videos? If so, then that's consistent with the bug -- getDevelopSettings() fails in LR 4 but not in 3 because 3 didn't even have develop settings for videos.
Photo of Rob Cole

Rob Cole

  • 4831 Posts
  • 382 Reply Likes
I suppose that makes sense (I'm a bit out on a limb now...).