Author Topic: Movie Layer  (Read 4178 times)

MOcean

  • Moderator
  • ****
  • Posts: 822
  • Michael Ocean
    • View Profile
Re: Movie Layer
« Reply #15 on: August 07, 2015, 10:36:51 PM »
Definitely bad issues pre loading MP4 with VP, avi is fine but these can't be pre-loaded?. It's fine on normal boot with python.

This is strange!

Looking at the pre-loader code now and only a file extension of mp4 is handled via OpenCV/ffmpeg, while an AVI is loaded via PIL and seems to be as a single image.  Are you sure AVI was working?  I'm just not seeing how that could be the case from what I'm looking at.  Did the file have an extension of .avi or .mp4?

Thanks!

dave_h

  • Wizard
  • *****
  • Posts: 185
    • View Profile
Re: Movie Layer
« Reply #16 on: August 07, 2015, 10:43:01 PM »
Yeah you can't preload AVI. Preloading MP4 with VP is insti-crash for me but fine otherwise (switch matrix or terminal.)

This way is working really nice and quick for me:

Code: [Select]
self.layer = self.game.generateAviLayer("assets/movie/test.avi",192,64)
Skeleton game
Code: [Select]
    def generateAviLayer(self, filename,width=480,height=240,opaque=False,hold=False,repeat=False,frame_time=1,frame_pointer=0):
        video_layer = movie.Movie().load(filename)
        video_layer.width=width
        video_layer.height=height
        out_layer = MovieLayer(opaque,hold,repeat,frame_time,video_layer)
        return out_layer

Attract.yaml
Code: [Select]
    - Movie:
        Name: test.avi
        lampshow: attract_show_1
        duration: 44.00

^^ Duration makes no odds obviously, it's there to look good at the moment.




dave_h

  • Wizard
  • *****
  • Posts: 185
    • View Profile
Re: Movie Layer
« Reply #17 on: August 07, 2015, 10:45:45 PM »
Code: [Select]
elif ('Movie' in yamlStruct):
v = yamlStruct['Movie']
movie = dmd.Movie().load('assets\\movie\\' + value_for_key(v,'Name'))
lyrTmp = dmd.MovieLayer(movie=movie)
duration = [value_for_key(v,'Duration')]

And in the dmd helper ^^

MOcean

  • Moderator
  • ****
  • Posts: 822
  • Michael Ocean
    • View Profile
Re: Movie Layer
« Reply #18 on: August 08, 2015, 01:33:30 PM »
Dave: Thank you for pushing me to make this better!

So, I didn't make the exact changes you recommended, but instead decided to implement a feature that I'd had on my 'to-do' list for far too long: you can now tag an animation as 'streamingMovie' and now the animation will be loaded as a movie that is decoded on the fly.  So there's no difference between a movieLayer and an animationLayer if you're using the abstracted interface provided by the assetManager, and that means it works just find to include these keys as 'animations' in your attract.yaml :)

I also fixed/enhanced some other stuff too while I was "under the hood" in this region of the code. 

Here are the change notes for the latest version that I just pushed up to gitHub:

Code: [Select]
1. Added a movie_file_path argument to a MovieLayer so that a movie layer can be created without first creating a Movie instance.
2. Changed the Movie class so it notices a different kind of failure to load the movie
3. Changed animation.load() to support the avi extension (previously only mp4 was supported through that interface)
4. Tagging an animation with 'streamingMovie' will cause it to be created as a movieLayer that is decoded on the fly -- note this should ONLY be used for .avi or .mp4 files
5. Fixed a bug that load would fail on files with uppercase extensions.

And here's a link to just the changes for those who are interested in the 'how' and the 'what' :)
https://github.com/mjocean/PyProcGameHD-SkeletonGame/commit/c0f75e11475a05f267ffb540e3cae98c1b3b8995

Thanks!
- Michael

dave_h

  • Wizard
  • *****
  • Posts: 185
    • View Profile
Re: Movie Layer
« Reply #19 on: August 08, 2015, 01:48:45 PM »
Quote
So, I didn't make the exact changes you recommended

:) No way recommended, just my quick workarounds!

Great, I was just about to set in for the evening to do some work on a game. I can get this loaded shortly and put it to use mate! Awesome, thanks a lot for upgrading it!

dave_h

  • Wizard
  • *****
  • Posts: 185
    • View Profile
Re: Movie Layer
« Reply #20 on: August 08, 2015, 02:46:26 PM »
Is the MovieLayer in layers.py missing duration?

