Author Topic: mp4 support for FullColor-hdDMD-pyprocgame  (Read 1940 times)

Rosh

  • P3 Developers
  • *
  • Posts: 667
  • Josh Kugler
    • View Profile
mp4 support for FullColor-hdDMD-pyprocgame
« on: May 30, 2014, 10:59:37 AM »
I've done an update to the Full Color version fork of pyprocgame that MOcean and I have been working on for the last few months.  This enhancement is not yet in MOcean's GIT repository as we are "debating" the method. 

The method I have written relies on openCV to handle the pulling of the images out of the mp4 file and then creating the dmdAnimation.  At that point this behaves like any other DMD animation you may be using.  The big advantage to this is that the file sizes are significantly smaller.  Based on some testing, the time it takes to load/process the mp4 is the same as using a dmd or dmd.zip file (zip files are supported in the HD fork).  As a reminder, the hdDMD version of pyprocgame uses pygame surfaces vs bitmaps for the dmd frames.  So even a DMD file at load time gets loaded and processed into a set of surfaces.

The difference in file sizes of a 300 frame test file . . .

.mp4          1.4 MB
.dmd         180MB
.dmd.zip     41MB


Obviously the other big benefit is not having to do the extra conversion when working on your animations before testing them out.

MOcean is concerned about needing an additional library (openCV), so for anyone who is using this fork, do you feel that is a concern/roadblock if you wanted to use mp4 conversion?

There is a possible alternative we (well Michael), may look at using FFMPEG or something similar. 

Keep in mind this speed testing was done using an SSD, so it is possible that the the mp4 performance would improve on a slower drive, but my guess is until the files got really big it would still be negligible.  I have also not looked at any optimization of the code, however, there is really not much code to optimize, since it is only about 12 lines. 


dave_h

  • Guest
Re: mp4 support for FullColor-hdDMD-pyprocgame
« Reply #1 on: May 31, 2014, 03:02:23 PM »
.
« Last Edit: July 16, 2014, 12:36:23 PM by dave_h »

MOcean

  • P3 Developers
  • *
  • Posts: 820
  • Michael Ocean
    • View Profile
Re: mp4 support for FullColor-hdDMD-pyprocgame
« Reply #2 on: May 31, 2014, 05:23:30 PM »

Not too bothered about the size of these .dmd files atm.

Option to play sound as well ?

It doesn't play sound stored in the mp4. MP4 is being used in this instance as a compression container for video frames which are immediately unpacked (on game load) and then treated like regular AnimatedFrameLayers (backed by pyGame surfaces).  This code doesn't even use the MP4 meta data for frame rate. If you're not interested in saving space then this probably isn't going to help you very much. It's just a different series of tools to pump your source video through at that rate.

dave_h

  • Guest
Re: mp4 support for FullColor-hdDMD-pyprocgame
« Reply #3 on: May 31, 2014, 05:57:33 PM »
.
« Last Edit: July 16, 2014, 12:36:16 PM by dave_h »

Rosh

  • P3 Developers
  • *
  • Posts: 667
  • Josh Kugler
    • View Profile
Re: mp4 support for FullColor-hdDMD-pyprocgame
« Reply #4 on: June 02, 2014, 12:20:17 PM »
one interesting thing that MOcean has raised is around blacksrc and the lossy nature of MP4 and wether a 'near black', which is often used when you want black on an dmd that is going to use blacksrc, is going to be treated as black.  In most cases a large file like this is going to be some form of intro or background so likely not blacksrc, but will have to do some testing around this to see how big a risk it is.

It is certainly possible to grab the frame rate and set that for the file, however, there is of course the issue of the game framerate not being a match for the file in question (e.g. game running at 30FPS and a MP4 set to run at 25.

It would probably be feasible to also strip the audio out but don't think openCV can do that, so likely need a different tool/approach.  Of course whether those would play in sync is a different question and it would be hard to get it to do so.

I would love to find a way to use MP4 as is, and overlay on top of it, but that is a far more completed change to how layers and frames work. 

dave_h

  • Guest
Re: mp4 support for FullColor-hdDMD-pyprocgame
« Reply #5 on: June 02, 2014, 01:48:38 PM »
.
« Last Edit: July 16, 2014, 12:36:09 PM by dave_h »

Richard_Blaim

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: mp4 support for FullColor-hdDMD-pyprocgame
« Reply #6 on: March 18, 2015, 06:24:23 AM »
Is it also possible to play an MP4 video via the normal framework ? E.g. the Indiana Jones software will just be rebuild by a forum member and he wants as an introduction, play a short Indiana Jones video on a color monitor. Are there already any functions to play videos like playing music ? How could that be realized ?

Rosh

  • P3 Developers
  • *
  • Posts: 667
  • Josh Kugler
    • View Profile
Re: mp4 support for FullColor-hdDMD-pyprocgame
« Reply #7 on: March 18, 2015, 09:59:02 AM »
there is no support for it in the standard framework.  You can use a video or audio editing tool to pull the audio, then you can export the mp4 as an image sequence, which can then be converted into a dmd file. 

There are online converters that can help with this if you don't have any editing tools.

I think there is tutorial on the forum on another way to do this using some standard tools.