Add Video Module


#1

Hi,

Beginner question here:
The videomodulation example hasn’t got the videomodule added to its project.json required modules list.

When trying to get a videoPlayer Ressource in napkin, i have to first add the required module ( mod_napvideo ) in the project.json. Is there a way to get the module to be added automatically in napkin somehow?

Thks,

P


#2

Hi @pierrextardif, welcome to the forum!

After building the videomodulation demo (release mode) and loading the project into napkin, the mod_napvideo module should already be loaded for you, as shown in the modules panel:

The videomodulation demo needs the video module to load and play the videos linked to in the VideoPlayer resource. As shown in the screenshot. The player itself is linked to by the nap::RenderVideoComponent, as part of the VideoEntity, which renders the video to an RGB texture, used by the rest of the application for displacement, the backdrop etc.

By right clicking on Resources you should be able to add another VideoPlayer. Note that the project.json file does not link to the video_module directly. Instead: it links to mod_videomodulation, which is the custom application module. This module links to mod_napvideo:

{
    "Type": "nap::ModuleInfo",
    "mID": "ModuleInfo",
    "RequiredModules": [
        "mod_naprender",
        "mod_napvideo",
        "mod_napscene",
        "mod_napaudio",
        "mod_napmath"
    ],
    "WindowsDllSearchPaths": []
}

The mod_videomodulation module (demos\videomodulation\module) contains the custom building blocks that are required but specific to the video modulation application. In this case that’s the videomeshfromfile (custom mesh) resource and selectvideomeshcomponentcomponent (to select the mesh).

Napkin & NAP applications, when loading the project.json file, automatically load all modules and module dependencies, including in this case mod_napvideo. Every resource exposed by the module is automatically added to Napkin after the module is loaded and inspected, including in this case the videoplayer. But why include the module in mod_videomodulation and not in project.json? That’s because we want access to the building blocks in the video module to create the custom building blocks in our own module.

Hope this makes sense, if you have any further questions lmk!


#3

Alright perfect thanks, understood now.


#4

Perfect, glad to be of help. I noticed others had similar questions. We’ll try to improve documentation related to module and resource management for the next release.


#5

Hi,

Coming back to this, it seems like if the mod_napvideo is added to the module, it is not appearing in napkin:

I’ve create a blank project and only added the mod_napvideo to the custom application mdule:


{
    "Type": "nap::ModuleInfo", 
    "mID": "ModuleInfo", 
    "RequiredModules": [
        "mod_naprender",
        "mod_napscene",
        "mod_napparameter",
        "mod_napvideo"
    ], 
    "WindowsDllSearchPaths": []
}


I believe I have followed the correct steps:

  1. create the project,
  2. compile it in Release,
  3. change the module/module.json
  4. execute regenerate.bat, giving me :

videotest>.\regenerate.bat
Found project at C:\Users\Jonathan\Documents\DEV\NAP-0.4.4-Win64\projects\videotest
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19042.
-- Using NAP root: C:/Users/Jonathan/Documents/DEV/NAP-0.4.4-Win64
-- Using thirdparty directory: C:/Users/Jonathan/Documents/DEV/NAP-0.4.4-Win64/thirdparty
-- Found rapidjson header files in C:/Users/Jonathan/Documents/DEV/NAP-0.4.4-Win64/thirdparty/rapidjson/include
Found project module in C:/Users/Jonathan/Documents/DEV/NAP-0.4.4-Win64/projects/videotest/module/
-- Adding library path for mod_naprender
-- Adding library path for mod_napscene
-- Adding library path for mod_napparameter
-- Adding library path for mod_napvideo
-- Found FFMPEG or Libav: C:/Users/Jonathan/Documents/DEV/NAP-0.4.4-Win64/thirdparty/FFmpeg/bin/avcodec.lib;C:/Users/Jonathan/Documents/DEV/NAP-0.4.4-Win64/thirdparty/FFmpeg/bin/avformat.lib;C:/Users/Jonathan/Documents/DEV/NAP-0.4.4-Win64/thirdparty/FFmpeg/bin/avutil.lib, C:/Users/Jonathan/Documents/DEV/NAP-0.4.4-Win64/thirdparty/FFmpeg/include
-- Adding library path for mod_napfont
-- Adding library path for mod_napinput
-- Adding library path for mod_napcolor
-- Adding library path for mod_napmath
-- Adding library path for mod_napaudio
-- Adding library path for mod_napapp
-- Adding library path for mod_napcameracontrol
-- Adding library path for mod_napparametergui
-- Adding library path for mod_napimgui
-- Found FFMPEG or Libav: C:/Users/Jonathan/Documents/DEV/NAP-0.4.4-Win64/thirdparty/FFmpeg/bin/avcodec.lib;C:/Users/Jonathan/Documents/DEV/NAP-0.4.4-Win64/thirdparty/FFmpeg/bin/avformat.lib;C:/Users/Jonathan/Documents/DEV/NAP-0.4.4-Win64/thirdparty/FFmpeg/bin/avutil.lib, C:/Users/Jonathan/Documents/DEV/NAP-0.4.4-Win64/thirdparty/FFmpeg/include
-- Adding library path for mod_napsdlinput
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/Jonathan/Documents/DEV/NAP-0.4.4-Win64/projects/videotest/msvc64
Solution generated in msvc64

  1. open napkin, nd try to add a VideoPlayer :

I’m on windows10 with Nap version 0.4.4 Win64.

Here is the project example maybe if you want to check it out yourself?

Obviously I can add the mod_napvideo straight into the project.json , but you said the resource should be exposed by the module.

Hope this makes sense,

Best,

P


#6

Hi @pierrextardif,

Looks to me like the compiled binaries of the video module are still missing. Napkin requires these to access type information. Have you rebuilt the project after adding mod_napvideo to your module/module.json and regenerating your solution?

The correct order would be:

  1. Create the project
  2. Add the video module (i.e. add mod_napvideo to module/module.json)
  3. Regenerate your solution
  4. Build your project. If the video module had not been included in a project before this, this should be the first time it is built - unless you built the entire framework (msvc64/NAP.sln). You should now be able to find the video module’s binaries in bin/...Release.
  5. Open napkin (release) - video resources should be there now

Good luck!


#7

Ah yeah,

Thaks for the tip @lshoek, it works when adding it this way.

Best,

P


#8

I’m looking into adding modules and compiling a project directly from within Napkin for a future release of NAP. Ideally, Napkin compiles the project when opened / created for the first time or when a change to the module.json / project.json is detected. This should help prevent confusion.