rshendershot / MythRokuPlayer

mythtv front end for Roku player
tbd
8 stars 2 forks source link

screenshots are not gathered by metadatalookup for Movies #8

Open rshendershot opened 11 years ago

rshendershot commented 11 years ago

this really is an issue for MythTV. Tried alternative suggested by Zane to use coverart or fanart instead. I found that, being 5-10 times larger in size, there was a critical performance penalty. For MythVideo TV Series types, they need to be named in a specific way to get metadata screenshots. I don't know of any MythtV based solution.

Using screenshots for now. TODO, generate missing screenshots and update database.

I don't think memcache can help as it seems to be on-the-wire, re-requested by the Roku (2XS with new UI).

dschwilk commented 9 years ago

Is there a way with your current code to get some sort of image associated with videos (not recordings)?

I tried uncommenting the code that used the coverart and fanart in mythroku/player_feed.php and you are right! That looks great but has unusable performance as those images are huge.

So I tried to figure out how to use the imagerezize.php code in Zane's dev fork, but 1) was not sure how to hook up this SimpleImage class to your use of images and 2) even including imageresize.php caused some error that caused image.php to fail. Obviously, I need to debug but don't have a good method for this in php (first time even looking at php --- I know what I'm doing in R, python, and ,at one time C++, but I'm a simple plant ecologist). I thought I'd check in before I tried harder in case you've already explored on the fly resizing.

dschwilk commented 9 years ago

Ah, I see that you are using image.php for streaming video as well as displaying images. Ok, I need to split those functions as images may need to be resized and also probably don't need all of the range download complication.

rshendershot commented 9 years ago

I was thinking about adding another conditional in image.php (call it imagegen) in addition to the current image and preview tags. When the list is sent to the Roku we know that the video screenshot is empty so use this new tag. In image.php that block would use ffmpeg (or GD functions similar to SimpleImage) to create a screenshot in the storage directory, and VideoMetaData class to update the database.

I've never seen a need to resize, and done on-the-fly would be a performance hit. Roku does something strange AFAICT with cache handling so relying on web cache I couldn't see would work.

Note that the initial list sent to the Roku contains the url of the preview image and a GET is issued by the Roku for all imgUrl in the current list. So Date;Today may not request -or display- every preview but Date;All would. They're issued asynchronously by the Roku UI.

dschwilk commented 9 years ago

I went ahead and implemented on the fly resizing. I created another conditional in image.php and used separate params for "stream" and "thumbnail" (name could be better). So params in urls from player_feed.hp are "stream", "thumbnail" and "preview". It works great on my setup. Very snappy and faster than the previews. I can create a clean branch with just that change for a pull request if you are interested. I also have the rescaled size hard coded for now. I was not even sure what was correct. Mythtv screenshots are inconsistent in width and the roku must resize anyway.

I used the imagemagick library for php. So it is a dependency. But perhaps there are easy base php ways to do it. On my ubuntu box I already have imagemagick and the library install is just apt-get install php-imagick.

Here is the relevent change in image.php starting at http://github.com/dschwilk/MythRokuPlayer/blob/videoimages/mythroku/image.php#L18:

} elseif (isset($_GET['thumbnail'])) { //send a file spec
    $file = rawurldecode($_GET['thumbnail']);
    if (file_exists($file)) {
        $img = new Imagick($file); // on ubuntu: apt-get install php5-imagick
        $img->scaleImage(250,0,false);
        // can't use line below because imageLength() is not the number of bytes sent. TODO?
        //header('Content-Length: ' . $img->getImageLength());
        header('Content-Type: image/' . $img->getImageFormat());
        echo $img;
    } else {
        throw new Exception("unknown file: $file");
    }
}
rshendershot commented 9 years ago

I'd be interested in accepting pull requests.

My tags image==static reference, preview==dynamic parametarized but imagegen would be something in-between so I would only caution not to make the request url quite so obvious; imagegen b/c its static only after action.

Note: I've found that the grey-oval serves to mark Items that don't have a generated preview graphic. They stick-out in my lists but that's b/c they're rare. If your use is to have mostly Video that aren't recognized @thetvdb.com then you're possibly fighting a problem outside of MRP domain?

dschwilk commented 9 years ago

Hi, my videos (pretty much all backups of my kid's movies) are able to be found in @thetvdb.com (or actually the movie db version). I

I put the resizing code in my resize-images branch and will submit a pull request. I'm not sure I understand your request, "I would only caution not to make the request url quite so obvious; imagegen b/c its static only after action." Is that a reference to my poorly named "thumbnail" request parameter which could be "imagen"? I'm also not sure where it is best to set the preview/thumbnail (as a separate size param in player_feed?). Sorry, I may use wrong terminology. I can change but was not sure what you were suggesting.

I had had a separate problem for videos of TV shows (I don't have many of those). But that was a problem in player_feed.php for me that created incorrect paths for the screenshot urls. I fixed it in player_feed but that broke other screenshots. This must be file the naming issue you mention above. Here is commit that reverted change:

https://github.com/dschwilk/MythRokuPlayer/commit/65bc65849a9483d21d3a02b6080e5389ae4cbc29

I need to track down what is going on with the screenshot location inconstencies.

rshendershot commented 9 years ago

Right, I was a little bit concerned that Stream,Thumbnail in the GET request provided too much info to the outside world. Prefer that the type (static image, static w/action, dynamic by parameters) be kept conceptually but admit that's not a clear point in my current code ;)