Ticket #45 (closed Enhancement: fixed)

Opened 6 years ago

Last modified 3 years ago

Screen Grabs - 2 points

Reported by: anonymous Owned by:
Priority: normal Milestone:
Component: Cover Art Version: 1.0b4.1
Keywords: Cc:

Description

1 - when i run the import TV data...sapphire does the screen grabs for use with preview art. BUT...many of my shows are not showing any art....it doesnt grab anything but a few episodes, even though they are same file, container, etc as the other files that did work.

2 - is there any way to auto grab the season art and show art? for example....season 1 art would pick a random screen grab from season 1 episodes. And Show art would grab a random screen grab from any episode.

Attachments

NSImage-Extensions.m Download (3.4 KB) - added by wazza 5 years ago.
NSImage-Extensions.h Download (2.0 KB) - added by wazza 5 years ago.
SapphireFrontRowCompat.h Download (13.0 KB) - added by wazza 5 years ago.
SapphireFrontRowCompat.m Download (13.9 KB) - added by wazza 5 years ago.
compat_classes_for_ticket_45.diff Download (1.4 KB) - added by wazza 5 years ago.
screen_grabs.diff Download (22.1 KB) - added by wazza 5 years ago.
NSString-Extensions.m Download (3.3 KB) - added by wazza 5 years ago.
Non-TIFFRepresentation version
NSImage-Extensions.2.m Download (3.4 KB) - added by wazza 5 years ago.
Non-TIFFRepresentation version
t45_import_and_refresh_segfault.diff Download (1.7 KB) - added by wazza 5 years ago.

Change History

comment:1 Changed 6 years ago by gbooker

1 - Sapphire grabs its data from  http://www.tvrage.com If there is no screenshot for a particular ep there, then there is nothing to grab. It doesn't examine the file itself to get a screencap.

2 - That could be an interesting idea.

comment:2 Changed 6 years ago by pmerrill

  • Component changed from Metadata - TV Show to Cover Art

comment:3 follow-up: ↓ 4 Changed 6 years ago by anonymous

is there any way to code it so the screen grab is from a random time frame from within the episode? this way you dont need to rely on the community for every screen shot.

I think it should be saved as a jpeg or something when doing the import, this way its faster when browsing, but it might be better in long run to grab artwork this way for individual episodes.

and then, we can go to TV rage for Season artwork, and Show title artwork.

comment:4 in reply to: ↑ 3 Changed 6 years ago by gbooker

Replying to anonymous:

is there any way to code it so the screen grab is from a random time frame from within the episode? this way you dont need to rely on the community for every screen shot.

Yeah, [QTMovie posterImage] and [QTMovie frameImageAtTime] will do the trick.

and then, we can go to TV rage for Season artwork, and Show title artwork.

Not all shows have show title artwork, and I have never seen season artwork (where are those?). Also, the show artwork tends to be somewhat low quality, but I guess it is better than nothing.

comment:5 follow-up: ↓ 6 Changed 6 years ago by anonymous

sorry...i dont know how to do the [QTMovie posterImage]. Is there a way to do this via applescript? then i can just drop all my videos on the applescript and have it throw out some jpegs into the collection art folder.

as for the season art...i was referring to the DVD covers, as they usually are sold in complete seasons. for show art...each show usually has a title screen...which obviously peple would need to do on their own or make a database for.

comment:6 in reply to: ↑ 5 Changed 6 years ago by gbooker

Replying to anonymous:

sorry...i dont know how to do the [QTMovie posterImage].

That was a developer note on a method to implement it

as for the season art...i was referring to the DVD covers, as they usually are sold in complete seasons.

Yuck; Those are usually ugly and destroyed by text overlays.

comment:7 Changed 6 years ago by snown

Although some DVD art is ugly, I agree that it would be nice to see something other than color bars all the time when browsing TV shows. And some cover art is really not that bad.

Also  IMPA's TV section (given far from complete) has some very nice Promotional posters for TV shows which may do for series cover art.

comment:8 Changed 6 years ago by gbooker

  • Type changed from Defect to Enhancement

This is not a defect; corrected type

comment:9 Changed 6 years ago by anonymous