Code: [Select]
AttributeError: 'MovieLayer' object has no attribute 'duration'
asset_list.yaml
Code: [Select]
- key : 'testmovie'
  file: 'testmovie.avi'
  frame_time : 1
  repeatAnim : False 
  streamingMovie: True

attract.yaml
Code: [Select]
    - Animation:
        Name: testmovie
        lampshow: attract_show_1
        duration: 44     

dave_h

  • Wizard
  • *****
  • Posts: 185
    • View Profile
Re: Movie Layer
« Reply #21 on: August 08, 2015, 03:03:46 PM »
I've added a few variables copied from the Animated layer just to get past the errors.

Not sure if I'm doing it right but if mp4 or avi is tagged with "streamingMovie"  the attract just skips that animation block. If set to False it plays ok.

MOcean

  • Moderator
  • ****
  • Posts: 822
  • Michael Ocean
    • View Profile
Re: Movie Layer
« Reply #22 on: August 08, 2015, 03:11:23 PM »
The fix is on GitHub now.  It is computed based on the length of the animation, frame time, and the fps setting in the config.yaml

dave_h

  • Wizard
  • *****
  • Posts: 185
    • View Profile
Re: Movie Layer
« Reply #23 on: August 08, 2015, 03:14:28 PM »
Insti-support  ;D Nice.

I nearly had it apart from I missed: duration = None, just copied the method  :-* and the other vars. Thanks!

dave_h

  • Wizard
  • *****
  • Posts: 185
    • View Profile
Re: Movie Layer
« Reply #24 on: August 09, 2015, 05:05:50 AM »
Just a small one here. If you check the MovieLayer you have 2 reset methods. Had me changing things for 20 minutes, like what is going on! Merging them is good :)

MOcean

  • Moderator
  • ****
  • Posts: 822
  • Michael Ocean
    • View Profile
Re: Movie Layer
« Reply #25 on: August 09, 2015, 01:52:10 PM »
Just a small one here. If you check the MovieLayer you have 2 reset methods. Had me changing things for 20 minutes, like what is going on! Merging them is good :)

Good catch.  checking in that change now.  I just realized I missed some that you mentioned a few days ago (aside from docs).   I'll have to run those down, too.  Thanks again!

dave_h

  • Wizard
  • *****
  • Posts: 185
    • View Profile
Re: Movie Layer
« Reply #26 on: August 09, 2015, 06:48:18 PM »
No worries the Movie layers are veeeeeeerrry good now. I think I can finally ditch the old VLC module I was using for 2 separate screen

MOcean

  • Moderator
  • ****
  • Posts: 822
  • Michael Ocean
    • View Profile
Re: Movie Layer
« Reply #27 on: August 09, 2015, 10:14:17 PM »
The MovieLayer is almost entirely Rosh's work. I did very little on this one other than some of the more recent convenience methods. All credit for the MP4 decoding should really go to him on this front.

When I finally get the installer to support the HD branch, then my only complaint about it (the nuisance of installing OpenCV, libffmpeg, etc) will be finally invalidated ...for windows users, at least.



No worries the Movie layers are veeeeeeerrry good now. I think I can finally ditch the old VLC module I was using for 2 separate screen

dave_h

  • Wizard
  • *****
  • Posts: 185
    • View Profile
Re: Movie Layer
« Reply #28 on: August 09, 2015, 11:32:50 PM »
Nice, I thought Rosh had just done the audio  ;D  > JK

But really just happy with the new streaming tag with avi's, I've had lot's going with it , including running them as backgrounds and lots going at the same time and it's perfect so far....touch wood.

I dug an old laptop out and was going to try the on click install with XP but I've decided to go Ubuntu on that instead. So far compared to windows it's been a lot easier for setup and I'm a complete linux noob. I'm yet to get to the point of setting up skeleton game though with OpenCV though. I just wanted a second dev station so I can work on bits wherever. Setting up some gitlabs and will invite you over so you can try and test for yourself if you need/want to.

Yeah its a bit of a nuisance but it wasn't THAT bad, quite glad I joined the party late because lots of those issues were already ironed out with set up etc.

MOcean

  • Moderator
  • ****
  • Posts: 822
  • Michael Ocean
    • View Profile
Re: Movie Layer
« Reply #29 on: August 15, 2015, 03:39:09 PM »
Okay, I've fallen behind on this stuff while trying to catch up on some other things.

Just for fun, here's a screenshot of four videos playing simultaneously "WoZ style".  These videos are not streaming loaded from mp4 (pre-loaded).  This is 900x450, but I also ran it at 1280x720 just fine.

At 30FPS I'm seeing a loop rate well in excess of 5000Hz, of course, that's on my laptop and ymmv.

SDL2 is a monster :)