i thought about this more....and maybe you can add a function to this so that Sapphire will check tvrage.com for the artwork for an episode first, but if there is no artwork for the given episode then it will grab a random time frame from the file and saves as .jpg in the coverart folder.

for seasons, you can do a random image from one of the episodes within that season.

for show you can do a random image from one of the season images within that show, or do like front row and do a flowing slideshow effect of all the season images.

comment:10 Changed 5 years ago by wazza

I thought this was an interesting enhancement so I had a go at it.

The attached diff and new files perform the following:

  • If no image data is available from TV rage a grab is made from the content.
  • If this image is not suitable there is a new option available on the mark menu to change the cover art. This provides a list of 10 random grabs to choose from. (warning: slooooow, ~4 seconds to generate 10 images, any hints on how to speed that up would be welcome)
  • The list of new images is refreshable, in case the list provided contains nothing useful.
  • For content that contains lots of fast movement (such as sport events) the screen grabs are pretty worthless, so I've also added an XML override using the tag <image>, which specifies a time hh:mm:ss from which to take the screen grab.
  • None of the above applies to mkv format, it's brain dead.

The diff applies to the CoreData branch, I didn't bother doing this for the trunk.

Changed 5 years ago by wazza

Changed 5 years ago by wazza

comment:11 Changed 5 years ago by wazza

Updated the diff file after [815]

comment:12 Changed 5 years ago by gbooker

Just to ping... I do like this idea, but I wonder if there's a better way to get screen captures. I'm afraid that the slow speed is unavoidable, but not likely that bad for interactive purposes. BTW, I think the XML key should likely be "imageTime" rather than "image" Also, flv should likely be skipped just like mkv.

comment:13 Changed 5 years ago by wazza

Just to clarify: do you mean better as in totally different way, or a nicer version of the above implementation?

  • TV show importing could be made analogous to Movie importing and provide a screen cap chooser during import if no cover art is available.
  • Sapphire could optionally allow the user to save the image at the time last played (could be horrible, though)
  • I don't know the BR API very well, but if there was some form of slide controller a user could have a finer control over the frame time if presented with the content and a slider to move to a frame and save it. Might be overkill though.
  • A nicer version of the above diff could cache images in the background to reduce wait times, but that's just a finesse issue, it doesn't add anything new, but should improve user experience.

The diff provided could be canabalised easily enough to provide a starting point for alternative implementations, so I hope it's at least 'kinda' useful.

If I'm barking up the wrong tree with the options above let me know, I'm happy to try alternatives if I know how to do them.

comment:14 Changed 5 years ago by gbooker

I was purely wondering if there was a better way to get images out of a QTMovie, but there doesn't seem to be one; otherwise the above implementation is a definite improvement.

comment:15 follow-up: ↓ 16 Changed 5 years ago by wazza

Just discovered frameImageAtTime:withAttributes:error as an optional API, which is supposed to be faster. I'll try that out and see what I get back from it.

comment:16 in reply to: ↑ 15 Changed 5 years ago by gbooker

Replying to wazza:

Just discovered frameImageAtTime:withAttributes:error

That's leopard only, which means it won't work on ATV.

comment:17 Changed 5 years ago by gbooker

I was applying this patch, and discovered it's missing your changes SapphireFrontRowCompat?, the coverartAsImage: selector.

Changed 5 years ago by wazza

Changed 5 years ago by wazza

comment:18 Changed 5 years ago by wazza

Uploaded now, my apologies

Changed 5 years ago by wazza

comment:19 Changed 5 years ago by wazza

should have been as a patch, more apologies...

comment:20 Changed 5 years ago by gbooker

Unfortunately, the TIFFRepresentation doesn't work on the ATV. I can't seem to find any other way to change an NSImage into JPG data though.

comment:21 Changed 5 years ago by wazza

Nuts.

Everything hinges on TIFFRepresentation. I'll see if I can find something else later.

frameImageAtTime:withAttributes:error as mentioned above can return CGImageRefs directly, which would skip using NSImage & TIFFRepresentation. But as you said, if that API is not available on aTV either that doesn't help matters much.

comment:22 Changed 5 years ago by wazza

After a bit of digging...

It might be possible to loop through the NSImageReps returned via [NSImage representations] and see if there is a NSBitmapImageRef (which there should be). If yes, then representationUsingType:properties: could be used to get the JPG in NSData format to write to file.

I don't have an aTV, but I could try it out on my Mac and see if that works, if it does I'll upload a new version and ask you to try it out on the aTV.

This may take a while, I upgraded my version of Xcode last night and when I checked it this morning it couldn't compile Sapphire... whoops.

Changed 5 years ago by wazza

comment:23 Changed 5 years ago by wazza

Updated version attached. It contains diffs for Compat classes as well, I'd suggest you apply the patch on a fresh checkout of the branch and copy over the NSImage extensions.

  • Alternative method to TIFFRepresentation used
  • XML image tag set to imageTime
  • Check for .flv file extension added

The removal of TIFFRepresentation didn't cause any problems on FrontRow?, hopefully it will be Ok for aTV.

comment:24 Changed 5 years ago by gbooker

I think this is going to have to be a leopard only feature. [QTMovie frameImageAtTime:] on the atv returns:

NSImage 0x338b50 Size={0, 0} Reps=(
    NSPICTImageRep 0x340e30 Size={0, 0} ColorSpace=NSCalibratedRGBColorSpace BPS=0 Pixels=0x0 Alpha=NO
)

on leopard, the same movie returns:

NSImage 0x16d8c0 Size={696, 376} Reps=(
    NSPICTImageRep 0x16a360 Size={696, 376} ColorSpace=NSCalibratedRGBColorSpace BPS=0 Pixels=696x376 Alpha=NO,
    NSBitmapImageRep 0x15acc0 Size={696, 376} ColorSpace=NSDeviceRGBColorSpace BPS=8 BPP=32 Pixels=696x376 Alpha=YES Planar=NO Format=0
)

Notice the size. Getting the NSPICTImageRep on the atv, and calling PICTRepresentation crashes. Also, [NSImage representations] on the ATV only returns the (broken) NSPICTImageRep, while on leopard it returns a NSBitmapImageRep as well. On the other hand, the old GetMoviePict? seems to work, but I don't think it's worth messing with old APIs.

comment:25 Changed 5 years ago by gbooker

Wazza, What was the alternative to TIFFRepresentation? I still see it being used in NSImage-Extensions. Is there something I'm missing?

Changed 5 years ago by wazza

Non-TIFFRepresentation version

Changed 5 years ago by wazza

Non-TIFFRepresentation version

comment:26 Changed 5 years ago by wazza

The latest version of NSImage extensions was missing, I've re-upped (and accidentally uploaded NSString extensions, please ignore)

If this would be Leopard only feature, it's probably best to stick with TIFFRepresentation, I guess.

comment:27 Changed 5 years ago by gbooker

  • Status changed from new to closed
  • Resolution set to fixed

(In [827]) Added screen capture ability thanks to patch by wazza. Does not work on ATV since ATV is broken. Fixes #45

comment:28 Changed 5 years ago by gbooker

I merged together the original TIFFRepresentation patch with changes I saw is subsequent patches. Let me know if I missed something. Also, I changed the refresh to take an invokation, which should be more flexible in the future.

comment:29 Changed 5 years ago by wazza

Looks good, there are three small issues fixed in the attached diff:

  • If image is missing from TVRage.com the initial screen grab wasn't being called (fileContainerType was checked instead of fileContainerTypeValue.)
  • The chooser for images works ok for the first time, but the refresh option causes a seg fault. Invocation of the refreshInvoke object loses the target (SapphireMarkMenu) object, because it is swapped out and probably garbage collected.
  • The refreshInvoke object should invoke doChangeArtwork: from SapphireMarkMenu, as loadArtwork: creates the wait display, which is already taken care of in doRefresh.

Another issue that I haven't fixed yet is that if there is a subtitle file then the image returned is a black image with just the subtitle overlay. I'll see if I can get around that.

Changed 5 years ago by wazza

comment:30 Changed 5 years ago by gbooker

(In [837]) Fixed refreshing of artwork. Fixes #45

comment:31 Changed 3 years ago by wazza

Just noticed this functionality has stopped working.

The "Change artwork" option is still there, but selecting a new image does nothing.

comment:32 Changed 3 years ago by gbooker

(In [1342]) Add back the writing of raw images to a file in the poster chooser. Refs #45

Note: See TracTickets for help on using tickets.